This repository is a fork of the MLOps Zoomcamp course by DataTalks.Club, designed to teach MLOps principles and provide weekly homework assignments for each lecture.
- os: Ubuntu(wsl)
- python 3.10 ^
- poetry
Using Poetry for Python Package and Dependency Management
-
Install Poetry if not yet installed.
-
Navigate to your project directory:
cd <PROJECT_DIR>
-
Initialize your project:
poetry init -n
- This command interactively creates a
pyproject.toml
file in your project directory.
- This command interactively creates a
-
Add dependencies:
-
Specify them in the
tool.poetry.dependencies
section ofpyproject.toml
:[tool.poetry.dependencies] numpy = "^1.19"
-
Use a mapping of package names and version constraints.
-
-
Use the
add
command to add dependencies:poetry add numpy
- It finds a suitable version constraint and installs the package along with sub-dependencies.
NOTE: If you already have
pyproject.toml
, you can use theinstall
command to read the file, resolve dependencies, and install them.poetry install
-
To update to the latest compatible version:
poetry update package
-
To upgrade to the latest available version:
poetry add package@latest
$ poetry add pandas numpy
# or
$ poetry add $(cat requirements.txt)
The remove
command removes required packages to your `pyproject.toml`` and installs them.
poetry remove numpy
To integrate Poetry with Jupyter Notebook and manage Python packages effectively, consider using poetry-kernel. Follow the steps below, and choose the method that suits your workflow.
When running Jupyter Notebook, you can choose another kernel from Python environments
.
Use a kernel from the Python environment managed by Poetry
Select the kernel named "<kernel_name>"
Create and use a new kernel managed by Poetry:
# Create a new kernel named "<kernel_name>"
$ poetry run python -m ipykernel install --user --name=<kernel_name>
Start Jupyter Notebook server and connect using the provided URL:
# Run Jupyter Notebook server
$ poetry run jupyter notebook
Special thanks to DataTalks.Club for providing the MLOps Zoomcamp course, which forms the foundation of this repository.
Additional thanks to ChatGPT for assisting in composing, improving, and developing the content of this repository.