You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a template repository dedicated to ML projects in python. It provides some basic tools and configs necessary to kickstart the development.
12
+
Are you tired of dealing with messy code, debugging errors, and fixing bugs that could have been prevented with proper tools and practices? Do you want to improve the overall quality of your projects while saving time in the long run? Then this template is perfect for you!
13
+
14
+
This is a template repository dedicated to ML projects in `Python`. It provides some basic tools and configs necessary to kickstart the development. It includes linting, type checking, package management, testing and CI.
15
+
16
+
## Prerequisites
17
+
18
+
In order to use this template, you need to have both `poetry` and `make` installed.
19
+
20
+
### Poetry
21
+
22
+
`poetry` is a package manager we're using. You can check the installation instructions [here](https://python-poetry.org/docs/#installing-with-the-official-installer). You should avoid installing `poetry` through `pip` as it is a system-level tool, separated from the `Python` runtime you're currently using. It enables us to treat `Python` as any other dependency and pin its version in `pyproject.toml`.
`make` is a utility tool that enables us to create aliases for commands we type in the console to run programs. It's much more efficient to use `make` so you don't have to memorize console commands. You can also expose your project's CLI via `Makefile`.
31
+
32
+
`make` should be available on most Linux distributions.
33
+
34
+
If you're using Windows, I would get [choco](https://chocolatey.org/install) first, then get `make` from `choco` package gallery.
35
+
36
+
```sh
37
+
choco install make
38
+
```
39
+
40
+
Mac users can pull it using `Homebrew`.
41
+
42
+
```sh
43
+
brew install make
44
+
```
45
+
46
+
## Getting started
47
+
48
+
To start your work, you need to set up your local environment and hooks.
49
+
50
+
```sh
51
+
make install_dev
52
+
```
53
+
54
+
Later you will define aliases for your CLI here. `Makefile` already contains calls to build tools and checks. Use `build` to run them all.
-`Makefile` - tasks definitions, much simpler to call `make` than writing whole commands in the terminal; it's also easy to check what project-specific functialities you're exposing
25
-
-`mypy.ini` - `mypy` config, usually some of your dependencies won't be hinted so you gonna ignore them here
86
+
-`mypy.ini` - `mypy` config, usually some of your dependencies won't be hinted so you're gonna ignore them here
26
87
-`poetry.lock` - compiled dependencies
27
88
-`poetry.toml` - `poetry` config, as you shouldn't enforce other devs where to put their virtual environment this is must be a separate config file
28
89
-`pyproject.toml` - repo config
@@ -40,34 +101,6 @@ When developing a project there's a need to automate some tedious stuff that hel
40
101
-[mypy](https://github.com/python/mypy)
41
102
-[coverage](https://github.com/nedbat/coveragepy)
42
103
43
-
## [Makefile](Makefile)
44
-
45
-
To start your work, you need to set up your local environment and hooks.
46
-
47
-
```sh
48
-
make install_dev
49
-
```
50
-
51
-
You gonna put your CLI here later. It already contains calls to build tools and checks. Use `build` to run them all (`isort`, `black`, `pre_commit`, `flake8`, `mypy`, `test`).
52
-
53
-
```sh
54
-
make build
55
-
```
56
-
57
-
Please note that `build` does not encompass the coverage and dependencies updates. These need to be run separately. Coverage may not always be necessary and you're gonna be running `build` often while working locally. Updating dependencies should be approached with the utmost care, no reason to bump the versions all the time when code does the work it's intended for. Better use some automation tool like [dependabot](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file).
58
-
59
-
To quickly format your repo while coding run:
60
-
61
-
```sh
62
-
make format
63
-
```
64
-
65
-
Before you commit, always run a full check. It's much more faster to run it locally, than to wait for CI build.
- finally some linter to be sure [flake8](https://gitlab.com/pycqa/flake8)
82
115
83
-
Why are we using local environment to run pre-commit for us? This is rather unusual isn't it? Yes - it is. You want to use the same versions of libs (`flake8`, `black`) and have them specified in a single file. Otherwise you need to keep track of precommit dependencies as well. If you want truly separate environment for the pre-commit - use dependency groups in your package manager.
116
+
Why are we using the local environment to run pre-commit for us? This is rather unusual, isn't it? Yes - it is. You want to use the same versions of libs (`flake8`, `black`) and have them specified in a single file. Otherwise, you need to keep track of `pre-commit` dependencies as well. If you want a truly separate environment for the `pre-commit` - use dependency groups in your package manager.
84
117
85
118
## Closing remarks
86
119
87
-
Hopefully, this template helps you jump off your project. If any of these tools are unfamiliar to you, follow the links for more info on them. Feel free to customize it, this is a template after all. The point I often make while doing workshops is you being able to make your toolset. This is but an example. Personally, I often look up how my favourite libraries are developed and take what I like. Just try not to overdo it. Don't use tools which are not necessary in your project. The main idea is to spend time actually coding, soliving problems, not thinking about code quality whatsoever.
120
+
Hopefully, this template helps you jump off your project. If any of these tools are unfamiliar to you, follow the links for more info on them. Feel free to customize it, this is a template after all. The point I often make while doing workshops is you being able to make your toolset. This is but an example. I often look up how my favorite libraries are developed and take what I like. Just try not to overdo it. Don't use tools that are not necessary in for project. The main idea is to spend time actually coding, solving problems, and not thinking about code quality whatsoever.
0 commit comments