refactor: migrate to src layout and add linting/type-checking configs#6
Draft
refactor: migrate to src layout and add linting/type-checking configs#6
Conversation
Move main.py into src/eo_api/ package layout. Add ruff, mypy, and pyright configurations to pyproject.toml. Update Makefile and README with new module path. Add ruff, mypy, pyright as dev dependencies.
Add build-system config using uv_build backend so the src layout package installs correctly. Add make help as default target.
Extract route definitions into dedicated router modules (routers/root.py, routers/cog.py) and add Pydantic schemas (schemas.py). Clean up main.py by removing noisy comments, fixing the load_dotenv() placement, and switching to fastapi.middleware.cors.
…router Rename the generic MessageResponse model to StatusMessage for clarity. Move the pygeoapi mount into its own router module for future configuration.
17bea73 to
71c5bc1
Compare
Add containerized deployment with uv base image, non-root user, and healthcheck. Include .dockerignore and docker-build/docker-run Make targets.
Add __version__ to eo_api package, an AppInfo schema, and a GET /info endpoint returning app/Python/titiler/pygeoapi/uvicorn versions. Tag all root router endpoints with "System" for OpenAPI grouping.
Replace docker-build/docker-run with docker-up/docker-down targets that use docker compose for declarative container management.
Shell-form CMD runs under /bin/sh which doesn't forward SIGTERM, causing exit code 137 on Ctrl-C. Tini as PID 1 fixes this.
Move plugins/ from repo root into src/eo_api/routers/ogcapi/plugins/, convert ogcapi.py into a package, rename dhis2orgUnits.py to snake_case, fix mutable default args, add missing self param, and add docstrings. Update pygeoapi-config.yml provider paths accordingly.
GET /ogcapi/collections/dhis2-org-units/items/{id} returned 500 because
the provider didn't override BaseProvider.get(), which raises
NotImplementedError. Add a stub get() that returns a single hardcoded
GeoJSON Feature, consistent with the existing query() stub.
Replace stub data in DHIS2OrgUnitsProvider with live API calls to the DHIS2 play server. Use Pydantic for response validation and geojson-pydantic for GeoJSON output. Fields: name, code, shortName, level, openingDate, geometry.
Add OrgUnitProperties Pydantic model and derive get_fields() from its
JSON Schema so the /schema endpoint receives {"type": "string"} dicts
instead of plain strings. Rename Makefile docker targets to start/restart.
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 free
to 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.
Summary
main.pyat root) tosrc/eo_api/package layoutpyproject.tomlmake linttargetmain.pyinto routers (cog,ogcapi) with Pydantic response modelsdocs/ogcapi.mdreference guide covering OGC API standards, pygeoapi configuration, resource types, and plugin systemmake testtarget.python-versionuv_buildbuild system andmake helpas default target/healthendpoint withStatusStrEnum for Docker container health checks/infoendpoint returning app/Python/titiler/pygeoapi/uvicorn versions/,/health,/info) as "System" in OpenAPI docscompose.ymlwith env_file, port mapping, and restart policydocker-build/docker-runMakefile targets withdocker-up/docker-downusing docker composemake openapitarget from mainTest plan
make lintpassesmake testpassesmake runstarts the app correctly with new module pathGET /inforeturns expected version JSON/docsshows root endpoints grouped under "System" tagdocker compose configvalidates successfullymake docker-upbuilds and starts the container