This is a Cookiecutter template for deep-learning Python projects. It has all the necessary tools for development, testing, and deployment:
- Poetry for dependency management
- CI/CD with GitHub Actions
- Pre-commit hooks with pre-commit
- Code quality with ruff, mypy or pyright, deptry and prettier
- Publishing to PyPI or Artifactory by creating a new release on GitHub
- Testing and coverage with pytest and codecov
- Documentation with MkDocs
- Compatibility testing for multiple versions of Python with Tox
- Containerization with Docker
- Development environment with VSCode devcontainers
The generated projects with this template will have the following architecture:
project_name
├── configs # Configuration files for experiments
├── data # Data for training and testing
├── docs # Documentation files
├── notebooks # Jupyter notebooks
├── tests # Unit tests for the project
├── weights # Trained models
├── project_slug (src) # Code for the project
├── base
├── data # Data processing and loading
├── logger # Logging
├── model # Model definition, metrics, and losses
├── trainer # Trainer class
├── utils # Utility functions
├── visualization # Visualization functions
├── test.py
├── train.py
├── Makefile
├── README.md
Files for version control, documentation, and CI/CD are not shown in the tree above.
On your local machine, install cookiecutter and directly pass the URL to this
Github repository to the cookiecutter command:
pip install cookiecutter
cookiecutter https://github.com/icn2-ai/cookiecutter-poetry-deep-learning.gitIf you have not installed poetry, follow the instructions here.
Create a repository on GitHub, and then run the following commands, replacing <project-name>, with the name that you gave the Github repository and
<github_author_handle> with your Github username.
cd <project_name>
git init -b main
git add .
git commit -m "Init commit"
git remote add origin [email protected]:<github_author_handle>/<project_name>.git
git push -u origin mainInstall the environment and the pre-commit hooks with:
make installThen, before making the push to the remote repository, run the pre-commit hooks with:
make checkIt might give an error the first time you run it, but mypy and ruff will correct the code style and type hints. You can run the pre-commit hooks again to check if everything is correct.
After that, you can do the push.
You are now ready to start development on your project! The CI/CD pipeline will be triggered when you open a pull request, merge to main, or when you create a new release.
This project is based on Florian Maas' repository, cookiecutter-poetry, for the development of Python projects with Poetry, including CI/CD and code quality tools. The generated projects' architecture is inspired by Victor Huang's template fo deep-learning projects, pytorch-template.