feat: add support for the Streams API#2519
feat: add support for the Streams API#2519evertoncolling wants to merge 5 commits intopysdk-release-v8from
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## pysdk-release-v8 #2519 +/- ##
====================================================
- Coverage 93.48% 93.46% -0.03%
====================================================
Files 478 483 +5
Lines 48118 48429 +311
====================================================
+ Hits 44983 45262 +279
- Misses 3135 3167 +32
🚀 New features to boost your workflow:
|
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Data Modeling module by integrating the Streams API. This new feature allows users to programmatically manage data streams, providing capabilities for creating new streams, fetching existing ones by ID, listing all available streams, and deleting them. The changes encompass both the core asynchronous client and its synchronous wrapper, along with new data structures to represent stream configurations and lifecycle settings, ensuring a complete and robust implementation. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces support for the Streams API, a new feature in the Data Modeling module. The changes are well-structured, adding asynchronous and synchronous API clients, corresponding data classes, comprehensive unit and integration tests, and documentation. The implementation aligns with the existing SDK patterns. The main issue identified is that the code examples in the asynchronous API's docstrings incorrectly demonstrate synchronous usage. This is a high-severity issue as it can mislead users. I have provided specific suggestions to correct these examples to reflect proper asynchronous patterns.
| >>> from cognite.client import CogniteClient, AsyncCogniteClient | ||
| >>> client = CogniteClient() | ||
| >>> # async_client = AsyncCogniteClient() # another option | ||
| >>> res = client.data_modeling.streams.retrieve(external_id="my_stream") | ||
|
|
||
| Retrieve a stream with statistics: | ||
|
|
||
| >>> res = client.data_modeling.streams.retrieve(external_id="my_stream", include_statistics=True) |
There was a problem hiding this comment.
The code examples for retrieve demonstrate synchronous client usage, but this is an asynchronous method. The examples should use AsyncCogniteClient and await to correctly illustrate asynchronous usage. This pattern of incorrect examples is present for all methods in this file.
| >>> from cognite.client import CogniteClient, AsyncCogniteClient | |
| >>> client = CogniteClient() | |
| >>> # async_client = AsyncCogniteClient() # another option | |
| >>> res = client.data_modeling.streams.retrieve(external_id="my_stream") | |
| Retrieve a stream with statistics: | |
| >>> res = client.data_modeling.streams.retrieve(external_id="my_stream", include_statistics=True) | |
| >>> from cognite.client import AsyncCogniteClient | |
| >>> async_client = AsyncCogniteClient() | |
| >>> res = await async_client.data_modeling.streams.retrieve(external_id="my_stream") | |
| Retrieve a stream with statistics: | |
| >>> res = await async_client.data_modeling.streams.retrieve(external_id="my_stream", include_statistics=True) |
| >>> from cognite.client import CogniteClient, AsyncCogniteClient | ||
| >>> client = CogniteClient() | ||
| >>> # async_client = AsyncCogniteClient() # another option | ||
| >>> client.data_modeling.streams.delete(external_id="my_stream") |
There was a problem hiding this comment.
The code example for delete demonstrates synchronous client usage, but this is an asynchronous method. The example should be updated to use AsyncCogniteClient and await.
| >>> from cognite.client import CogniteClient, AsyncCogniteClient | |
| >>> client = CogniteClient() | |
| >>> # async_client = AsyncCogniteClient() # another option | |
| >>> client.data_modeling.streams.delete(external_id="my_stream") | |
| >>> from cognite.client import AsyncCogniteClient | |
| >>> async_client = AsyncCogniteClient() | |
| >>> await async_client.data_modeling.streams.delete(external_id="my_stream") |
| >>> from cognite.client import CogniteClient, AsyncCogniteClient | ||
| >>> client = CogniteClient() | ||
| >>> # async_client = AsyncCogniteClient() # another option | ||
| >>> stream_list = client.data_modeling.streams.list() |
There was a problem hiding this comment.
The code example for list demonstrates synchronous client usage, but this is an asynchronous method. The example should be updated to use AsyncCogniteClient and await.
| >>> from cognite.client import CogniteClient, AsyncCogniteClient | |
| >>> client = CogniteClient() | |
| >>> # async_client = AsyncCogniteClient() # another option | |
| >>> stream_list = client.data_modeling.streams.list() | |
| >>> from cognite.client import AsyncCogniteClient | |
| >>> async_client = AsyncCogniteClient() | |
| >>> stream_list = await async_client.data_modeling.streams.list() |
| >>> from cognite.client import CogniteClient, AsyncCogniteClient | ||
| >>> from cognite.client.data_classes.data_modeling import StreamWrite, StreamWriteSettings | ||
| >>> client = CogniteClient() | ||
| >>> # async_client = AsyncCogniteClient() # another option | ||
| >>> stream = StreamWrite( | ||
| ... external_id="my_stream", | ||
| ... settings=StreamWriteSettings(template_name="ImmutableTestStream") | ||
| ... ) | ||
| >>> res = client.data_modeling.streams.create(stream) |
There was a problem hiding this comment.
The code example for create demonstrates synchronous client usage, but this is an asynchronous method. The example should be updated to use AsyncCogniteClient and await.
| >>> from cognite.client import CogniteClient, AsyncCogniteClient | |
| >>> from cognite.client.data_classes.data_modeling import StreamWrite, StreamWriteSettings | |
| >>> client = CogniteClient() | |
| >>> # async_client = AsyncCogniteClient() # another option | |
| >>> stream = StreamWrite( | |
| ... external_id="my_stream", | |
| ... settings=StreamWriteSettings(template_name="ImmutableTestStream") | |
| ... ) | |
| >>> res = client.data_modeling.streams.create(stream) | |
| >>> from cognite.client import AsyncCogniteClient | |
| >>> from cognite.client.data_classes.data_modeling import StreamWrite, StreamWriteSettings | |
| >>> async_client = AsyncCogniteClient() | |
| >>> stream = StreamWrite( | |
| ... external_id="my_stream", | |
| ... settings=StreamWriteSettings(template_name="ImmutableTestStream") | |
| ... ) | |
| >>> res = await async_client.data_modeling.streams.create(stream) |
Description
Adds support for the Streams API in the Data Modeling module, enabling users to create, retrieve, list, and delete streams.
Checklist:
If a new method has been added it should be referenced in cognite.rst in order to generate docs based on its docstring.