Skip to content

uv cheat sheet

Run these commands from your team repository. They work on macOS, Linux and Windows. If you haven't installed uv yet, start with machine setup.

Run your code

Command What it does
uv sync --locked Install the dependencies from uv.lock into .venv. Fails if the lockfile needs updating.
uv run python my_eval.py Run your script in the project environment, updating the lockfile and environment if needed.
uv run --locked python my_eval.py Run without changing the lockfile. Use this to check your script before submitting.
uv run python Open Python in the project environment.
uv run python --version Check which Python version your project uses.

You don't need to activate .venv before using uv run. After cloning or pulling your team's repository, uv sync --locked installs its dependencies.

Manage dependencies

Command What it does
uv add scikit-learn Add a runtime dependency and install it.
uv add "transformers>=4,<5" Add a dependency with version limits. Quote the requirement on every platform.
uv remove scikit-learn Remove a dependency and update the environment.
uv add --dev codecarbon Add a development dependency, for example for local measurements.
uv remove --dev codecarbon Remove a development dependency.
uv lock --upgrade-package scikit-learn Upgrade one package within the version limits in pyproject.toml. Run uv sync --locked afterwards to install it.
uv tree --locked Show your project's dependency tree without changing the lockfile.

uv add and uv remove update both pyproject.toml and uv.lock. Commit both so that your teammates and the evaluation server use the same dependencies.

Packages imported by your inference script belong in runtime dependencies (uv add). Optional extras and custom dependency groups are not installed by default on the evaluation server.

Keep the lockfile in sync

Command What it does
uv lock Create or update uv.lock after editing pyproject.toml manually.
uv lock --check Check that uv.lock matches pyproject.toml without changing it.
uv --version Print the uv version.
uv --help List uv commands. Add --help after any command for its options.

--locked reports an error if the lockfile is missing or out of date. Run uv lock, test your script again, then commit the updated files. Keep uv.lock in Git; keep .venv/ out of Git.

Run the Green AI Hack CLI

uvx greenaihack@latest submit
uvx greenaihack@latest status --wait

uvx runs the CLI in its own environment. @latest checks for CLI updates on each invocation; bare uvx greenaihack may reuse a cached or installed version. You don't need to add greenaihack or DVC to your project's dependencies.

See the CLI cheat sheet for registration, submission and results. For more on uv, see its guides to projects, dependencies, lockfiles and tools.