The code is currently in a pre-release status. There is enough functionality to demonstrate the direction of the project, but the software is currently missing functionality that would provide a robust security model for deployment within an enterprise.
The project documentation is available at https://pages.nist.gov/dioptra/.
For instructions on how to build and run a fresh instance of Dioptra, see cookiecutter-templates/cookiecutter-dioptra-deployment/README.md and the Building the containers and Running Dioptra sections of the published documentation.
Developers must use Python 3.9 and create a virtual environment using one of the requirements.txt files in the requirements/ directory in order to make contributions to this project.
Ensure that you have Python 3.9 installed and that it is available in your PATH, and then identify the requirements file that you want to use:
| Filename | OS | Architecture | Tensorflow | PyTorch |
|---|---|---|---|---|
| linux-x86_64-py3.9-requirements-dev.txt | Linux | x86-64 | ❌ | ❌ |
| linux-x86_64-py3.9-requirements-dev-tensorflow.txt | Linux | x86-64 | ✅ | ❌ |
| linux-x86_64-py3.9-requirements-dev-pytorch.txt | Linux | x86-64 | ❌ | ✅ |
| linux-aarch64-py3.9-requirements-dev.txt | Linux | arm64 | ❌ | ❌ |
| linux-aarch64-py3.9-requirements-dev-tensorflow.txt† | Linux | arm64 | ❌ | ❌ |
| linux-aarch64-py3.9-requirements-dev-pytorch.txt | Linux | arm64 | ❌ | ✅ |
| macos-x86_64-py3.9-requirements-dev.txt | MacOS | x86-64 | ❌ | ❌ |
| macos-x86_64-py3.9-requirements-dev-tensorflow.txt | MacOS | x86-64 | ✅ | ❌ |
| macos-x86_64-py3.9-requirements-dev-pytorch.txt | MacOS | x86-64 | ❌ | ✅ |
| macos-arm64-py3.9-requirements-dev.txt | MacOS | arm64 | ❌ | ❌ |
| macos-arm64-py3.9-requirements-dev-tensorflow.txt | MacOS | arm64 | ✅ | ❌ |
| macos-arm64-py3.9-requirements-dev-pytorch.txt | MacOS | arm64 | ❌ | ✅ |
| win-x86_64-py3.9-requirements-dev.txt | Windows | x86-64 | ❌ | ❌ |
| win-x86_64-py3.9-requirements-dev-tensorflow.txt | Windows | x86-64 | ✅ | ❌ |
| win-x86_64-py3.9-requirements-dev-pytorch.txt | Windows | x86-64 | ❌ | ✅ |
†: This file is a placeholder. Tensorflow is currently pinned to 2.9.1, which is only available for the x86-64 architecture on Linux.
Next, use the venv module to create a new virtual environment:
python -m venv .venvActivate the virtual environment after creating it. To activate it on MacOS/Linux:
source .venv/bin/activateTo activate it on Windows:
.venv\Scripts\activateNext, upgrade pip and install pip-tools:
python -m pip install --upgrade pip pip-toolsFinally, use pip-sync to install the dependencies in your chosen requirements file and install dioptra in development mode.
On MacOS/Linux:
# Replace "linux-x86_64-py3.9-requirements-dev.txt" with your chosen file
pip-sync requirements/linux-x86_64-py3.9-requirements-dev.txtOn Windows:
# Replace "win-x86_64-py3.9-requirements-dev.txt" with your chosen file
pip-sync requirements\win-x86_64-py3.9-requirements-dev.txtIf the requirements file you used is updated, or if you want to switch to another requirements file (you need access to the Tensorflow library, for example), just run pip-sync again using the appropriate filename.
It will install, upgrade, and uninstall all packages accordingly and ensure that you have a consistent environment.
For instructions on how to prepare the frontend development environment, see the src/frontend/README.md file
This project uses Sphinx to generate the documentation published at https://pages.nist.gov/dioptra. To build the documentation locally, activate your virtual environment if you haven't already and run:
python -m tox run -e web-compile,docsAlternatively, you can also use make to do this:
make docsThis project uses black and isort to automatically format Python code:
Developers are expected to run black and isort over their contributions before opening a Pull Request.
To do this, activate your virtual environment if you haven't already and run:
# Run black to reformat code
python -m tox run -e black -- src/dioptra task-plugins/dioptra_builtins tests
# Run isort to reformat import statements
python -m tox run -e isort -- src/dioptra task-plugins/dioptra_builtins testsAlternatively, you can also use make to do this:
make beautifyThis project uses flake8 as a code linter and mypy to perform static type checking.
Developers are expected to run flake8 and mypy and resolve all issues before opening a Pull Request.
To do this, activate your virtual environment if you haven't already and run:
# Lint the code
python -m tox run -e flake8
# Perform static type checking
python -m tox run -e mypyAlternatively, you can also use make to do this:
make code-checkThis project has a commit style guide that is enforced using the gitlint tool.
Developers are expected to run gitlint and validate their commit message before opening a Pull Request.
After commiting your contribution, activate your virtual environment if you haven't already and run:
python -m tox run -e gitlintAlternatively, you can also use make to do this:
make commit-checkThis project stores its unit tests in the tests/ folder and runs them using pytest.
Developers are expected to create new unit tests to validate any new features or behavior that they contribute and to verify that all unit tests pass before opening a Pull Request.
To run the unit tests, activate your virtual environment if you haven't already and run:
python -m tox run -e py39-pytest -- tests/unit
python -m tox run -e py39-cookiecutterAlternatively, you can also use make to do this:
make tests-unitRun the following to clear away the project's temporary files, which includes the sentinel dotfiles that are created in build/ when using make:
make cleanThis Software (Dioptra) is being made available as a public service by the National Institute of Standards and Technology (NIST), an Agency of the United States Department of Commerce. This software was developed in part by employees of NIST and in part by NIST contractors. Copyright in portions of this software that were developed by NIST contractors has been licensed or assigned to NIST. Pursuant to Title 17 United States Code Section 105, works of NIST employees are not subject to copyright protection in the United States. However, NIST may hold international copyright in software created by its employees and domestic copyright (or licensing rights) in portions of software that were assigned or licensed to NIST. To the extent that NIST holds copyright in this software, it is being made available under the Creative Commons Attribution 4.0 International license (CC BY 4.0). The disclaimers of the CC BY 4.0 license apply to all parts of the software developed or licensed by NIST.
