-
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
Changes from all commits
c13c730
7bdd8d7
bf9e4ae
541374a
c54ff84
345075b
921339f
c8d9359
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| 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"] |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,70 @@ | ||||||||||||||||||||
| #!/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 | ||||||||||||||||||||
| # AMI_ANTENNA_SERVICE_NAME="DRAC Worker" | ||||||||||||||||||||
| # EOF | ||||||||||||||||||||
| # | ||||||||||||||||||||
| # # Set service name and register worker with Antenna (once): | ||||||||||||||||||||
| # export AMI_ANTENNA_SERVICE_NAME="DRAC Worker" | ||||||||||||||||||||
| # ami worker register | ||||||||||||||||||||
| # ────────────────────────────────────────────────────────────────────── | ||||||||||||||||||||
|
|
||||||||||||||||||||
| 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). | ||||||||||||||||||||
| # Service name is read from AMI_ANTENNA_SERVICE_NAME in .env (hostname appended automatically). | ||||||||||||||||||||
| ami worker register | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # Run with timeout slightly shorter than SLURM --time to allow clean shutdown. | ||||||||||||||||||||
| # The worker handles SIGTERM gracefully and finishes the current batch. | ||||||||||||||||||||
| # Exit code 124 from timeout is expected (time limit reached), not an error. | ||||||||||||||||||||
| timeout --signal=SIGTERM 11h55m ami worker \ | ||||||||||||||||||||
| || { rc=$?; [[ $rc -eq 124 ]] && echo "Worker reached time limit — exiting cleanly." && exit 0; exit $rc; } | ||||||||||||||||||||
|
Comment on lines
+67
to
+70
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Line 67’s claim is unsafe: Please either (1) implement explicit signal-aware shutdown in worker code (stop polling, drain pending posts, then exit), or (2) remove the graceful-shutdown claim and document this as a hard stop. 🛠️ Minimal in-file correction while worker shutdown is not signal-aware-# The worker handles SIGTERM gracefully and finishes the current batch.
+# NOTE: Current worker code does not install a SIGTERM handler.
+# Timeout-triggered SIGTERM may interrupt in-flight processing/posting.📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
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