Repository navigation
build!: adopt pyproject, harden image and Compose - #223
Conversation
Package with pyproject.toml as cloud-registry does: version from Git tags via setuptools-scm (fallback 0.0.0.dev0), bounded dependencies, a dev extra, package data. Remove setup.py, setup.cfg (flake8 settings move to .flake8 until ruff replaces flake8), the requirements files, pro_tes/version.py and the stray file =0.12.1. Image: dependencies from pyproject.toml, non-editable install as root, then UID 1000; health check on the Swagger UI; version as build argument; Gunicorn settings in pro_tes/gunicorn_config.py with the app factory as command, replacing gunicorn.py (which trusted X-Forwarded-* headers from any address) and wsgi.py. The Celery worker runs as pro_tes.celery_worker, also in the Helm chart. Compose: ports on 127.0.0.1 only, health checks for docker compose up --wait, RabbitMQ credentials in CELERY_BROKER_URL, Flower in an opt-in profile with required basic auth, named volumes. CI installs the dev extra, builds and checks the wheel, waits for the healthy Compose stack and checks the app version; the publish job passes the version to the image build. Add Dependabot config. Closes #204 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Mount only the dependency wheels and requirements of the build stage, test the health check path against the app, explain the mypy pin, and document the broker credential rules and that data of the former bind mounts is not migrated. Bump the chart to 3.0.0, as its commands need the new image. BREAKING CHANGE: The image installs proTES into site-packages: the app runs with `gunicorn --config python:pro_tes.gunicorn_config 'pro_tes.app:init_app()'` and the worker with `celery --app pro_tes.celery_worker worker`; `/app/pro_tes`, `gunicorn.py` and `wsgi.py` are gone, and `GUNICORN_PROCESSES` and `GUNICORN_THREADS` are replaced by `GUNICORN_CMD_ARGS`. Chart 3.0.0 needs images built from this version, and earlier charts need earlier images. Co-Authored-By: Claude Opus 5.5 <[email protected]>
appVersion is the version of proTES, not of the chart; it is set with the release process (#44). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThis breaking change adopts pyproject.toml/setuptools-scm packaging, produces a hardened non-root image with new Gunicorn/Celery entry points, and rewrites Compose and Helm execution around health checks, safer networking, pinned dependencies, and coordinated versioned builds. Sequence diagram for Compose health-gated startupsequenceDiagram
participant Compose
participant MongoDB
participant RabbitMQ
participant ProTES
participant Worker
Compose->>MongoDB: healthcheck ping
MongoDB-->>Compose: healthy
Compose->>RabbitMQ: rabbitmq-diagnostics ping
RabbitMQ-->>Compose: healthy
Compose->>ProTES: start after dependencies are healthy
Compose->>Worker: start after dependencies are healthy
Compose->>ProTES: HTTP healthcheck /ga4gh/tes/v1/ui/
ProTES-->>Compose: healthy
Compose->>Worker: celery inspect ping
Worker-->>Compose: healthy
Compose-->>Compose: docker compose up --wait completes
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="docker-compose.yaml" line_range="86" />
<code_context>
+ image: mongo:7.0
+ restart: unless-stopped
+ volumes:
+ - mongodb-data:/data/db
+ healthcheck:
+ test: ["CMD", "mongosh", "--quiet", "--eval", "db.adminCommand('ping').ok"]
</code_context>
<issue_to_address>
**Existing MongoDB data disappears**
When an existing Compose installation upgrades with task records in its former `PROTES_DATA_DIR` database, compose mounts a new named volume, so `TaskRuns.list_tasks` and `TaskRuns.get_task` cannot find those records, and `PROTES_DATA_DIR` no longer controls MongoDB storage; users see an empty task list.
Keep MongoDB on the configured `PROTES_DATA_DIR` bind mount or migrate the existing database into the named volume.
Also at `docker-compose.yaml:121`.
</issue_to_address>
### Comment 2
<location path="pro_tes/gunicorn_config.py" line_range="27" />
<code_context>
+!LICENSE
+!pyproject.toml
+!README.md
+
+# Exclude caches and local files within the included paths
+**/__pycache__
</code_context>
<issue_to_address>
**Port configuration guidance is stale**
When a user changes the app’s `server` settings expecting the container’s production server to use them, gunicorn binds to the configured fixed address rather than `config.yaml`’s `server.host` and `server.port`, so users following the README’s instruction to change those settings do not change the image’s listening address.
Update the README to say that the image’s Gunicorn bind is controlled with `GUNICORN_CMD_ARGS` and that the Compose port mapping must also be changed as needed.
</issue_to_address>
### Comment 3
<location path="tests/test_gunicorn_config.py" line_range="119" />
<code_context>
+ monkeypatch.chdir(tmp_path)
+ monkeypatch.setattr(sys, "argv", ["pytest"])
+ monkeypatch.setenv("GUNICORN_CMD_ARGS", "--workers 3")
+ assert load_settings("--chdir /").cfg.workers == 1
+ assert load_settings().cfg.workers == 1
+ assert (os.getcwd(), sys.argv) == (str(tmp_path), ["pytest"])
</code_context>
<issue_to_address>
**Working-directory restoration goes untested**
When `load_settings` constructs a `WSGIApplication` without running Gunicorn, when Gunicorn only parses `--chdir /` without running its chdir path, `test_load_settings_restores` line 119 never changes the working directory, so line 121 still passes if `load_settings`’s `os.chdir(cwd)` cleanup is removed.
Make the test cause a controlled working-directory change during `load_settings`, then assert that the helper restores the original directory.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 3 findings to address first, and docker Compose switches MongoDB from the existing host directory to a new named volume, so prior data is left behind and the app starts with a fresh database; records written to the new volume remain there after a revert and require manual recovery or migration to access.
Blocking findings: docker-compose.yaml:86, pro_tes/gunicorn_config.py:27, tests/test_gunicorn_config.py:119
The `server.host` and `server.port` settings apply to Flask's development server only; the image's Gunicorn binds to the address of `pro_tes/gunicorn_config.py`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Closes #204. This follows the cloud-registry template (elixir-cloud-aai/cloud-registry#97, #120 and #142).
pyproject.tomlwith setuptools-scm. The version comes fromvX.Y.Ztags, with fallback0.0.0.dev0.devextra and package data.setup.py,setup.cfg, both requirements files,pro_tes/version.pyand the stray file=0.12.1..flake8.pylintrcstays until style: adopt the shared ruff, mypy and pre-commit #206 replaces flake8 and pylint with ruff.ip2geotoolsneedstyped-ast.USER 1000. Base image pinned by digest.HEALTHCHECKon the Swagger UI.SETUPTOOLS_SCM_PRETEND_VERSIONbuild argument. Labels name ELIXIR On-Cloud.CMD gunicorn --config python:pro_tes.gunicorn_config 'pro_tes.app:init_app()'. The Gunicorn settings follow cloud-registry and dropforwarded_allow_ips = "*";FORWARDED_ALLOW_IPSis documented instead.gunicorn.pyandwsgi.pyare removed. The worker runscelery --app pro_tes.celery_worker worker.127.0.0.1only (proTES, plus Flower when enabled). MongoDB and RabbitMQ are no longer published.docker compose up --waitworks.CELERY_BROKER_URL.monitoringand refuses to start withoutFLOWER_BASIC_AUTH.links/version, pinned images (rabbitmq:4.1,mher/flower:2.0.1)..[dev], builds the distributions and checks the wheel contents.--wait, checks the version the app reports, and shows logs on failure.docker/build-push-action, passing the version from setuptools-scm as a build argument (same tags as before:latestand the date).Breaking change (in the commit footer):
/app/pro_tes,gunicorn.pyorwsgi.py.GUNICORN_PROCESSESandGUNICORN_THREADSare replaced byGUNICORN_CMD_ARGS.latestandimagePullPolicy: Always, chart and image must be upgraded together.Local Compose data: MongoDB data in the former bind mount (
PROTES_DATA_DIR, default../data/pro_tes) is not migrated to the named volume.Not done here:
PROTES_DATA_DIR,docker-composev1 and the old ports, and needs updating in docs: present the app, use ELIXIR On-Cloud #210.config.dev.yamloverlay: no local-development setting differs from the base config yet. It comes with the auth settings of feat(auth)!: require tokens for task operations #212, as in cloud-registry.elixircloud/foca:0.15.0-py3.13exists, buttyped-ast(required byip2geotools) does not build on 3.13. The single-version rule (3.13) moves to build!: require FOCA 0.17 and Python 3.13 #214, whose title and text were updated; build!: require FOCA 0.17 and Python 3.13 #214 must also replaceip2geotools.Full review lane.
How it was verified
pytest tests --ignore=tests/unitTest --ignore=tests/test_integration: 41 passed on each.flake8 pro_tes: clean.pylint pro_tes: 10.00/10.mypy pro_tes: no issues.python -m build: wheel contains onlypro_tes, its YAML data and the license.docker compose configvalidated, with and without--profile monitoring. The stack itself is started by CI (no localdocker run).CI: all checks pass (linting and unit tests on 3.10 and 3.12; Compose stack healthy with
--wait, app version check and integration tests; CodeQL).Declined review findings
Pin all CI actions by SHA, and add
concurrencyandtimeouts(quality, medium): deferred to style: adopt the shared ruff, mypy and pre-commit #206, which replaces the lint jobs with one pre-commit job.Default chart image tags to the chart's
appVersioninstead oflatest(adversarial, low): belongs to the chart rewrite in build(chart)!: use the FOCA library chart #216.Version goes back from
0.2.0(oldversion.py) to0.0.0.devN, because the repository has novX.Y.Ztags (adversarial, medium): tags are part of the release process (ci: release from signed version tags #44). Taggingv0.2.0on 5f80afe (where 0.2.0 was set) would restore it. This is noted for the maintainers, not a blocker.Sourcery: keep MongoDB on the
PROTES_DATA_DIRbind mount or migrate it. Declined: the Compose file is for local development only, the change is documented, and a bind mount can be added in an override.Sourcery:
test_load_settings_restoresdoes not change the working directory. Declined: Gunicorn'sload_config()callschdir(), so the test covers the restore.Open questions
None.
🤖 Generated with Claude Code