You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@otava.apache.org by "Gerrrr (via GitHub)" <gi...@apache.org> on 2026/08/29 18:35:30 UTC

[PR] Make external service clients optional [otava]

Gerrrr opened a new pull request, #176:
URL: https://github.com/apache/otava/pull/176

   ## Why
   
   `pip install apache-otava` currently installs every database and notification client, even when the caller only needs the analysis library, bundled CLI, or built-in CSV, JSON, HistoStat, and Graphite sources.
   
   This is not hypothetical:
   
   - [Nyrkiö imports Otava](https://github.com/nyrkio/nyrkio/blob/ecc4b6f5f8c6369f900fafbbfc5533220888eefc/backend/core/core.py#L12-L18) and feeds it `Series` objects from its own storage; Otava is not connected to a database at all ([analysis endpoint](https://github.com/nyrkio/nyrkio/blob/ecc4b6f5f8c6369f900fafbbfc5533220888eefc/backend/api/changes.py#L4), [discussion](https://github.com/apache/otava/issues/101#issuecomment-3589345129)).
   - Another [programmatic-use example](https://github.com/apache/otava/issues/101#issuecomment-3613628236) transforms data from MySQL/custom processing into `Series` before analysis.
   - A CSV-only user currently receives BigQuery, PostgreSQL, InfluxDB, Grafana, and Slack dependencies anyway.
   
   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:
   
   | install / extra | covers | client dependency | installed size | cost over core |
   |---|---|---|---:|---:|
   | default | analysis, CLI, CSV, JSON, HistoStat, Graphite | — | 148.1 MB / 19 pkgs | core |
   | `influxdb` | importer | `influxdb3-python` | 283.0 MB / 24 pkgs | +134.9 MB / +5 pkgs |
   | `bigquery` | importer + `--update-bigquery` | `google-cloud-bigquery` | 221.2 MB / 41 pkgs | +73.1 MB / +22 pkgs |
   | `slack` | `--notify-slack` | `slack-sdk` | 152.1 MB / 20 pkgs | +4.0 MB / +1 pkg |
   | `grafana` | `--update-grafana`, `remove-annotations` | `requests` | 151.7 MB / 24 pkgs | +3.5 MB / +5 pkgs |
   | `postgres` | importer + `--update-postgres` | `pg8000` | 149.7 MB / 22 pkgs | +1.5 MB / +3 pkgs |
   | `all` | every integration | all clients | 360.3 MB / 48 pkgs | +212.2 MB / +29 pkgs |
   
   The default installation avoids 212.2 MB (58.9%) and 29 packages (60.4%) compared with the full integration set.
   
   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
   
   ```console
   # Analysis library, CLI, and built-in sources
   pip install apache-otava
   
   # One external service
   pip install 'apache-otava[bigquery]'
   
   # Combine only the services needed
   pip install 'apache-otava[bigquery,postgres]'
   
   # Existing all-integrations experience
   pip install 'apache-otava[all]'
   ```
   
   The production Docker image continues to include every integration by installing `[all]`.
   
   ## What changed
   
   - Move BigQuery, PostgreSQL, InfluxDB, Grafana, and Slack clients into named extras, plus an `all` extra.
   - Import optional clients only when their features are used.
   - Report actionable errors that name the missing extra and installation command.
   - Keep Slack optional even for code paths that do not send notifications.
   - Add a clean-wheel core installation smoke test to CI.
   - Install `[all]` in the production Docker image.
   - Update the README, installation guide, getting-started guide, and integration-specific documentation.
   
   ## Scope
   
   This deliberately contains only dependency extraction and its supporting tests/documentation. It does not move modules, redesign the public analysis model, introduce compatibility shims, or commit architecture specifications. Keeping those API discussions separate lets #55 and #175 land independently.
   
   ## Verification
   
   - `242 passed` across the complete test and performance suite, including Docker-backed Graphite, InfluxDB, and PostgreSQL end-to-end tests.
   - Lint and license checks pass through tox.
   - Clean default wheel: 19 packages and the core smoke test passes.
   - `[all]` wheel: 48 packages and all service client imports pass.
   - Production Docker image builds and `otava --help` runs successfully.
   
   Closes #55
   Closes #175
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@otava.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Make external service clients optional [otava]

Posted by "Gerrrr (via GitHub)" <gi...@apache.org>.
Gerrrr commented on code in PR #176:
URL: https://github.com/apache/otava/pull/176#discussion_r3888455440


##########
otava/influxdb.py:
##########
@@ -51,7 +64,7 @@ def __init__(self, config: InfluxDBConfig):
     @property
     def client(self) -> InfluxDBClient3:
         if self._client is None:
-            self._client = InfluxDBClient3(
+            self._client = _influxdb_client_class()(

Review Comment:
   Fixed in f5cc644. `InfluxDBImporter.fetch_data` now re-raises `MissingOptionalDependencyError` before its general client-error wrapper, allowing the CLI handler to exit with status 1. Added a regression test covering the exit status and actionable `[influxdb]` installation message.



##########
docs/GRAFANA.md:
##########
@@ -22,6 +22,14 @@
 Change points found by `analyze` can be exported
 as Grafana annotations using the `--update-grafana` flag:
 
+## Installation

Review Comment:
   Fixed in f5cc644. The Installation section now comes first, and the usage introduction remains directly attached to its command example under the Usage heading.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@otava.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Make external service clients optional [otava]

Posted by "Gerrrr (via GitHub)" <gi...@apache.org>.
Gerrrr merged PR #176:
URL: https://github.com/apache/otava/pull/176


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@otava.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Make external service clients optional [otava]

Posted by "Gerrrr (via GitHub)" <gi...@apache.org>.
Gerrrr commented on PR #176:
URL: https://github.com/apache/otava/pull/176#issuecomment-5470394103

   Thanks for the review @MrlixiangWE! This is a valid suggestion; fixed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@otava.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Make external service clients optional [otava]

Posted by "henrikingo (via GitHub)" <gi...@apache.org>.
henrikingo commented on PR #176:
URL: https://github.com/apache/otava/pull/176#issuecomment-5523965705

   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.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@otava.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Make external service clients optional [otava]

Posted by "Gerrrr (via GitHub)" <gi...@apache.org>.
Gerrrr commented on PR #176:
URL: https://github.com/apache/otava/pull/176#issuecomment-5466731370

   @henrikingo 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@otava.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Make external service clients optional [otava]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #176:
URL: https://github.com/apache/otava/pull/176#discussion_r3887457570


##########
docs/GRAFANA.md:
##########
@@ -22,6 +22,14 @@
 Change points found by `analyze` can be exported
 as Grafana annotations using the `--update-grafana` flag:
 
+## Installation

Review Comment:
   The new section interrupts the preceding sentence immediately after its colon, leaving the usage example detached from that sentence. Put the installation section before the usage introduction so the heading structure and sentence read correctly.



##########
otava/influxdb.py:
##########
@@ -51,7 +64,7 @@ def __init__(self, config: InfluxDBConfig):
     @property
     def client(self) -> InfluxDBClient3:
         if self._client is None:
-            self._client = InfluxDBClient3(
+            self._client = _influxdb_client_class()(

Review Comment:
   The missing-extra exception raised here is swallowed by `InfluxDBImporter.fetch_data`'s blanket `except Exception` (`otava/importer.py:876-879`) and rewrapped as `DataImportError`. `script_main` catches that inside the per-test loop, so `otava analyze` without `[influxdb]` logs the message but exits successfully instead of reaching the new missing-dependency exit handler, unlike the other integrations. Re-raise `MissingOptionalDependencyError` before the broad wrapper and cover the CLI exit status.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@otava.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Make external service clients optional [otava]

Posted by "Gerrrr (via GitHub)" <gi...@apache.org>.
Gerrrr commented on PR #176:
URL: https://github.com/apache/otava/pull/176#issuecomment-5521605017

   @henrikingo I am going to merge this PR and let you comment async. As usual, I'll be happy to fix-forward any feedback.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@otava.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Make external service clients optional [otava]

Posted by "MrlixiangWE (via GitHub)" <gi...@apache.org>.
MrlixiangWE commented on PR #176:
URL: https://github.com/apache/otava/pull/176#issuecomment-5468884016

   @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 `core_install_smoke.py` passes against a freshly built wheel on all five.
   
   `pytz` is imported at runtime in `util.py`, `data_selector.py`, `grafana.py`, `slack.py` and `main.py`, but a default install only gets it through `dateparser`. Declare it in `[project.dependencies]`?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@otava.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Make external service clients optional [otava]

Posted by "Gerrrr (via GitHub)" <gi...@apache.org>.
Gerrrr commented on code in PR #176:
URL: https://github.com/apache/otava/pull/176#discussion_r3888455305


##########
docs/GRAFANA.md:
##########
@@ -22,6 +22,14 @@
 Change points found by `analyze` can be exported
 as Grafana annotations using the `--update-grafana` flag:
 
+## Installation

Review Comment:
   Fixed in f5cc644. The Installation section now comes first, and the usage introduction remains directly attached to its command example under the Usage heading.



##########
otava/influxdb.py:
##########
@@ -51,7 +64,7 @@ def __init__(self, config: InfluxDBConfig):
     @property
     def client(self) -> InfluxDBClient3:
         if self._client is None:
-            self._client = InfluxDBClient3(
+            self._client = _influxdb_client_class()(

Review Comment:
   Fixed in f5cc644. `InfluxDBImporter.fetch_data` now re-raises `MissingOptionalDependencyError` before its general client-error wrapper, allowing the CLI handler to exit with status 1. Added a regression test covering the exit status and actionable `[influxdb]` installation message.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@otava.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org