Skip to content

valentingol/my_ml_template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Personal ML template

Release PythonVersion PytorchVersion License

GitHub Release Date GitHub last commit GitHub User followers GitHub User's User stars

Torch_logo Wandb_logo

Ruff_logo Black_logo

Ruff Flake8 Pydocstyle MyPy PyLint

Tests Coverage Bandit

Disclaimer: Even if it is a personal project, everybody can use it freely and modify it for their own needs.

This repository is a template for using in ML projects. It includes:

  • Inference and training template scripts
  • ⚙️ YAECS as configuration manager (compatible with WandB, ClearML, ...)
  • pytest-cov to check unit tests and get coverage (including an optional minimum coverage to pass)
  • 🎨 ruff to check the style and auto-format it, including:
    • pycodestyle and flake to check overall Python scripts style (PEP8)
    • isort to check the import order of Python scripts
    • pydocstyle to check Python docstrings style (Numpy convention)
  • 🎨 pylint to have an overall grade of the style (including an optional minimum grade to pass)
  • 🎨 black to auto-format Python scripts
  • 🏷️ mypy to check typing and type hints

Some GitHub actions 🏭 are provided:

  • 🔒 bandit for security
  • 🎨 flake8, mypy, pydocstyle, pylint, ruff for style
  • Cache is preserved between GH action runs (useful for heavy requirements packages)

And finally, some badges:

  • 🆙 Release, last commit and release date
  • 🧑‍🤝‍🧑 Github stats
  • 📑 licenses
  • 🔖 python version (and pytorch version)
  • Pytorch and Wandb badges
  • And more...

All workflows create a badge available, for instance, in README.

This repository provides also a pre-commit configuration to check end-of-file, trailing whitespace, flake8 and pydocstyle (numpy).

alt text

HowTo

All feature of this template is easy to adapt on your project by changing names or versions on the .github/workflows/ directory and on the badge paths on your markdown/rst files. All the worflows are independent and can be used individually. You can also remove any workflow you don't need.

Before all, you need to create a gist The id of the gist is required for pylint and test/coverage badges. Then, you must add a secret in your repository (Settings > Secrets > New repository secret) that is a personal token with gist scope with name GIST_SECRET (details here).

Notes

By default, there is no maximum unit test coverage but you can set the minimum coverage you want in utils/github_actions/pytest_manager.py. There is also a minimum grade for pylint that is 7.0/10 and can be set in utils/github_actions/pylint_manager.py. Details of pylint options are in .pylintrc and can also be changed at will.

Contributing

Even if it is a personal template, feel free to contribute via issues or pull requests 🤗.

See CONTRIBUTING.md for more details.