Skip to content

3. How to commit and contribute to the MLOps Project

Maike Rodrigo edited this page Feb 15, 2022 · 10 revisions

This session explains the flow of committing to this project. Before making any contributions, consider reading through this document.

Pre-commit - what it is and how does it work

The MLOps project uses pre-commit, "a framework for managing and maintaining multi-language pre-commit hooks." As the definition suggests, the pre-commit uses Git hooks scripts to automatically check code formatting and possible issues.

The Git hooks point out inconsistencies in your code (such as missing punctuation and unnecessary whitespaces) and also debug statements and standardize code style.

All these checks will be performed before committing the changes and if all the hooks/conditions pass, your code will be committed.

You can see all the configured hooks for this project in the root directory on the .pre-commit-config.yaml file.

How to use pre-commit

Once you commit any modifications made on your local branch, the pre-commit tool will run on your changes

If you wish to manually check if your modification will pass this stage, run:

pre-commit run --all-files

With this command, all your files and commit message will be checked based on the configured hooks. Depending on your modification some checks will be skipped.

The status of the pre-commit run will be at the right of the task and there are three possible status messages:

  • 🔵 The 'Skipped' message in blue indicates that the files in which these hooks apply were not modified, so there is nothing to check.

  • 🟢 The 'Passed' message in green, as the name suggests, indicated that the hook passed for that file

  • 🔴 The 'Failed' message, in red, indicates, as expected, that the hook failed. To understand what happened, check the leftmost part of the screen where the hook name can be found. Below its name, the hook id will be displayed and its description can be found on the .yaml file on the root of this repository.

Below, an example of a real attempt to commit some changes:

Here, a modification on the README.md file was made and a long, detailed commit message was written.

In the example above, the commit message was too long, so a new commit message needed to be created, in accordance with the commit hooks. After failing on this step, all further checks were interrupted, the hook name was displayed in the right (Conventional Commits for MlOps) and its id was displayed right below it (ccmlops).

Checking the yaml file, we can find all the information on the hook with the ccmlops id, especially under the 'description' section, to understand what this hook is checking.

In this case, further details of this hook are in the conventional_commits_for_mlops.py file, but for other hooks, you can find the information under each 'description'.

Once you fix any possible mistakes and run the pre-commit command again, your terminal screen should look like this:

How to contribute

After forking, cloning, and installing the requirements, you can start contributing to this project!

If you wish, follow the contribution example to get further details on the process!

‼️ Remember to write good commit messages and to check the hooks used by the pre-commit tool