AtlantisCmd Package Development

Licensed under the Apache License, Version 2.0 Python Version Git on GitHub The uncompromising Python code formatter Documentation Status Sphinx linkcheck Pytest with Coverage Status Codecov Testing Coverage Report CodeQL analysis Issue Tracker

The AtlantisCmd package (atlantis_cmd) is a command-line tool for doing various operations associated with the Salish Sea Atlantis project version of the CSIRO Atlantis ecosystem model. AtlantisCmd is based on, and provides Atlantis-specific extensions for https://github.com/SalishSeaCast/NEMO-Cmd.

Python Versions

Python Version

The atlantis_cmd package is developed and tested using Python 3.10. The package uses some Python language features that are not available in versions prior to 3.8, in particular:

Getting the Code

Git on GitHub

Clone the code and documentation repository from GitHub with:

$ git clone git@github.com:SS-Atlantis/AtlantisCmd.git

or copy the URI (the stuff after git clone above) from the Code button on the repository page.

Note

The git clone command above assumes that your are connecting to GitHub using SSH. If it fails, please follow the instructions in our Secure Remote Access docs to set up your SSH keys and Copy Your Public ssh Key to GitHub.

Development Environment

The AtlantisCmd package depends on the NEMO-Cmd package, so you need to clone its repo, NEMO-Cmd, beside your clone of AtlantisCmd repository.

Setting up an isolated development environment using Conda is recommended. Assuming that you have Miniconda3 installed, you can create and activate an environment called atlantis-cmd that will have all of the Python packages necessary for development, testing, and building the documentation with the commands below.

$ cd AtlantisCmd
$ conda env create -f env/environment-dev.yaml
$ conda activate atlantis-cmd
(atlantis-cmd)$ pip install --editable ../NEMO-Cmd
(atlantis-cmd)$ pip install --editable .

The --editable option in the pip install commands above install the packages from the cloned repos via symlinks so that the installed packages will be automatically updated as their repos evolves.

To deactivate the environment use:

(atlantis-cmd)$ conda deactivate

Coding Style

The uncompromising Python code formatter

The AtlantisCmd package uses the black code formatting tool to maintain a coding style that is very close to PEP 8.

black is installed as part of the Development Environment setup.

To run black on the entire code-base use:

$ cd AtlantisCmd
$ conda activate atlantis_cmd
(atlantis-cmd)$ black ./

in the repository root directory. The output looks something like:

**add example black output**

Building the Documentation

Documentation Status

The documentation for the AtlantisCmd package is written in reStructuredText and converted to HTML using Sphinx. Creating a Development Environment as described above includes the installation of Sphinx. Building the documentation is driven by the docs/Makefile. With your salishsea-nowcast development environment activated, use:

(atlantis-cmd)$ (cd docs && make clean html)

to do a clean build of the documentation. The output looks something like:

Running Sphinx v4.1.1
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 1 source files that are out of date
updating environment: 0 added, 1 changed, 0 removed
reading sources... [100%] pkg_development
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [ 50%] index
writing output... [100%] pkg_development
generating indices... genindex done
writing additional pages... search done
copying static files... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded.

The HTML pages are in docs/_build.

The HTML rendering of the docs ends up in docs/_build/html/. You can open the index.html file in that directory tree in your browser to preview the results of the build.

If you have write access to the repository on GitHub, whenever you push changes to GitHub the documentation is automatically re-built and rendered at https://atlantiscmd.readthedocs.io/en/latest/.

Running the Unit Tests

The test suite for the AtlantisCmd package is in AtlantisCmd/tests/. The pytest tool is used for test parametrization and as the test runner for the suite.

With your atlantis-cmd development environment activated, use:

(atlantis-cmd)$ cd AtlantisCmd/
(atlantis-cmd)$ pytest

to run the test suite. The output looks something like:

================================ test session starts =================================
platform linux -- Python 3.9.6, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
Using --randomly-seed=3861485000
rootdir: /media/doug/warehouse/Atlantis/AtlantisCmd
plugins: randomly-3.8.0, cov-2.12.1
collected 1 item

tests/test_run.py .                                                                                                                                                                                                                                                                                            [100%]

================================= 1 passed in 0.17s ==================================

You can monitor what lines of code the test suite exercises using the coverage.py and pytest-cov tools with the command:

(atlantis-cmd)$ cd AtlantisCmd/
(atlantis-cmd)$ pytest --cov=./

and generate a test coverage report with:

(atlantis-cmd)$ coverage report

to produce a plain text report, or

(atlantis-cmd)$ coverage html

to produce an HTML report that you can view in your browser by opening AtlantisCmd/htmlcov/index.html.

Continuous Integration

Pytest with Coverage Status Codecov Testing Coverage Report

The AtlantisCmd package unit test suite is run and a coverage report is generated whenever changes are pushed to GitHub. The results are visible on the repo actions page, from the green checkmarks beside commits on the repo commits page, or from the green checkmark to the left of the “Latest commit” message on the repo code overview page . The testing coverage report is uploaded to codecov.io

The GitHub Actions workflow configuration that defines the continuous integration tasks is in the .github/workflows/pytest-coverage.yaml file.

Version Control Repository

Git on GitHub

The AtlantisCmd package code and documentation source files are available as a Git repository at https://github.com/SS-Atlantis/AtlantisCmd.

Issue Tracker

Issue Tracker

Development tasks, bug reports, and enhancement ideas are recorded and managed in the issue tracker at https://github.com/SS-Atlantis/AtlantisCmd/issues.

License

Licensed under the Apache License, Version 2.0

The code and documentation of the Atlantis Command Processor project are copyright 2021 – present by the Salish Sea Atlantis project contributors, The University of British Columbia, and CSIRO.

They are licensed under the Apache License, Version 2.0. https://www.apache.org/licenses/LICENSE-2.0 Please see the LICENSE file for details of the license.