Skip to content

Commit 78ccd0e

Browse files
committed
usage of pip-tools for packages dependencies
1 parent 5b7678e commit 78ccd0e

File tree

4 files changed

+808
-13
lines changed

4 files changed

+808
-13
lines changed

README.md

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,38 @@ All project relevant configuration values, including model hyperparameter ranges
4343
For versioning tasks, [_git_](https://git-scm.com/) and [_dvc_](https://dvc.org/doc/use-cases/versioning-data-and-models), handled with ignore files content, are chosen. If a remote storage, like AWS S3 or Azure shall be used as future task, dvc[all] for the selected dvc version is installed via requirements.txt file as well for specific configuration. By now, only dvc 'local' remote is set.
4444

4545

46-
## Environment Set up
46+
## Environment Set Up
4747
* Working in a command line environment is recommended for ease of use with git and dvc. Working on Windows, [WSL2 and Ubuntu (Linux)](https://ubuntu.com/tutorials/install-ubuntu-on-wsl2-on-windows-11-with-gui-support#1-overview) is chosen for this project implementation.
48-
* We expect you have at least Python 3.10.9 installed (e.g. via conda), furthermore having forked this project repo locally and activate it in your virtual environment to work on for your own. So, in your root directory `path/to/census-project` create a new virtual environment depending on the selected OS and use the supplied _requirements.txt_ file to install the needed libraries e.g. via
49-
50-
```
51-
pip install -r requirements/requirements.txt
52-
```
53-
or use
54-
55-
```
56-
conda create -n [envname] "python=3.10.9" scikit-learn pandas numpy pytest jupyter jupyterlab fastapi uvicorn ... <the-needed-library-list> -c conda-forge
57-
```
48+
* We expect you have at least Python 3.11.13 installed, furthermore having forked this project repo locally and activate it in your virtual environment to work on for your own. So, in your root directory `path/to/census-project` create a new virtual environment depending on the selected OS and use the supplied _requirements.txt_ file to install the needed libraries via the following process:
49+
50+
### User Process
51+
This project uses Conda for environment management and pip-tools for dependency locking.
52+
53+
1. **Create and activate the Conda environment:**
54+
```bash
55+
conda create --name my-project-env python=3.11.13
56+
conda activate my-project-env
57+
```
58+
59+
2. **Install dependencies:**
60+
Use the locked requirements file for a reproducible installation.
61+
```bash
62+
pip install -r requirements.txt
63+
```
64+
65+
### Developer Workflow
66+
If updates are needed, put them in the top-level <i>requirements.in</i> file. There the directly needed packages are listed. <i>pip-compile</i> resolves the search of necessary dependencies together with the <i>pyproject.toml</i> file and creates the final <i>requirements.txt</i> file.
67+
68+
1. Add or modify a package in `requirements.in`.
69+
2. Regenerate the lock file:
70+
```bash
71+
pip-compile requirements.in
72+
```
73+
3. Install the new packages:
74+
```bash
75+
pip install -r requirements.txt
76+
```
77+
4. Commit **both** `requirements.in` and `requirements.txt` to Git.
5878

5979

6080
## Project Structure
@@ -130,11 +150,11 @@ There in "__main__" it calls
130150
```
131151
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)
132152
```
133-
153+
134154
Remember, this code is for development purpose, in production the reload option shall be set to False resp. not used. In other words, the start command e.g. on our render deployment web service (see below) is:<br>
135155
uvicorn src.main:app --host 0.0.0.0 --port 8000
136156

137-
* So, locally we start our implemented browser web application with
157+
* So, locally we start our implemented browser web application from project root with
138158

139159
```
140160
http://127.0.0.1:8000/docs

pyproject.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# pyproject.toml
2+
[build-system]
3+
# These are packages required to build the project and pip uses it
4+
# as a strong hint for what to use in isolated build environments
5+
# for dependencies.
6+
requires = [
7+
"setuptools>=64.0.0", # A version well past the Python 3.12 compatibility fixes
8+
"wheel"
9+
]
10+
build-backend = "setuptools.build_meta"

requirements.in

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Top-level dependencies for the project.
2+
# Run `pip-compile` to generate the locked requirements.txt file.
3+
4+
# Core Application
5+
fastapi==0.115.3
6+
uvicorn
7+
gunicorn
8+
9+
# Data Science
10+
numpy==1.25.0
11+
pandas==2.0.3
12+
ydata-profiling
13+
scikit-learn==1.3.0
14+
xgboost==1.7.6
15+
16+
# Tooling
17+
dvc[all]
18+
flake8
19+
pytest
20+
pytest-html
21+
22+
# Utilities
23+
requests
24+
25+
# Security Pins - keep these strictly pinned
26+
pillow>=10.3.0
27+
setuptools>=78.1.1
28+
fonttools>=4.43.0
29+
zipp>=3.19.1

0 commit comments

Comments
 (0)