Skip to content

add async subject and source read methods to AsyncERClient#27

Open
JoshuaVulcan wants to merge 4 commits intomainfrom
ERA-12652/async-subject-source-read
Open

add async subject and source read methods to AsyncERClient#27
JoshuaVulcan wants to merge 4 commits intomainfrom
ERA-12652/async-subject-source-read

Conversation

@JoshuaVulcan
Copy link
Contributor

@JoshuaVulcan JoshuaVulcan commented Feb 10, 2026

Summary

  • Adds get_subjects(), get_subject(), get_subject_tracks(), get_sources(), and get_source_by_id() to AsyncERClient, achieving feature parity with the sync ERClient for subject and source read operations.
  • get_sources() is implemented as a paginated async generator using the existing _get_data() infrastructure, consistent with get_events() and get_observations().
  • All methods mirror the parameter signatures of their sync counterparts (e.g., subject_group, include_inactive, date range for tracks).

Test Plan

  • 31 new tests added covering:
    • Successful responses for all 5 new methods
    • Empty/no-result scenarios
    • Query parameter passing and filtering (e.g., subject_group, include_inactive, since/until)
    • Pagination across multiple pages (get_sources)
    • HTTP error handling (401, 403, 404) raising appropriate ERClient* exceptions
    • Network errors (ConnectTimeout, ReadTimeout) raising ERClientException
  • All 121 tests pass (90 existing + 31 new), zero regressions

Jira

Resolves ERA-12652

Add get_subjects(), get_subject(), get_subject_tracks(), get_sources()
(paginated async generator), and get_source_by_id() to AsyncERClient,
achieving parity with the sync ERClient's existing read methods.

Includes 31 new tests covering success, pagination, error handling,
parameter filtering, and network failure scenarios.

Resolves ERA-12652

Co-authored-by: Cursor <cursoragent@cursor.com>
@JoshuaVulcan JoshuaVulcan added autoreviewing PR is currently being auto-reviewed and removed autoreviewing PR is currently being auto-reviewed labels Feb 11, 2026
JoshuaVulcan and others added 2 commits February 11, 2026 17:35
Match PR #24 pattern so mocks match client request URL after #23.
Add docs/AGENT_LEARNINGS.md for merge and test patterns.

Co-authored-by: Cursor <cursoragent@cursor.com>
@JoshuaVulcan JoshuaVulcan requested a review from a team as a code owner February 12, 2026 01:38
Copy link
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.

Pull request overview

Adds async subject/source read APIs to AsyncERClient to match the sync client’s subject/source read capabilities, including paginated async iteration for sources.

Changes:

  • Added get_subjects(), get_subject(), get_subject_tracks(), get_sources(), and get_source_by_id() to AsyncERClient.
  • Added async tests covering success, empty results, query params, pagination, and error handling for the new endpoints.
  • Added an agent-focused documentation note capturing async test mocking patterns and merge guidance.

Reviewed changes

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

Show a summary per file
File Description
erclient/client.py Adds the new async subject/source read methods and wires get_sources() into existing _get_data() pagination/batching.
tests/async_client/test_get_subjects.py New tests for get_subjects() and get_subject() (params + error cases).
tests/async_client/test_get_subject_tracks.py New tests for get_subject_tracks() including date-range param behavior and errors.
tests/async_client/test_get_sources.py New tests for paginated get_sources() and get_source_by_id() (success + error cases).
docs/AGENT_LEARNINGS.md Adds internal notes about merge/test patterns and respx base URL usage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

"""
return await self._get(f"spatialfeaturegroup/{feature_group_id}", params={})

async def get_subjects(self, **kwargs):

## 5. Strategy and merge order

- Full merge strategy and wave order: see **ER_CLIENT_MERGE_STRATEGY_RECOMMENDATION.md** in the DAS repo (`/Users/joshuak/Projects/das/`) if available, or the same filename in notes.
Comment on lines +1662 to +1677
async def get_sources(self, **kwargs):
"""
Returns an async generator to iterate over sources (paginated).

Optional kwargs:
page_size: Change the page size. Default 100.
batch_size: The generator returns sources in batches (list)
instead of one by one. Default 0 (means no batching).
"""
page_size = kwargs.get('page_size', 100)
batch_size = kwargs.get('batch_size', 0)
params = {'page_size': page_size}
if batch_size and page_size:
params['page_size'] = batch_size
async for source in self._get_data(endpoint='sources', params=params, batch_size=batch_size):
yield source
Comment on lines +1667 to +1675
page_size: Change the page size. Default 100.
batch_size: The generator returns sources in batches (list)
instead of one by one. Default 0 (means no batching).
"""
page_size = kwargs.get('page_size', 100)
batch_size = kwargs.get('batch_size', 0)
params = {'page_size': page_size}
if batch_size and page_size:
params['page_size'] = batch_size
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.

2 participants