add async subject and source read methods to AsyncERClient#27
Open
JoshuaVulcan wants to merge 4 commits intomainfrom
Open
add async subject and source read methods to AsyncERClient#27JoshuaVulcan wants to merge 4 commits intomainfrom
JoshuaVulcan wants to merge 4 commits intomainfrom
Conversation
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>
Contributor
There was a problem hiding this comment.
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(), andget_source_by_id()toAsyncERClient. - 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
get_subjects(),get_subject(),get_subject_tracks(),get_sources(), andget_source_by_id()toAsyncERClient, achieving feature parity with the syncERClientfor subject and source read operations.get_sources()is implemented as a paginated async generator using the existing_get_data()infrastructure, consistent withget_events()andget_observations().subject_group,include_inactive, date range for tracks).Test Plan
subject_group,include_inactive,since/until)get_sources)ERClient*exceptionsConnectTimeout,ReadTimeout) raisingERClientExceptionJira
Resolves ERA-12652