chore(api): drop the dead dev Dockerfile and read the app version from metadata - #76
Open
nadeem4 wants to merge 1 commit into
Open
chore(api): drop the dead dev Dockerfile and read the app version from metadata#76nadeem4 wants to merge 1 commit into
nadeem4 wants to merge 1 commit into
Conversation
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
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Two small, independent cleanups in the API package.
1. Delete the orphaned
packages/api/Dockerfile.devThe file was tracked but dead. 12 of its 17
COPYpaths pointed at thepackages/core,packages/adapter-sqlalchemyandpackages/adapters/{mssql,mysql,postgres,sqlite}layout that was removed in thedistribution collapse. Only 5 paths still resolve, so the image could not build
at all — the first
COPY ./packages/core/pyproject.tomlfails outright.It has no live references anywhere in the repo: no workflow, compose file,
doc, or task runner mentions it. Every
Dockerfilereference in the tree pointsat
packages/api/Dockerfile.packages/api/Dockerfile— the real one used by the GHCR build in.github/workflows/publish_pypi.yaml— is untouched, and all three of itsCOPYpaths resolve against the current layout.2. Read the FastAPI app version from the distribution metadata
main.pyhardcodedversion="0.1.0"in theFastAPI(...)constructor, andnothing bumped it. It happened to agree with
packages/api/pyproject.tomltoday, but release-please only bumps the
pyproject.tomlmarker — so the verynext release (
0.1.1) would have left the OpenAPI spec advertising0.1.0, aversion the package no longer is. That gap would widen with every subsequent
release, and anything relying on the served spec to identify the API build
would be quietly wrong.
The version is now read at runtime via
importlib.metadata.version("nl2sql-api"), so it trackspyproject.tomlautomatically. Deliberately no
# x-release-please-versionmarker is addedhere: reading the installed metadata is the point, and a second bump target
would just be one more thing to drift.
PackageNotFoundErrorfalls back to"0.0.0"so the app still imports from asource tree where the distribution is not installed.
0.0.0is a valid PEP 440version that sorts below every real release, matching the convention the
release manifest is already seeded with, and it cannot be mistaken for a
published build.
Tests
Added to the existing
packages/api/tests/test_app.py:test_app_version_matches_installed_distributionassertsapp.versionequals
importlib.metadata.version("nl2sql-api")rather than a hardcodedliteral, so the test cannot itself go stale.
test_app_version_falls_back_when_distribution_is_missingmonkeypatches thelookup to raise
PackageNotFoundErrorand confirms the fallback path returnsa version instead of raising.
Both fallback and normal branches were confirmed to be genuinely exercised
(
0.0.0and0.1.0respectively).Unit: 261 passed, 1 skipped, 47 deselected (259 baseline + the 2 new tests).
Key-free integration: 28 passed. Both suites run twice under
pytest-randomly.No changes to
CHANGELOG.md, anypyproject.tomlversion, or.release-please-manifest.json.