Skip to content

feat(weather-dl): add PostgreSQL manifest support - #562

Open
Omonire wants to merge 1 commit into
google:mainfrom
Omonire:feat/postgres-manifest
Open

Omonire wants to merge 1 commit into
google:mainfrom
Omonire:feat/postgres-manifest

Conversation

@Omonire

@Omonire Omonire commented Oct 31, 2026

Copy link
Copy Markdown

Summary

Implements #13 by adding a PostgreSQL-backed manifest to weather-dl.

Changes

  • PostgresManifest in weather_dl/download_pipeline/manifest.py:
    • Creates the manifest table and an index on config_name if they do not exist.
    • Reads by location; writes via INSERT ... ON CONFLICT (location) DO UPDATE, so there is always exactly one row per download holding its latest state.
    • Location format: postgresql://<user>:<password>@<host>:<port>/<database>?table=<table-name> (table defaults to manifest).
    • The table query param is stripped from the DSN; remaining params (e.g. sslmode) are forwarded to psycopg2. Table names are validated as SQL identifiers.
  • Registered the postgresql:// and postgres:// manifest schemes.
  • Documented the option in the CLI help and weather_dl/README.md, including a note that it works with Cloud Spanner's PostgreSQL interface.
  • Added psycopg2-binary to the package requirements and dev environment.
  • Added tests for location parsing/validation and serialization helpers, plus DB round-trip, upsert, and row-uniqueness tests. DB tests are skipped unless POSTGRES_MANIFEST_DSN is set.

Testing

  • Manifest test module: 15 passed (the 4 DB tests were run against a local PostgreSQL instance).
  • ruff check passes.

Fixes #13.

Implements a relational manifest backed by PostgreSQL, as requested in google#13.

- Add PostgresManifest that creates the manifest table (plus an index on
  config_name) if needed and upserts one row per download location.
- Register the postgresql:// and postgres:// manifest schemes.
- Parse the optional table query parameter, validating it as a SQL
  identifier and forwarding remaining params (e.g. sslmode) to psycopg2.
- Add unit tests for location parsing and DB round-trip/upsert tests
  gated on POSTGRES_MANIFEST_DSN.
- Document the new option in the CLI help and weather-dl README,
  including the Cloud Spanner PostgreSQL interface.
- Add psycopg2-binary to the package requirements.
@google-cla

google-cla Bot commented Oct 31, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@Omonire

Omonire commented Oct 31, 2026 via email

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

weather-dl: Implement PostgreSQL Manifest

1 participant