Skip to content

refactor: simplify WriteApi request path - #237

Open
bednar wants to merge 6 commits into
mainfrom
codex/fix-229-write-api-request-path
Open

refactor: simplify WriteApi request path#237
bednar wants to merge 6 commits into
mainfrom
codex/fix-229-write-api-request-path

Conversation

@bednar

@bednar bednar commented Aug 25, 2026

Copy link
Copy Markdown
Member

Summary

  • Replace generated OpenAPI request plumbing with focused request construction and direct RestClient transport.
  • Preserve v2/v3 endpoint selection, precision conversion, gzip, timeout, retry, and error translation behavior.
  • Update request-path and Polars tests to assert the RestClient boundary.

Testing

  • venv/bin/python -m pytest tests -q -m 'not integration' — 174 passed, 29 deselected
  • venv/bin/flake8 influxdb_client_3/write_client/client/write_api.py tests/test_write_api.py tests/test_polars.py
  • Integration marker suite: 29 skipped because the integration environment is unavailable.

Closes #229

@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.43%. Comparing base (d846df5) to head (b65e6d0).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #237      +/-   ##
==========================================
+ Coverage   86.90%   87.43%   +0.53%     
==========================================
  Files          28       28              
  Lines        2084     2030      -54     
==========================================
- Hits         1811     1775      -36     
+ Misses        273      255      -18     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the internal WriteApi write path to construct v2/v3 write requests directly and send them through the internal RestClient, removing leftover generated OpenAPI request plumbing while preserving existing write behaviors and updating tests to assert the RestClient boundary.

Changes:

  • Replace generated-style request preparation (call_api / _post_write_prepare / serialization helpers) with _build_write_request(...) + _request(...) using RestClient.
  • Update unit tests (including Polars) to validate request construction and mock rest_client.request instead of call_api.
  • Update the changelog to mention the additional simplification of the WriteApi request path.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
influxdb_client_3/write_client/client/write_api.py Removes generated OpenAPI request plumbing and routes write requests through _build_write_request + RestClient.
tests/test_write_api.py Adds request-matrix coverage for _build_write_request and adjusts mocks to the RestClient boundary.
tests/test_polars.py Updates Polars write tests to mock/assert rest_client.request calls and payload forwarding.
CHANGELOG.md Notes further write-path simplification via direct RestClient request construction.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread influxdb_client_3/write_client/client/write_api.py Outdated
Comment thread influxdb_client_3/write_client/client/write_api.py Outdated
Comment thread tests/test_write_api.py
Comment thread influxdb_client_3/write_client/client/write_api.py

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

influxdb_client_3/write_client/client/write_api.py:690

  • _build_write_request raises errors that say "when calling _post_write", but the validation is happening inside _build_write_request. Using the correct method name makes errors clearer, especially when this helper is called directly in tests or from post_write_async.
        if org is None:
            raise ValueError("Missing the required parameter `org` when calling `_post_write`")
        if bucket is None:
            raise ValueError("Missing the required parameter `bucket` when calling `_post_write`")

Comment thread influxdb_client_3/write_client/client/write_api.py
Comment thread influxdb_client_3/write_client/client/write_api.py
Comment thread influxdb_client_3/write_client/client/write_api.py

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

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.

Simplify the WriteApi request path after removing the OpenAPI client

2 participants