Mentions légales du service

Skip to content

Python package

David Ham requested to merge python_package into master

Produce an installable Python Package with a library interface that enables other packages to use the algorithms presented here.

The following changes are introduced:

  • The main source files are moved into an hrevolve package and renamed to have conventional (lower case) and legal (no - and no initial digits) names.
  • Executable scripts for all of the algorithms are provided. In accordance with convention these do not have the .py extension.
  • Configuration parameters are now passed through arguments rather than stored in module global variables. This is required to enable the library interface.
  • The source code passes flake8 (this was a side effect of the work needed to do the previous item).
  • There are pytest tests corresponding to all of the tests in the paper.
  • A .gitignore file has been introduced to help avoid committing the wrong files.
  • setup.py, setup.cfg and pyproject.toml have been introduced to make the package installable.

To install the package directly from Gitlab, run:

$ pip install git+https://gitlab.inria.fr/adjoint-computation/H-Revolve.git@python_package

Once this MR lands, the @python_package will no longer be required. As a next step we can push the packages to PyPI at which point the following will work:

$ pip install hrevolve

When working on the package, it should be installed in editable mode by running the following command in the top folder of the repository:

$ pip install -e .

This causes the source files to be used directly so that changes can be tested without reinstalling.

The tests can be run using:

$ pip install pytest
$ python -m pytest
=========================================================================== test session starts ============================================================================
platform darwin -- Python 3.10.4, pytest-7.1.2, pluggy-1.0.0
rootdir: /Users/dham/src/firedrake/src/H-Revolve
plugins: xdist-2.5.0, forked-1.4.0, nbval-0.9.6, flake8-1.1.1, typeguard-2.13.3
collected 7 items                                                                                                                                                          

tests/test_hrevolve.py .......                                                                                                                                       [100%]

============================================================================ 7 passed in 0.04s =============================================================================

PEP8 compliance can be checked with:

$ pip install flake8
$ flake8

Successful execution will result in no output. Any output indicates PEP8 violations in the code.

Once the merge to master has occurred, we should set up INRIA's continuous integration to ensure that flake8 and pytest are run on all commits automatically.

Merge request reports