Skip to content

refactor: simplify WriteApi request path - #237

Merged
bednar merged 9 commits into
mainfrom
codex/fix-229-write-api-request-path
Sep 1, 2026
Merged

refactor: simplify WriteApi request path#237
bednar merged 9 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 83.59%. Comparing base (4b3549c) to head (554d0cd).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #237      +/-   ##
==========================================
- Coverage   86.90%   83.59%   -3.31%     
==========================================
  Files          28       28              
  Lines        2084     2030      -54     
==========================================
- Hits         1811     1697     -114     
- Misses        273      333      +60     

☔ 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.

@karel-rehor
karel-rehor self-requested a review August 31, 2026 08:44

@karel-rehor karel-rehor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A question regarding how this is documented in CHANGELOG.md needs to be clarified. Will continue with reviewing other changes.

Comment thread CHANGELOG.md Outdated
### Breaking Changes

1. [#217](https://github.com/InfluxCommunity/influxdb3-python/pull/217): Makes the writing API simpler and more consistent with other v3 clients.
1. [#217](https://github.com/InfluxCommunity/influxdb3-python/pull/217), [#237](https://github.com/InfluxCommunity/influxdb3-python/pull/237): Makes the writing API simpler and more consistent with other v3 clients.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see the changes in this PR are being documented as part of release 0.21.0, which was released last week. Are we planning to re-release 0.21.0? Or should this PR and its changes be added to the 0.22.0 release cycle?

This addendum to last week's release could lead users to understand that functionality has changed in 0.21.0, when in fact the change will only be available in 0.22.0.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed - updated 0.22.0 changelog.

bednar added 2 commits August 31, 2026 13:18
Added bug fix details for version 0.22.0 and updated breaking changes section.
Further simplifies the WriteApi request path by constructing v2/v3 requests directly through RestClient, while preserving existing write behavior.
@bednar
bednar requested a review from karel-rehor August 31, 2026 11:19

@karel-rehor karel-rehor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tests pass locally. These changes make reading the Write API cleaner and clearer.

Looks good to me. 🚴 🏁

N.B. just noticed loss of test coverage. Maybe we want to add one or two new unit tests. But not a blocker for me.

@bednar
bednar merged commit d2fc4da into main Sep 1, 2026
15 of 16 checks passed
@bednar
bednar deleted the codex/fix-229-write-api-request-path branch September 1, 2026 02:02
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

3 participants