This project uses uv and task to manage this Python packaging and running all of its development tasks.
-
Install uv
Linux / macOS
curl -LsSf https://astral.sh/uv/install.sh | sh
brew
brew install uv
Windows
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
-
Install task
Linux / macOS
sh -c "$(curl -LsSf https://taskfile.dev/install.sh)" -- -d -b ~/.local/bin
brew
brew install go-task
Windows
You can use
Chocolatey
,Scoop
, orWinget
. Read more in the task installation guide.choco install go-task scoop install task winget install Task.Task
-
Build the Virtual Environment
task install
-
Activate the Virtual Environment
source .venv/bin/activate
Command Description | Command | Notes |
---|---|---|
Install Project | task install |
Installs the project and development dependencies |
Run Tests | task test |
Runs tests with pytest and coverage |
Run Formatting | task fmt |
Runs ruff code formatter |
Run Linting | task lint |
Runs ruff code linter |
Run Type Checking | task check |
Runs mypy static type checker |
Run Code Fixers | task fix |
Runs ruff to format and fix code |
Build the Artifacts | task build |
Build the Python Package Artifacts |
Build the Docker Image | task docker |
Build the Docker Image with the docker CLI |
Run a Command | task run |
Run a shell command: task run -- which python |
Run the pre-commit Hooks | task pre-commit |
Runs the pre-commit hooks |
To see all available commands, simply ask task
:
task --list
This project declares two PyPI repositories in the pyproject.toml
file:
[[tool.uv.index]]
name = "pypi"
url = "https://pypi.org/simple"
[[tool.uv.index]]
name = "python-packages"
url = "https://smarterdx-166979434163.d.codeartifact.us-east-1.amazonaws.com/pypi/python-packages/simple"
[tool.uv.sources]
snowflake-sdx = {index = "python-packages"}
By default uv
will use the first pypi
index, but you can specify the python-packages
index for internal packages
from AWS CodeArtifact. This allows for explicit declaration of internal packages and to use the faster,
cached, public PyPI repository for everything else. This also allows for the usage of
UV_INDEX_PYTHON_PACKAGES_PASSWORD
instead of UV_INDEX_URL
/ UV_EXTRA_INDEX_URL
.
This project uses a multi-stage Dockerfile to build the final image. The builder
stage
first installs the project dependencies, and then installs the project itself to optimize
for layer caching. The final image copies the virtual environment built in the builder
stage to the final image, ensuring that the final image is as small as possible.
The choice to use a virtual environment in the Docker image, rather than installing directly into the system Python come from recommendations in the uv documentation and a simplicity recommendation from this blog post.