make_midoss_forcing Package Development

Licensed under the Apache License, Version 2.0 Python Version Git on GitHub The uncompromising Python code formatter Documentation Status Sphinx linkcheck Issue Tracker

The Make-MIDOSS-Forcing package (make_midoss_forcing) is Make Salish Sea HDF5 Forcing Files for MIDOSS Runs

Python Versions

Python Version

The make_midoss_forcing package is developed and tested using Python 3.9. It is intended to work in environments using Python>=3.8. The package uses some Python language features that are not available in versions prior to 3.6, in particular:

Getting the Code

Git on GitHub

Clone the code and documentation repository from GitHub with:

$ git clone git@github.com:MIDOSS/Make-MIDOSS-Forcing.git

Development Environment

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

$ cd Make-MIDOSS-Forcing
$ conda env create -f envs/environment-dev.yaml
$ conda activate make-midoss-forcing
(make-midoss-forcing)$ python3 -m pip install --editable .

The --editable option in the pip install command above installs the package from the cloned repo via symlinks so that the installed package will be automatically updated as the repo evolves.

To deactivate the environment use:

(make-midoss-forcing)$ conda deactivate

Coding Style

The uncompromising Python code formatter

The Make-MIDOSS-Forcing 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 Make-MIDOSS-Forcing
$ conda activate make_midoss_forcing
(make-midoss-forcing)$ black ./

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

reformatted /media/doug/warehouse/MIDOSS/Make-MIDOSS-Forcing/make_midoss_forcing/forcing_paths.py
All done! ✨ 🍰 ✨
1 file reformatted, 6 files left unchanged.

Building the Documentation

Documentation Status

The documentation for the Make-MIDOSS-Forcing package is written in reStructuredText and converted to HTML using Sphinx.

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://make-midoss-forcing.readthedocs.io/en/latest/.

Additions, improvements, and corrections to these docs are always welcome.

The quickest way to fix typos, etc. on existing pages is to use the Edit on GitHub link in the upper right corner of the page to get to the online editor for the page on GitHub.

For more substantial work, and to add new pages, follow the instructions in the Development Environment section above. In the development environment you can build the docs locally instead of having to push commits to GitHub to trigger a build on readthedocs.org and wait for it to complete. Below are instructions that explain how to:

  • build the docs with your changes, and preview them in Firefox

  • check the docs for broken links

Building and Previewing the Documentation

Building the documentation is driven by the docs/Makefile. With your make-midoss-forcing environment activated, use:

(make-midoss-forcing)$ (cd docs && make clean html)

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

Running Sphinx v2.2.1
making output directory... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 2 source files that are out of date
updating environment: [new config] 2 added, 0 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... [100%] pkg_development
generating indices...  genindexdone
writing additional pages...
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 _build/html.

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 Bitbucket the documentation is automatically re-built and rendered at https://make-midoss-forcing.readthedocs.io/en/latest/.

Running the Unit Tests

The test suite for the Make-MIDOSS-Forcing package is in Make-MIDOSS-Forcing/tests/. The pytest tool is used for test parametrization and as the test runner for the suite.

With your make-midoss-forcing development environment activated, use:

(make-midoss-forcing)$ cd Make-MIDOSS-Forcing/
(make-midoss-forcing)$ py.test

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

**add example pytest output**

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

(make-midoss-forcing)$ cd Make-MIDOSS-Forcing/
(make-midoss-forcing)$ pytest --cov=./

The test coverage report will be displayed below the test suite run output.

Alternatively, you can use

(make-midoss-forcing)$ pytest --cov=./ --cov-report html

to produce an HTML report that you can view in your browser by opening Make-MIDOSS-Forcing/htmlcov/index.html.

Version Control Repository

Git on GitHub

The Make-MIDOSS-Forcing package code and documentation source files are available as a Git repository at https://github.com/MIDOSS/Make-MIDOSS-Forcing.

Issue Tracker

Issue Tracker

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

License

Licensed under the Apache License, Version 2.0

The code and documentation of the Make MIDOSS Forcing project are copyright 2019-2021 the MIDOSS project contributors, The University of British Columbia, and Dalhousie University.

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.