diff --git a/Makefile b/Makefile index 9d9dd79a..b40349d4 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ PYTHON3 = python3 ############# Manage Environments ############# -## Environment using Pip +## Create environment using Pip .PHONY: venv venv: clean-venv @$(PYTHON3) -m venv $(VENV); @@ -19,19 +19,28 @@ install: @$(PYTHON3) -m pip install -e . @$(PYTHON3) -m pip install -r requirements.txt -## Environment using Poetry +## Create environment using Poetry -.PHONY: develop -develop: clean-poetry-env - poetry shell +.PHONY: install-with-poetry +install-with-poetry: + poetry env remove --all poetry install --with test - +## Create new requirements.txt from current poetry environment .PHONY: requirements.txt requirements.txt: poetry export --format requirements.txt --output requirements.txt --without-hashes --with test,widget,tutorials,docs -############# Running Tests, linters ############# +############# Tutorials ############# +.PHONY: tutorials +tutorials: + jupyter notebook tutorials + +.PHONY: clean +clean: + rm -rf .out .pytest_cache .tox *.egg-info dist build _build pytest.xml pytest_notebooks.xml .coverage + +############# Running Tests, linters, formatters ############# ## Tests .PHONY: test @@ -45,37 +54,12 @@ test-core: coverage report -m -## Tests using Tox +## Run test on Tox framework ## Includes linting, running tests on jupyter notebooks .PHONY: test-tox test-tox: @$(PYTHON3) -m tox --parallel -### Tests using Poetry + Tox -### Used by Bamboo CI Pipeline, Github Workflows CI Pipeline - -.PHONY: test-ci-stash -test-ci-stash: install-poetry-stash run-poetry-tox clean-poetry-env - -.PHONY: build-docs-stash -build-docs-stash: install-poetry-stash run-build-docs clean-poetry-env - -.PHONY: install-poetry-stash -install-poetry-stash: - pip install poetry==1.8.2 tox - -.PHONY: run-poetry-tox -run-poetry-tox: - tox --parallel - -.PHONY: run-build-docs -run-build-docs: - tox -e build-docs - -.PHONY: clean-poetry-env -clean-poetry-env: - poetry env remove --all - ## Lint .PHONY: lint lint: pylint flake8 @@ -89,37 +73,8 @@ pylint: flake8: @$(PYTHON3) -m flake8 hypernetx --exit-zero +## precommit hooks that include formatter (Black) .PHONY: pre-commit pre-commit: pre-commit install pre-commit run --all-files - -############# Packaging and Publishing to PyPi ############# -## Uses Poetry to manage packaging and publishing -## Targets are included as a backup in case the Github Workflows CI can't publish to PyPi and we need to do it manually -## Assumes the following environment variables are set: PYPI_API_TOKEN -.PHONY: publish-to-pypi -publish-to-pypi: build check-long-desc - @echo "Publishing to PyPi" - poetry config pypi-token.pypi PYPI_API_TOKEN - poetry config repositories.pypi https://pypi.org/simple/ - poetry publish --dry-run - #poetry publish - -.PHONY: build -build: clean - poetry build - -.PHONY: check-long-desc -check-long-desc: - poetry run pip install twine - poetry run twine check dist/* - -############# Misc ############# -.PHONY: tutorials -tutorials: - jupyter notebook tutorials - -.PHONY: clean -clean: - rm -rf .out .pytest_cache .tox *.egg-info dist build _build pytest.xml pytest_notebooks.xml .coverage diff --git a/README.md b/README.md index 55e60eaf..ab3c519e 100644 --- a/README.md +++ b/README.md @@ -72,37 +72,37 @@ Google Colab Open In Colab Basic 1 - HNX Basics -
+
Open In Colab Basic 2 - Visualization Methods -
+
Open In Colab Basic 3 - LesMis Case Study -
+
Open In Colab Basic 4 - LesMis Visualizations-Book Tour -
+
Open In Colab Basic 5 - HNX attributed hypergraph -
+
Open In Colab Basic 6 - Hypergraph Arithmetic.ipynb -
+
Jupyter Notebooks @@ -115,7 +115,7 @@ Installation The recommended installation method for most users is to create a virtual environment and install HyperNetX from PyPi. -HyperNetX may be cloned or forked from [Github](https://github.com/pnnl/HyperNetX). +HyperNetX may be cloned or forked from [GitHub](https://github.com/pnnl/HyperNetX). Prerequisites ------------- @@ -168,7 +168,7 @@ To deactivate your environment, use: Installing HyperNetX ==================== -Regardless of how you install HyperNetX, ensure that your environment is activated and that you are running Python >=3.8. +Regardless of how you install HyperNetX, ensure that your environment is activated and that you are running Python >=3.10. Installing from PyPi @@ -261,6 +261,9 @@ Install support for testing ```shell poetry install --with test +# activate your virtual environment created by poetry +poetry shell + # run tests python -m pytest @@ -275,9 +278,12 @@ open htmlcov/index.html Install support for tutorials ----------------------------- -``` +```shell poetry install --with tutorials +# activate your virtual environment created by poetry +poetry shell + # open Jupyter notebooks in a browser make tutorials ``` @@ -291,8 +297,10 @@ HyperNetX uses a number of tools to maintain code quality: Before using these tools, ensure that you install Pylint in your environment: -``` +```shell poetry install --with lint +# activate your virtual environment created by poetry +poetry shell ``` Pylint @@ -325,13 +333,30 @@ Black black hypernetx ``` +Pre-commit +--------- + +Use the [pre-commit framework](https://pre-commit.com/) to automatically point out issues and resolve those issues before code review. +It is highly recommended to install pre-commit in your development environment so that issues with your code can be found before you submit a +pull request. More importantly, using pre-commit will automatically format your code changes so that they pass the CI build. For example, pre-commit will +automatically run the formatter Black on your code changes. + +```shell +pre-commit install + +# Once installed, pre-commit will be triggered every time you make a commit in your environment +``` + Documentation ------------- Build and view documentation locally: -``` +```shell poetry install --with docs +# activate your virtual environment created by poetry +poetry shell + cd docs make html open docs/build/html/index.html @@ -340,7 +365,7 @@ open docs/build/html/index.html When editing documentation, you can auto-rebuild the documentation locally so that you can view your document changes live on the browser without having to rebuild every time you have a change. -``` +```shell cd docs make livehtml ``` @@ -360,49 +385,12 @@ Click on `http://127.0.0.1:8000/install.html` to open the docs on your browser. you change a document file, it will automatically render on your browser, allowing you to verify your document changes. -Continuous Integration -====================== - -This project runs Continuous Integration (CI) using GitHub Actions. Normally, CI runs -on pull requests, pushes to certain branches, and other events. - -Maintainers of the GitHub repository can manually trigger CI using [GitHub CLI](https://cli.github.com/). See instructions below on how to manually trigger CI on GitHub Actions: - -```commandline -# login to Github -gh auth login --with-token < ~/.ssh/tokens/ - -# Trigger CI -gh workflow run ci.yml --repo pnnl/HyperNetX --ref --field triggeredBy="" - -# Get the status of the workflow -gh run list --workflow=ci.yml --repo pnnl/HyperNetX -``` - - -Versioning -========== - -This project uses [`commitizen`](https://github.com/commitizen-tools/commitizen) to manage versioning. -The files where "version" will be updated are listed in the '.cz.toml' file. To create a new version and the associated tag, -run the following commands: - -```shell -# Install commitizen tool to environment -pip install commitizen - -# Updates version; values for '--increment' can be MAJOR, MINOR, or PATCH -# Autocreates a tag and commit for the updated version -cz bump --increment MAJOR --dry-run -cz bump --increment MAJOR -``` - Notice ====== This material was prepared as an account of work sponsored by an agency of the United States Government. Neither the United States Government nor the United States Department of Energy, nor Battelle, nor any of their employees, nor any jurisdiction or organization that has cooperated in the development of these materials, makes any warranty, express or implied, or assumes any legal liability or responsibility for the accuracy, completeness, or usefulness or any information, apparatus, product, software, or process disclosed, or represents that its use would not infringe privately owned rights. Reference herein to any specific commercial product, process, or service by trade name, trademark, manufacturer, or otherwise does not necessarily constitute or imply its endorsement, recommendation, or favoring by the United States Government or any agency thereof, or Battelle Memorial Institute. The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or any agency thereof. -
+
    PACIFIC NORTHWEST NATIONAL LABORATORY
    operated by