Skip to content

Commit

Permalink
Update documentation and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
bonicim committed Apr 4, 2024
1 parent 70360f1 commit 539ff90
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 67 deletions.
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@ venv: clean-venv
clean-venv:
rm -rf $(VENV)

.PHONY: install-reqs
install-reqs:
pip install --upgrade pip
.PHONY: install
install:
@$(PYTHON3) -m pip install --upgrade pip
@$(PYTHON3) -m pip install -e .
@$(PYTHON3) -m pip install -r requirements.txt
pip install pytest pytest-cov decorator

## Environment using Poetry

.PHONY: develop
develop: clean-poetry-env
poetry install --all-extras --with test
poetry shell
poetry install --with test


.PHONY: requirements.txt
requirements.txt:
Expand Down
98 changes: 65 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,29 +190,71 @@ Ensure that you have [git](https://git-scm.com/book/en/v2/Getting-Started-Instal
```shell
git clone https://github.com/pnnl/HyperNetX.git
cd HyperNetX

# Create a virtual environment
make venv
source venv-hnx/bin/activate
pip install .

# install required dependencies
make install
```

Development
===========

Install an editable version
---------------------------

```
pip install -e .
```

Install an editable version with supported applications
-------------------------------------------------------
Install additional dependencies to support testing and jupyter notebooks:
```
pip install -r requirements.txt
```

```shell
pip install -e .['all']
You can also install all these requirements in one Make target:

```
make install
```

Poetry
======

# for zsh users
pip install -e .'[all]'
This library uses [Poetry](https://python-poetry.org/docs/) to manage dependencies and packaging. Poetry can also be
used to manage your environment for development.

Prerequisites
-------------

* [Install Poetry](https://python-poetry.org/docs/#installation)


Configure Poetry
----------------

[Configure your Poetry](https://python-poetry.org/docs/configuration/) to create the virtual environment in your project directory:
```
poetry config virtualenvs.in-project true
# check the poetry configuration
poetry config --list
```

Set up virtual environment
----------------------------

Create and activate a virtual environment.
```
poetry shell
```

NOTE: If you plan to use Poetry to manage your virtual environment, you can activate the virtual environment
using poerty: `poetry shell`. Another option is to directly

Install required dependencies and HyperNetX in editable mode.
```
poetry install
```

Install support for testing
Expand All @@ -221,7 +263,7 @@ Install support for testing
> ℹ️ **NOTE:** This project has a pytest configuration file named 'pytest.ini'. By default, pytest will use those configuration settings to run tests.
```shell
make test-deps
poetry install --with test

# run tests
python -m pytest
Expand All @@ -237,17 +279,13 @@ open htmlcov/index.html
Install support for tutorials
-----------------------------

``` shell
make tutorial-deps
```
poetry install --with tutorials
# open Jupyter notebooks in a browser
make tutorials
```





Code Quality
------------
HyperNetX uses a number of tools to maintain code quality:
Expand All @@ -257,12 +295,12 @@ HyperNetX uses a number of tools to maintain code quality:

Before using these tools, ensure that you install Pylint in your environment:

```shell
make lint-deps
```
poetry install --with lint
```


### Pylint
Pylint
------

[Pylint](https://pylint.pycqa.org/en/latest/index.html) is a static code analyzer for Python-based projects. From the [Pylint docs](https://pylint.pycqa.org/en/latest/index.html#what-is-pylint):

Expand All @@ -282,37 +320,31 @@ pylint hypernetx --output=pylint-results.txt

For more information on configuration, see https://pylint.pycqa.org/en/latest/user_guide/configuration/index.html

### Black

Black
-----
[Black](https://black.readthedocs.io/en/stable/) is a PEP 8 compliant formatter for Python-based project. This tool is highly opinionated about how Python should be formatted and will automagically reformat your code.


```shell
make format-deps
black hypernetx
```

Documentation
===============
-------------

Build and view documentation locally
---------------------------
Build and view documentation locally:

```
make docs-deps
poetry install --with docs
cd docs
make html
open docs/build/html/index.html
```

Editing documentation
----------------------

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.

```
make docs-deps
cd docs
make livehtml
```
Expand Down Expand Up @@ -353,15 +385,15 @@ 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
make version-deps
pip install commitizen

# Updates version; values for '--increment' can be MAJOR, MINOR, or PATCH
# Autocreates a tag and commit for the updated version
Expand Down
31 changes: 10 additions & 21 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
Installing HyperNetX
********************


Installation
############

The recommended installation method for most users is to create a virtual environment
and install HyperNetX from PyPi.

Expand Down Expand Up @@ -56,43 +52,39 @@ To deactivate your environment, use:
>>> .\env-hnx\Scripts\deactivate


Installing Hypernetx
####################
Installation
############

Regardless of how you install HyperNetX, ensure that your environment is activated and that you are running Python >=3.8.

Installing from PyPi
*************************
********************

>>> pip install hypernetx

If you want to use supported applications built upon HyperNetX (e.g. ``hypernetx.algorithms.hypergraph_modularity`` or
``hypernetx.algorithms.contagion``), you can install HyperNetX with those supported applications by using
the following command:

>>> pip install hypernetx[all]

If you are using zsh as your shell, use single quotation marks around the square brackets:

>>> pip install hypernetx'[all]'
>>> pip install igraph celluloid

Installing from Source
*************************
**********************

Ensure that you have ``git`` installed.

>>> git clone https://github.com/pnnl/HyperNetX.git
>>> cd HyperNetX
>>> make venv
>>> source venv-hnx/bin/activate
>>> pip install .
>>> make install


Post-Installation Actions
##########################
#########################

Interact with HyperNetX in a REPL
********************************************
*********************************

Ensure that your environment is activated and that you run ``python`` on your terminal to open a REPL:

Expand All @@ -108,7 +100,7 @@ Ensure that your environment is activated and that you run ``python`` on your te


Other Actions if installed from source
********************************************
**************************************

If you have installed HyperNetX from source, you can perform additional actions such as viewing the provided Jupyter notebooks
or building the documentation locally.
Expand All @@ -121,7 +113,6 @@ Viewing jupyter notebooks

The following command will automatically open the notebooks in a browser.

>>> make tutorial-deps
>>> make tutorials


Expand All @@ -130,9 +121,7 @@ Building documentation

The following commands will build and open a local version of the documentation in a browser:

>>> make docs-deps
>>> pip install sphinx sphinx-autobuild sphinx-rtd-theme sphinx-copybutton
>>> cd docs
>>> make html
>>> open build/index.html


12 changes: 6 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ python = "^3.8,<3.12"
networkx = "^2.2"
pandas = "^1.5.3"
scikit-learn = "^1.3.2"

[tool.poetry.group.algorithms.dependencies]
decorator = "^5.1.1"
celluloid = "^0.2.0"
igraph = "^0.11.4"
decorator = "^5.1.1"

[tool.poetry.group.widget]
optional = true
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ h11==0.14.0
hnxwidget==0.1.1b3
httpcore==1.0.5
httpx==0.27.0
-e git+ssh://git@stash.pnnl.gov:7999/hyp/hypernetx.git@70360f14748f8f66188a04179d741201452e389a#egg=hypernetx
idna==3.6
igraph==0.11.4
iniconfig==2.0.0
Expand Down Expand Up @@ -74,7 +75,7 @@ matplotlib-inline==0.1.6
mistune==3.0.2
nbclient==0.6.8
nbconvert==7.16.3
nbformat==5.10.3
nbformat==5.10.4
nbmake==1.5.3
nest-asyncio==1.6.0
networkx==2.8.8
Expand Down

0 comments on commit 539ff90

Please sign in to comment.