Skip to content

Commit

Permalink
Pull request #22: Add continuous integration; reformat codebase to Py…
Browse files Browse the repository at this point in the history
…thon Black

Merge in HYP/hypernetx from feature/HYP-262-create-ci-cd-pipelines-to-automate-the-deployment-process to develop

* commit '7a0ac8b5557a551c3d377bf458c930334b328ebf':
  Reformat codebase to Python Black
  Update precommit hooks
  Add continuous integration for Github
  • Loading branch information
madelynshapiro committed Aug 29, 2022
2 parents d666dda + 7a0ac8b commit 771e556
Show file tree
Hide file tree
Showing 34 changed files with 395 additions and 160 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[run]
omit = */tests/*
omit = */tests/*
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Continuous Integration


on:
push:
branches: [master, develop, release/**]
pull_request:
types: [opened, synchronize, reopened]

defaults:
run:
shell: bash

env:
LANG: en_US.utf-8
LC_ALL: en_US.utf-8

jobs:

run-tests:

strategy:
matrix:
os: [ubuntu-20.04, macos-12, windows-2022]
python: ['3.7']

runs-on: ${{ matrix.os }}

steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."

- name: Checkout
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

# https://github.com/pre-commit/action
- name: Run pre-commit hooks
uses: pre-commit/[email protected]

- name: Run tests
run: |
make test-ci
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.DS_Store
gitmerge.sh
dist
.DS_Store
gitmerge.sh
dist
hypernetx.egg-info*
hypernetx.egg-info/PKG-INFO
hypernetx.egg-info/requires.txt
Expand Down
30 changes: 30 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: check-yaml
- id: check-json
- id: check-toml
- id: end-of-file-fixer
exclude: ^(docs/|hypernetx.egg-info/)
- id: trailing-whitespace
exclude: ^(docs/|hypernetx.egg-info/)
- id: check-merge-conflict
- id: no-commit-to-branch
args: ['--branch', 'master'] # blocks master commits. To bypass do git commit --allow-empty

- repo: https://github.com/psf/black
rev: 22.6.0
hooks:
- id: black
exclude: ^(docs/|hypernetx.egg-info/)

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.910-1
hooks:
- id: mypy
exclude: (?x)(docs/|tests/)
args: [--no-strict-optional, --ignore-missing-imports]
2 changes: 1 addition & 1 deletion DISCLAIMER.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ reflect those of the United States Government or any agency thereof.
BATTELLE
for the
UNITED STATES DEPARTMENT OF ENERGY
under Contract DE-AC05-76RL01830
under Contract DE-AC05-76RL01830
35 changes: 20 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@

SHELL = /bin/bash

VENV = .venv_test
PYTHON = $(VENV)/bin/python
PYTHON = $(VENV)/bin/python3
PYTHON3 = python3

## Environment

venv:
@python3 -m venv $(VENV);

deps-testing:
@$(PYTHON) -m pip install -e .'[testing]'

deps-packaging:
@$(PYTHON) -m pip install -e .'[packaging]'

.PHONY: venv deps-testing deps-packaging
.PHONY: venv

## Test

test: clean venv deps-testing
test: clean venv
@$(PYTHON) -m pip install -e .'[auto-testing]'
@$(PYTHON) -m tox

.PHONY: test
test-ci:
@$(PYTHON3) -m pip install -e .'[auto-testing]'
@$(PYTHON3) -m pip install 'pytest-github-actions-annotate-failures>=0.1.7'
pre-commit install
pre-commit run --all-files
@$(PYTHON3) -m tox

.PHONY: test, test-ci

## Build package

build: clean venv deps-packaging
@$(PYTHON) -m build --wheel --sdist
@$(PYTHON) -m twine check dist/*
build-dist: clean
@$(PYTHON3) -m pip install -e .'[packaging]'
@$(PYTHON3) -m build --wheel --sdist
@$(PYTHON3) -m twine check dist/*


publish-to-test-pypi:
Expand All @@ -38,9 +43,9 @@ publish-to-pypi:
@echo "Publishing to PyPi"
# $(PYTHON) -m twine upload --repository pypi dist/*

.PHONY: build publish-to-test-pypi
.PHONY: build-dist publish-to-test-pypi publish-to-pypi

clean:
rm -rf .out .pytest_cache .tox *.egg-info dist build $(VENV)

.PHONY: clean
.PHONY: clean
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@

HyperNetX
=========
![Passing?](https://github.com/pnnl/HyperNetX/actions/workflows/ci.yml/badge.svg)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

The HNX library provides classes and methods for modeling the entities and relationships
The HNX library provides classes and methods for modeling the entities and relationships
found in complex networks as hypergraphs, the natural models for multi-dimensional network data.
As strict generalizations of graphs, hyperedges can represent arbitrary multi-way relations
As strict generalizations of graphs, hyperedges can represent arbitrary multi-way relations
among entities, and in particular can distinguish cliques and simplices, and admit singleton edges.
As both vertex adjacency and edge
incidence are generalized to be quantities,
hypergraph paths and walks thereby have both length and *width* because of these multiway connections.
hypergraph paths and walks thereby have both length and *width* because of these multiway connections.
Most graph metrics have natural generalizations to hypergraphs, but since
hypergraphs are basically set systems, they also admit to the powerful tools of algebraic topology,
including simplicial complexes and simplicial homology, to study their structure.

This library serves as a repository of the methods and algorithms we find most useful
as we explore what hypergraphs can tell us. We have a growing community of users and contributors.
as we explore what hypergraphs can tell us. We have a growing community of users and contributors.
To learn more about some of our research check out our publications below:

Publications
------------
Joslyn, Cliff A; Aksoy, Sinan; Callahan, Tiffany J; Hunter, LE; Jefferson, Brett ; Praggastis, Brenda ; Purvine, Emilie AH ; Tripodi, Ignacio J: (2020) "Hypernetwork Science: From Multidimensional Networks to Computational Topology", in: Int. Conf. Complex Systems (ICCS 2020), https://arxiv.org/abs/2003.11782, (in press)

Feng, Song; Heath, Emily; Jefferson, Brett; Joslyn, CA; Kvinge, Henry; McDermott, Jason E ; Mitchell, Hugh D ; Praggastis, Brenda ; Eisfeld, Amie J; Sims, Amy C ; Thackray, Larissa B ; Fan, Shufang ; Walters, Kevin B; Halfmann, Peter J ; Westhoff-Smith, Danielle ; Tan, Qing ; Menachery, Vineet D ; Sheahan, Timothy P ; Cockrell,
Feng, Song; Heath, Emily; Jefferson, Brett; Joslyn, CA; Kvinge, Henry; McDermott, Jason E ; Mitchell, Hugh D ; Praggastis, Brenda ; Eisfeld, Amie J; Sims, Amy C ; Thackray, Larissa B ; Fan, Shufang ; Walters, Kevin B; Halfmann, Peter J ; Westhoff-Smith, Danielle ; Tan, Qing ; Menachery, Vineet D ; Sheahan, Timothy P ; Cockrell,
Adam S ; Kocher, Jacob F ; Stratton, Kelly G ; Heller, Natalie C ; Bramer, Lisa M ; Diamond, Michael S ; Baric, Ralph S ; Waters, Katrina M ; Kawaoka, Yoshihiro ; Purvine, Emilie: (2020) "Hypergraph Models of Biological Networks to Identify Genes Critical to Pathogenic Viral Response", in: https://arxiv.org/abs/2010.03068, BMC Bioinformatics, 22:287, doi: 10.1186/s12859-021-04197-2

Aksoy, Sinan G; Joslyn, Cliff A; Marrero, Carlos O; Praggastis, B; Purvine, Emilie AH: (2020) "Hypernetwork Science via High-Order Hypergraph Walks", EPJ Data Science, v. 9:16, https://doi.org/10.1140/epjds/s13688-020-00231-0
Expand Down Expand Up @@ -109,10 +111,10 @@ Tutorials may be run in your browser using Google Colab
<span >Tutorial 7 - s-Centrality</span>
</a>
</br>

Installing HyperNetX
====================
HyperNetX may be cloned or forked from: <https://github.com/pnnl/HyperNetX>
HyperNetX may be cloned or forked from: <https://github.com/pnnl/HyperNetX>

To install in an Anaconda environment
-------------------------------------
Expand All @@ -126,9 +128,9 @@ the conda version of matplotlib:

>>> conda create -n <env name> python=3.7 matplotlib
>>> source activate <env name>
>>> pip install hypernetx
>>> pip install hypernetx

To use [NWHy](docs/build/nwhy.html) use python=3.9 and the conda version of tbb in your environment.
To use [NWHy](docs/build/nwhy.html) use python=3.9 and the conda version of tbb in your environment.
**Note** that [NWHy](docs/build/nwhy.html) only works on Linux and some OSX systems. See [NWHy documentation](docs/build/nwhy.html) for more.:

>>> conda create -n <env name> python=3.9 tbb
Expand Down Expand Up @@ -170,13 +172,13 @@ For an editable installation with access to jupyter notebooks:

>>> pip install [-e] .

> ℹ️ **TIP:** For the following installation commands, if you are using ZSH as your shell, you might encounter the
> following error:
>>**zsh: no matches found: .[tutorials]**
> ℹ️ **TIP:** For the following installation commands, if you are using ZSH as your shell, you might encounter the
> following error:
>>**zsh: no matches found: .[tutorials]**
>
> To successfully run the below installation commands, put the single quote around the square brackets. For example:
> >pip install -e .'[tutorials]'
>
>
> For more information on this ZSH-related issue, see this [StackOverflow post](https://stackoverflow.com/a/68888466/11145086).
To install with the tutorials:
Expand All @@ -194,13 +196,13 @@ To install with the documentation:
To install and test using pytest:

>>> pip install -e .['testing']

# run tests
>>> python -m pytest

# run tests and show coverage report
>>> python -m pytest --cov=hypernetx

# Generate an HTML code coverage report and view it on a browser
>>> coverage html
>>> open htmlcov/index.html
Expand Down Expand Up @@ -230,5 +232,3 @@ License
-------

Released under the 3-Clause BSD license (see License.rst)


6 changes: 3 additions & 3 deletions build_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

rm -rf docs/build
rm -rf docs/source/classes
rm -rf docs/source/algorithms
rm -rf docs/source/drawing
rm -rf docs/source/algorithms
rm -rf docs/source/drawing
rm -rf docs/source/reports

sphinx-apidoc -o docs/source/classes hypernetx/classes
sphinx-apidoc -o docs/source/algorithms hypernetx/algorithms
sphinx-apidoc -o docs/source/drawing hypernetx/drawing
sphinx-apidoc -o docs/source/reports hypernetx/reports
sphinx-build -b html docs/source docs/build
sphinx-build -b html docs/source docs/build
Loading

0 comments on commit 771e556

Please sign in to comment.