This repository templates the development of a new python method for the Statistical Method Library
This template is an example repository for a new Python implementation of a method targeted for the Statistical Method Library. You should use the template to produce the basic repository structure and tooling useful for developing a method in Python.
- Click on the "Use this template" button available on the top right of this page.
- Provide a name for your new repository, follow the naming convention sml-<method_name>- e.g sml-totals-and-components-python, sml-totals-and-components-pyspark or sml-totals-and-components-r.
- Click the "Create repository from template" button.
You now have a copy of the template repository and can clone this to your local machine to begin development.
git clone https://github.com/ONSdigital/your-new-method-repository.git
cd your-new-method-repository
This repository uses poetry for python package and dependency management. To install use the poetry installation documentation for guidance
Use poetry to install and create a virtual environment, from the root directory of your repository run:
poetry install
Ensure you are in the associated virtual environment:
poetry shell
You can run the template code using:
poetry run python method_name/method_name.py
Unit tests can be run using pytest.
cd tests
pytest
This repository includes an example CICD flow using github actions that will run code quality tooling (flake8, black, isort and bandit)
This repository includes an example release and packaging CICD flow using github actions that will create a github release, producing a .whl file and zip of the source code.
To trigger this flow add a tag in the format of a semantic version to the commit that you want to package and release:
-
Update the docs/release-notes markdown is updated to reflect the latest change
-
Determine the next sematic version
- 1.0.0 should be the first official release, once all testing and documentation has been executed and approved
- x.y.z
- increment z (patch release) for backward compatible bug fix
- increment y (minor release) for backward compatible enhancements (e.g new method introduced). z (patch release) is reset to 0
- increment x (major release) for non-backward compatible changes (e.g method name change / interface change). y (minor release) and z (patch release) are reset to 0.
-
Update pyproject.toml to reflect the next semantic version
-
Tag the release
- git checkout main
- git tag semantic version
- git push origin semantic version
-
Github Action will be triggered and release assets should be made available under the Releases tab in Github
See the LICENSE file for further information