Skip to content

Add async support for Dataverse SDK#171

Open
abelmilash-msft wants to merge 28 commits into
mainfrom
users/abelmilash/async-phase2
Open

Add async support for Dataverse SDK#171
abelmilash-msft wants to merge 28 commits into
mainfrom
users/abelmilash/async-phase2

Conversation

@abelmilash-msft
Copy link
Copy Markdown
Contributor

  • Introduces the complete aio/ async package mirroring the sync SDK:
    • HTTP layer: _AsyncHttpClient wrapping aiohttp with identical retry, backoff, and timeout logic
    • Auth: _AsyncAuthManager for async Azure Identity token acquisition
    • OData client: _AsyncODataClient — full CRUD, SQL-over-API, table/column metadata, file upload, and relationship operations
    • Batch: _AsyncBatchClient with _SyncResponseWrapper bridging the async HTTP response to the shared sync multipart parser in _BatchBase
    • Operation namespaces: records, tables, query, files, batch, dataframe — all mirroring their sync counterparts
    • Top-level client: AsyncDataverseClient with lazy init, async context manager, and session lifecycle management
  • Adds pytest-asyncio (asyncio_mode = auto) and aiohttp as an optional dependency (pip install PowerPlatform-Dataverse-Client[async]).

Test plan

  • 1,758 unit tests pass (389 new async tests, ~95% coverage of the async layer)
  • black --check passes on all files

@abelmilash-msft abelmilash-msft force-pushed the users/abelmilash/async-phase2 branch from e491241 to b848324 Compare May 11, 2026 23:53
@abelmilash-msft abelmilash-msft marked this pull request as ready for review May 12, 2026 06:29
@abelmilash-msft abelmilash-msft requested a review from a team as a code owner May 12, 2026 06:29
Copilot AI review requested due to automatic review settings May 12, 2026 06:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

@abelmilash-msft abelmilash-msft force-pushed the users/abelmilash/async-phase2 branch from b32987a to ad9297e Compare May 14, 2026 17:28
Comment thread .azdo/ci-pr.yaml
Comment thread .azdo/ci-pr.yaml
Comment thread .azdo/ci-pr.yaml
Comment thread .azdo/ci-pr.yaml
Comment thread .azdo/ci-pr.yaml
Comment thread .azdo/ci-pr.yaml
@abelmilash-msft abelmilash-msft force-pushed the users/abelmilash/async-phase2 branch from f52d6b8 to 8ff97e4 Compare May 15, 2026 04:04
Comment thread .azdo/ci-pr.yaml
@abelmilash-msft abelmilash-msft force-pushed the users/abelmilash/async-phase2 branch from 8ff97e4 to a23cecd Compare May 15, 2026 04:26
Comment thread .azdo/ci-pr.yaml
@abelmilash-msft abelmilash-msft force-pushed the users/abelmilash/async-phase2 branch from a23cecd to 4a319bf Compare May 15, 2026 05:10
Comment thread .azdo/ci-pr.yaml
@abelmilash-msft abelmilash-msft force-pushed the users/abelmilash/async-phase2 branch from 4a319bf to 68e705a Compare May 15, 2026 05:37
Comment thread .azdo/ci-pr.yaml
Comment thread .azdo/ci-pr.yaml
@abelmilash-msft abelmilash-msft force-pushed the users/abelmilash/async-phase2 branch from 500c19f to 55e3359 Compare May 15, 2026 05:44
Comment thread .azdo/ci-pr.yaml
Comment thread .azdo/ci-pr.yaml
@abelmilash-msft abelmilash-msft force-pushed the users/abelmilash/async-phase2 branch from a374227 to 602c990 Compare May 18, 2026 16:34
Comment thread .azdo/ci-pr.yaml
Abel Milash and others added 2 commits May 18, 2026 10:10
- Reset to main (which is now PR #175)
- Re-apply: _ODataBase, _BatchBase, _QueryBuilderBase, _BatchContext Protocol,
  _operation_context in base, Self type annotation
- Re-export multipart helpers from _batch.py for test compatibility
- Update test_sql_parse.py patch target to _odata_base.urlparse

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Reset to main via refactoring branch
- Restore full async implementation: aio/ client, HTTP, batch, OData,
  relationships, upload, query builder, fetchxml, operations, tests, examples
- Re-export multipart helpers from _batch.py for test compatibility
- All 2166 tests passing

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@abelmilash-msft abelmilash-msft force-pushed the users/abelmilash/async-phase2 branch from 602c990 to a4f69cd Compare May 18, 2026 17:11
Comment thread .azdo/ci-pr.yaml
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread .azdo/ci-pr.yaml
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread .azdo/ci-pr.yaml
Rename `r` to `response` for consistency with _async_http.py.
Replace multi-pass comprehension + zip in _resolve_table_remove_columns
with a plain for loop matching the sync _batch.py structure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread .azdo/ci-pr.yaml
Replace broad try/except around r.json() with hasattr guard, matching
the sync FetchXmlQuery pattern. Remove the now-obsolete test that
verified the exception-swallowing behavior.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread .azdo/ci-pr.yaml
Moves fetchxml() after sql_columns() to match the order in the sync
QueryOperations: builder, sql, fetchxml, sql_columns, odata_*.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread .azdo/ci-pr.yaml
Order now matches sync exactly: builder, sql, fetchxml, sql_columns, odata_expands.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread .azdo/ci-pr.yaml
Add missing "Use for SQL-JOIN scenarios..." sentence, expand :return:
description, add link-entity JOIN example, align Eager/Lazy comment
wording, and add the two inline implementation comments from sync.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread .azdo/ci-pr.yaml
…ession on auth failure

- functional_testing.py: replace batch.records.get() with batch.records.retrieve();
  close client session on auth failure to avoid unclosed session warning
- sql_examples.py: remove odata_select/odata_expand/odata_bind calls (deprecated
  sync-only helpers not available on async client); keep only odata_expands()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread .azdo/ci-pr.yaml
…ontent

_AsyncResponse buffers the body in ._body; it has no .content attribute
(unlike requests.Response used by the sync client).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread .azdo/ci-pr.yaml
…replace downloads

Two download paths after replace uploads still used resp_r.content and
resp_rc.content instead of ._body, causing AttributeError.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread .azdo/ci-pr.yaml
Validates 7 properties of the async client against a live environment:
1. Non-blocking reads — canary confirms event loop stays free during GETs
2. Read throughput — concurrent reads via gather() beat sequential
3. Write concurrency — concurrent POSTs beat sequential (POST path)
4. Pagination non-blocking — async generators yield between page fetches
5. Mixed fan-out — different op types run simultaneously without serialization
6. Error resilience — one failure in gather() does not kill other calls
7. Real-world fan-out — metadata for multiple tables fetched in parallel

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread .azdo/ci-pr.yaml
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Warning

ADO PR pipeline YAML change detected

This PR modifies .azdo/ci-pr.yaml. After merge, Azure DevOps may disable or require approval for the PR validation pipeline.

Action required (post-merge): Re-enable / approve the updated YAML for:

Please resolve this comment after completing the post-merge steps.

Each test now has a brief explanation of what it runs, what property
it validates, and what a failure would indicate.
Also clarifies that speedup measures async-sequential vs async-concurrent,
not async vs sync.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread .azdo/ci-pr.yaml
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Warning

ADO PR pipeline YAML change detected

This PR modifies .azdo/ci-pr.yaml. After merge, Azure DevOps may disable or require approval for the PR validation pipeline.

Action required (post-merge): Re-enable / approve the updated YAML for:

Please resolve this comment after completing the post-merge steps.

Abel Milash and others added 2 commits May 20, 2026 11:30
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread .azdo/ci-pr.yaml
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Warning

ADO PR pipeline YAML change detected

This PR modifies .azdo/ci-pr.yaml. After merge, Azure DevOps may disable or require approval for the PR validation pipeline.

Action required (post-merge): Re-enable / approve the updated YAML for:

Please resolve this comment after completing the post-merge steps.

Comment thread .azdo/ci-pr.yaml
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Warning

ADO PR pipeline YAML change detected

This PR modifies .azdo/ci-pr.yaml. After merge, Azure DevOps may disable or require approval for the PR validation pipeline.

Action required (post-merge): Re-enable / approve the updated YAML for:

Please resolve this comment after completing the post-merge steps.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread .azdo/ci-pr.yaml
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Warning

ADO PR pipeline YAML change detected

This PR modifies .azdo/ci-pr.yaml. After merge, Azure DevOps may disable or require approval for the PR validation pipeline.

Action required (post-merge): Re-enable / approve the updated YAML for:

Please resolve this comment after completing the post-merge steps.

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.

3 participants