This repository holds a base for Python based projects.
To create a project from this base, clone the project and then set the upstream Github to a new repository.
This skeleton uses UV as a Python package and environment manager.
Run uv sync to initialise the uv project in your environment.
This repository has basic (and opinionated) pre-commit checks for linting and formatting.
The pre-commit rules and configuration can be found in .pre-commit-config.yml.
Run uv run pre-commit install.
IMPORTANT: Note that Ruff is ran in pre-commit with
--fixargument which can change files
Basic Ruff settings can be found in settings.toml. Mostly default settings are used with the exception of line-width which is set to 120.
Type checking is performed with MyPy and performed after linting during pre-commit.
Ensure any packages added are also represented in the additional-dependencies in .pre-commit-config.yml.
Below are some example commands for installing some of the more common packages with UV package manager. Adjust the commands as necessary.
Recommended environment packages:
uv add python-dotenv httpx mypy
FastAPI:
uv add fastapi --extra standard
Jupyter notebooks (especially for integrated VS Code notebooks):
uv add --dev jupyter ipykernel ipython notebook tqdm
Common data packages:
uv add pandas numpy scikit-learn matplotlib seaborn
HuggingFace packages:
uv add datasets[torch] huggingface-hub transformers[torch]
For PyTorch and related packages depending on the CUDA version on your device, compatible PyTorch package, and device platform, add the following to the pyproject.toml:
[tool.uv.sources]
torch = [
{ index = "pytorch-cu126", marker = "sys_platform == 'linux' or sys_platform == 'win32'" },
]
torchvision = [
{ index = "pytorch-cu126", marker = "sys_platform == 'linux' or sys_platform == 'win32'" },
]
[[tool.uv.index]]
name = "pytorch-cu126"
url = "https://download.pytorch.org/whl/cu126"
explicit = trueThen run the following to fetch the correct packages:
uv add torch torchvision