-
Notifications
You must be signed in to change notification settings - Fork 7
Migrate from Poetry to uv, bump deps for H100/Python 3.12 #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c13c730
feat: migrate from Poetry to uv, bump deps for H100/Python 3.12
mihow 7bdd8d7
fix: np.product removal in numpy 2.0, address review feedback
mihow bf9e4ae
fix: cache ML model downloads in CI
mihow 541374a
fix: SLURM script register args and timeout exit code
mihow c54ff84
Merge remote-tracking branch 'origin/main' into feature/uv-migration
mihow 345075b
Merge remote-tracking branch 'origin/main' into feature/uv-migration
mihow 921339f
Merge remote-tracking branch 'origin/main' into feature/uv-migration
mihow c8d9359
Merge remote-tracking branch 'origin/main' into feature/uv-migration
mihow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,67 +1,73 @@ | ||
| [tool.poetry] | ||
| [project] | ||
| name = "trapdata" | ||
| version = "0.6.0" | ||
| description = "Companion software for automated insect monitoring stations" | ||
| authors = ["Michael Bunsen <notbot@gmail.com>"] | ||
| license = "MIT" | ||
| authors = [{ name = "Michael Bunsen", email = "notbot@gmail.com" }] | ||
| license = { text = "MIT" } | ||
| readme = "README.md" | ||
| homepage = "https://github.com/RolnickLab/ami-data-manager" | ||
| repository = "https://github.com/RolnickLab/ami-data-manager" | ||
| requires-python = ">=3.10,<3.13" | ||
| urls = { Homepage = "https://github.com/RolnickLab/ami-data-companion", Repository = "https://github.com/RolnickLab/ami-data-companion" } | ||
|
|
||
| [build-system] | ||
| requires = ["poetry-core>=1.0.0"] | ||
| build-backend = "poetry.core.masonry.api" | ||
| dependencies = [ | ||
| "alembic>=1.10.2", | ||
| "boto3>=1.33", | ||
| "fastapi>=0.100", | ||
| "gradio>=4.41", | ||
| "imagesize>=1.4.1", | ||
| "numpy>=1.26", | ||
| "pandas>=2.0", | ||
| "pillow>=10.0", | ||
| "pydantic>=2.5", | ||
| "pydantic-settings>=2.1", | ||
| "python-dateutil>=2.8.2", | ||
| "python-dotenv>=1.0", | ||
| "requests>=2.28", | ||
| "rich>=13.3", | ||
| "sentry-sdk>=1.18", | ||
| "sqlalchemy>=2.0", | ||
| "sqlalchemy-utils>=0.40", | ||
| "structlog>=22.3", | ||
| "timm>=0.6.13", | ||
| "torch>=2.5", | ||
| "torchvision>=0.20", | ||
| "typer>=0.12.3,<1", | ||
| "uvicorn>=0.20", | ||
| ] | ||
|
|
||
| [project.optional-dependencies] | ||
| gui = [ | ||
| "kivy[base]>=2.3", | ||
| "plyer>=2.1", | ||
| "pyobjus>=1.2.1; sys_platform == 'darwin'", | ||
| ] | ||
| postgres = [ | ||
| "psycopg2-binary>=2.9.5", | ||
| ] | ||
|
|
||
| [tool.poetry.dependencies] | ||
| python = "^3.10,<3.12" | ||
| pillow = "^9.5.0" | ||
| python-dateutil = "^2.8.2" | ||
| python-dotenv = "^1.0.0" | ||
| pydantic = "^2.5.0" | ||
| rich = "^13.3.3" | ||
| pandas = "^1.5.3" | ||
| sqlalchemy = ">2.0" | ||
| sqlalchemy-utils = "^0.40.0" | ||
| alembic = "^1.10.2" | ||
| psycopg2-binary = { version = "^2.9.5", optional = true } | ||
| sentry-sdk = "^1.18.0" | ||
| imagesize = "^1.4.1" | ||
| torch = "^2.1.0" | ||
| torchvision = "^0.16.0" | ||
| timm = "^0.6.13" | ||
| structlog = "^22.3.0" | ||
| kivy = { extras = ["base"], version = "^2.3.0" } | ||
| plyer = "^2.1.0" | ||
| pyobjus = { version = "^1.2.1", markers = "sys_platform == 'darwin'" } | ||
| [dependency-groups] | ||
| dev = [ | ||
| "black>=23.3", | ||
| "flake8>=6.0", | ||
| "ipython>=8.11", | ||
| "isort>=5.12", | ||
| "mypy-boto3-s3>=1.29", | ||
| "pytest>=7", | ||
| "pytest-asyncio>=0.21", | ||
| "pytest-cov>=4.0", | ||
| ] | ||
|
|
||
| # [tool.poetry.group.dev.dependencies] # Can't install these dev deps with pip, so they're in the main deps | ||
| black = "^23.3.0" | ||
| flake8 = "^6.0.0" | ||
| ipython = "^8.11.0" | ||
| pytest-cov = "^4.0.0" | ||
| pytest-asyncio = "^0.21.0" | ||
| pytest = "*" | ||
| numpy = "^1.26.2" | ||
| pip = "^23.3.1" | ||
| pydantic-settings = "^2.1.0" | ||
| boto3 = "^1.33.0" | ||
| botocore = "^1.33.0" | ||
| mypy-boto3-s3 = "^1.29.7" | ||
| typer = ">=0.12.3,<1.0.0" | ||
| gradio = "^4.41.0" | ||
| [project.scripts] | ||
| trapdata = "trapdata.ui.main:run" | ||
| trapdata-test = "trapdata.tests.test_pipeline:process_deployments" | ||
| ami = "trapdata.cli.base:cli" | ||
|
|
||
| [build-system] | ||
| requires = ["hatchling"] | ||
| build-backend = "hatchling.build" | ||
|
|
||
| [tool.pytest.ini_options] | ||
| asyncio_mode = 'auto' | ||
| asyncio_mode = "auto" | ||
| testpaths = ["trapdata/tests", "trapdata/**/tests"] | ||
|
|
||
| [tool.isort] | ||
| profile = "black" | ||
|
|
||
| [tool.poetry.scripts] | ||
| trapdata = 'trapdata.ui.main:run' | ||
| trapdata-test = 'trapdata.tests.test_pipeline:process_deployments' | ||
| ami = 'trapdata.cli.base:cli' | ||
|
|
||
| # [tool.setuptools.package_data] | ||
| # trapdata = ["*.kv", "*.txt", "*.json", "*.ini", "*.md"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| #!/bin/bash | ||
| #SBATCH --job-name=adc-worker | ||
| #SBATCH --account=def-YOUR_ACCOUNT # <-- Replace with your DRAC allocation | ||
| #SBATCH --time=12:00:00 | ||
| #SBATCH --mem=32G | ||
| #SBATCH --cpus-per-task=4 | ||
| #SBATCH --gres=gpu:1 # Request 1 GPU (see GPU options below) | ||
| #SBATCH --output=%x-%j.out | ||
| #SBATCH --error=%x-%j.err | ||
| # | ||
| # Example SLURM job script for running the ADC Antenna worker on DRAC Alliance | ||
| # HPC clusters (Fir, Rorqual, Narval, etc.). | ||
| # | ||
| # GPU options (adjust --gres): | ||
| # Fir/Rorqual: gpu:h100:1 | ||
| # Narval: gpu:a100:1 | ||
| # Cedar: gpu:v100l:1 | ||
| # | ||
| # ────────────────────────────────────────────────────────────────────── | ||
| # One-time setup (run interactively, NOT in this script): | ||
| # | ||
| # module load python/3.12 cuda/12.6 | ||
| # uv venv ~/venvs/adc --python 3.12 | ||
| # source ~/venvs/adc/bin/activate | ||
| # cd ~/projects/ami-data-companion | ||
| # # --no-deps: let the lockfile control versions; avoids conflicts with | ||
| # # system packages on DRAC nodes. | ||
| # uv pip install --no-deps -r <(uv export --no-hashes --frozen) | ||
| # uv pip install --no-deps . | ||
| # | ||
| # # Create .env with your Antenna credentials: | ||
| # cat > .env <<EOF | ||
| # AMI_ANTENNA_API_BASE_URL=https://antenna.insectai.org/api/v2 | ||
| # AMI_ANTENNA_API_AUTH_TOKEN=your_token_here | ||
| # AMI_ANTENNA_API_BATCH_SIZE=4 | ||
| # EOF | ||
| # | ||
| # # Register worker with Antenna (once): | ||
| # ami worker register "DRAC Worker" | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| # ────────────────────────────────────────────────────────────────────── | ||
|
|
||
| set -euo pipefail | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| # Catch unedited placeholder in #SBATCH --account | ||
| if [[ "${SLURM_JOB_ACCOUNT:-}" == *YOUR_ACCOUNT* ]]; then | ||
| echo "ERROR: Replace --account in this script with your DRAC allocation." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| module load python/3.12 cuda/12.6 | ||
|
|
||
| source ~/venvs/adc/bin/activate | ||
| cd ~/projects/ami-data-companion | ||
| if [[ ! -f .env ]]; then | ||
| echo "ERROR: .env not found in $(pwd). See one-time setup instructions in this script." >&2 | ||
| exit 1 | ||
| fi | ||
| set -a; source .env; set +a | ||
|
|
||
| # Register pipelines on each run (idempotent) | ||
| ami worker register "DRAC Worker - $(hostname)" | ||
|
|
||
| # Run with timeout slightly shorter than SLURM --time to allow clean shutdown. | ||
| # The worker handles SIGTERM gracefully and finishes the current batch. | ||
| timeout --signal=SIGTERM 11h55m ami worker | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
In GitHub Actions, doesuv python installalso force subsequentuv syncanduv runto use that exact interpreter, or shouldUV_PYTHON(or setup-uv python-version input) be set explicitly?💡 Result:
No, uv python install does not force subsequent uv sync and uv run to use that exact interpreter automatically. uv selects the Python interpreter via a discovery process that prioritizes: UV_PYTHON environment variable (if set to a path), .python-version files (project-local or parent dirs), pyproject.toml requires-python, managed Pythons in UV_PYTHON_INSTALL_DIR (newer first), then PATH executables (first matching). uv python install adds the version to managed Pythons and PATH (via shims in ~/.local/bin), making it discoverable and preferred if no higher-priority specifier exists (e.g., no .python-version or UV_PYTHON), but does not set UV_PYTHON or create .python-version. In GitHub Actions, use setup-uv's python-version input (sets UV_PYTHON to the path) or explicitly set UV_PYTHON=/path/to/python for guarantee. Official docs recommend explicit uv python install after setup-uv for projects without pyproject.toml requires-python, but pairing with setup-uv python-version or UV_PYTHON ensures the exact interpreter.
Citations:
🏁 Script executed:
Repository: RolnickLab/ami-data-companion
Length of output: 1094
🏁 Script executed:
Repository: RolnickLab/ami-data-companion
Length of output: 1761
Set UV_PYTHON to enforce matrix Python version for
uv syncanduv runcommands.The workflow installs a matrix Python version via
uv python install, but doesn't explicitly pin it. Whilepyproject.tomlconstrains the range to 3.10–3.13, it doesn't guarantee the exact matrix version (e.g., 3.10) is used if other compatible versions exist on the runner's PATH. This risks silent matrix coverage drift.Suggested hardening
- name: Set up Python ${{ matrix.python-version }} run: uv python install ${{ matrix.python-version }} + + - name: Pin uv interpreter for this job + run: echo "UV_PYTHON=${{ matrix.python-version }}" >> "$GITHUB_ENV" - name: Install dependencies run: uv syncAlternatively, pass
python-versionto thesetup-uvaction:📝 Committable suggestion
🤖 Prompt for AI Agents