Make external service clients optional - #176
Conversation
d9f9cad to
2c28fe2
Compare
There was a problem hiding this comment.
Pull request overview
Makes external service clients optional while keeping core analysis, CLI, and built-in sources available by default.
Changes:
- Adds per-integration extras and lazy client imports.
- Adds missing-dependency handling and core-install tests.
- Updates Docker, CI, and installation documentation.
Reviewed changes
Copilot reviewed 20 out of 21 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
pyproject.toml |
Defines integration extras and local dev dependencies. |
uv.lock |
Locks the revised dependency structure. |
otava/_optional.py |
Adds optional-import error handling. |
otava/bigquery.py |
Lazily imports BigQuery clients. |
otava/grafana.py |
Lazily imports Requests. |
otava/importer.py |
Lazily creates BigQuery parameters. |
otava/influxdb.py |
Lazily imports the InfluxDB client. |
otava/main.py |
Lazily initializes Slack and handles missing extras. |
otava/postgres.py |
Lazily imports pg8000. |
otava/slack.py |
Lazily imports the Slack SDK. |
tests/core_install_smoke.py |
Tests a clean core installation. |
tests/optional_dependencies_test.py |
Tests optional-import behavior. |
.github/workflows/python-app.yml |
Adds the core-wheel CI job. |
Dockerfile |
Installs all integrations in production images. |
README.md |
Documents installation extras. |
docs/INSTALL.md |
Lists available extras. |
docs/GETTING_STARTED.md |
Updates setup instructions. |
docs/BIG_QUERY.md |
Documents the BigQuery extra. |
docs/GRAFANA.md |
Documents the Grafana extra. |
docs/INFLUXDB.md |
Documents the InfluxDB extra. |
docs/POSTGRESQL.md |
Documents the PostgreSQL extra. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
f5cc644 to
201354a
Compare
|
@Gerrrr 245 tests pass on each of Python 3.10, 3.11, 3.12, 3.13 and 3.14, including the Docker-backed Graphite, PostgreSQL and InfluxDB e2e tests, and
|
201354a to
d4b1a73
Compare
|
Thanks for the review @MrlixiangWE! This is a valid suggestion; fixed. |
Otava currently installs every database and notification client even when callers only need the analysis library, bundled CLI, or built-in data sources. Split BigQuery, PostgreSQL, InfluxDB, Grafana, and Slack clients into installable extras so users pay only for the integrations they need. Keep the production image's existing all-integrations behavior through the all extra, move contributor tools into the unpublished dev dependency group, load optional clients lazily with actionable installation errors, and verify a clean core wheel in CI. Update installation and integration documentation to describe the new choices.
Running the documented workflows exposed stale paths, timestamps, output, date selectors, and malformed code fences. Add a runnable source-checkout CSV configuration with regression coverage and align the CSV, Graphite, Grafana, PostgreSQL, and InfluxDB examples with the bundled fixtures.
d4b1a73 to
489c09a
Compare
|
@henrikingo I am going to merge this PR and let you comment async. As usual, I'll be happy to fix-forward any feedback. |
|
I'm keeping an eye on things, can't comment yet. Glad to see project so active! Hopefully I can help do a release soon and hopefully the deterministic variation is in it. |
Why
pip install apache-otavacurrently installs every database and notification client, even when the caller only needs the analysis library, bundled CLI, built-in CSV and JSON sources, or the bundled NoSQLBench HistoStat and Graphite importers. This PR makes the default installation useful on its own while letting users opt into only the external services they need.Measured impact
Fresh measurements from the wheel built from this branch:
influxdbinfluxdb3-pythonbigquery--update-bigquerygoogle-cloud-bigqueryslack--notify-slackslack-sdkgrafana--update-grafana,remove-annotationsrequestspostgres--update-postgrespg8000allThe default installation avoids 212.2 MB (58.9%) and 29 packages (60.4%) compared with the full integration set.
NoSQLBench HistoStat and Graphite support remain bundled because their implementations add no external Python dependencies, so making them extras would not reduce installation size. We may still extract them into separate packages or plugins as follow-up work.
Measured on Python 3.14.7 on macOS arm64 using wheel-only installs with bytecode compilation and a fresh environment for each row. Installed size is the sum of file sizes under
site-packages. Absolute results vary by platform, but these measurements closely match those reported in #175.Installation examples
The production Docker image continues to include every integration by installing
[all].Contributor-only tools now live in the local
devdependency group rather than apublished
[dev]extra. A full contributor environment is installed with:uv sync --all-extras --devWhat changed
allextra.[dev]extra and into the standardized localdevdependency group.pytz, which Otava imports directly at runtime, as a core dependency instead of relying ondateparserto install it transitively.[all]in the production Docker image.Note
Exercising the documented workflows during testing also uncovered pre-existing
documentation issues, including stale paths, dates and expected output. Those
corrections and their executable CSV regression coverage are included in a
separate commit.
Verification
246 passedacross the complete test and performance suite, including Docker-backed Graphite, InfluxDB, and PostgreSQL end-to-end tests.[all]wheel: 48 packages and all service client imports pass.otava --helpruns successfully.Closes #55
Closes #175