A Cookiecutter template for OAK plugin modules.
See:
First, install the cruft package. Cruft enables keeping projects up-to-date with future updates made to this original template.
pip install cruft
Next, create a project using the oakx-plugin-cookiecutter template.
cruft create https://github.com/incatools/oakx-plugin-cookiecutter
This kickstarts an interactive session where you declare the following:
project_name: Name of the project. [defaults to: Project_X]project_description: Description of the project. [defaults to: This is the project description.].file_name: The name of the main python file. [defaults to:mainformain.py]greeting_recipient: Just a string that will be displayed when the boilerplate code is invoked. [defaults to:Worldas inHello, World!]author: The author of the project. [defaults to: Harshad Hegde hhegde@lbl.gov]⚠️ github_token_for_doc_deployment: The github token variable name for document deployment usingSphinx. [defaults to:GH_TOKEN]⚠️ github_token_for_pypi_deployment: The github token variable name which aligns with your autogenerated PyPI token for making releases. [defaults to:PYPI_TOKEN]
⚠️ Do NOT enter actual token here, this is just the variable name that holds the token value in the project repository's Secrets.
This will generate the project folder abiding by the template configuration specified by oakx-plugin-cookiecutter in the cookiecutter.json file.
The following files and directories are autogenerated in the project:
- Github wokflows:
- For code quality checks (
qc.yml) - Documentation deployment (
deploy-docs.yml) - PyPI deployment (
pypi-publish.yml)
- For code quality checks (
docsdirectory withSphinxconfiguration files and anindex.rstfile.srcdirectory structure with theproject_namedirectory within it.- Within the
project_namedirectory, there are 2 python files:main_file.pycli.pyforclickcommands.
- Within the
testsdirectory with a very basic test.poetrycompatiblepyproject.tomlfile containing minimal package requirements.tox.inifile containing configuration for:coverage-cleanlintflake8mypydocstr-coveragepytest
README.mdfile containingproject_descriptionvalue entered during setup.
Install poetry if you haven't already. Also poetry-dynamic-versioning for obvious reasons.
pip install poetry poetry-dynamic-versioning
poetry install
poetry run tox
This should run all the bullets mentioned above under the tox configuration and ideally you should see the following at the end of the run:
coverage-clean: commands succeeded
lint: commands succeeded
flake8: commands succeeded
mypy: commands succeeded
docstr-coverage: commands succeeded
py: commands succeeded
congratulations :)
And as the last line says: congratulations :)!! Your project is ready to evolve!
On the command line, type the project_name. In this example, ABCD:
ABCD run
Should return Hello, **greeting_recipient value chosen during setup**
In order to be up-to-date with the template, first check if there is a mismatch between the project's boilerplate code and the template by running:
cruft check
This indicates if there is a difference between the current project's boilerplate code and the latest version of the project template. If the project is up-to-date with the template:
SUCCESS: Good work! Project's cruft is up to date and as clean as possible :).
Otherwise, it will indicate that the project's boilerplate code is not up-to-date by the following:
FAILURE: Project's cruft is out of date! Run `cruft update` to clean this mess up.
For viewing the difference, run cruft diff. This shows the difference between the project's boilerplate code and the template's latest version.
After running cruft update, the project's boilerplate code will be updated to the latest version of the template.