Skip to content

feat(Data Modeling): support usedFor=record on containers#2621

Open
evertoncolling wants to merge 7 commits into
masterfrom
used-for-records
Open

feat(Data Modeling): support usedFor=record on containers#2621
evertoncolling wants to merge 7 commits into
masterfrom
used-for-records

Conversation

@evertoncolling
Copy link
Copy Markdown
Contributor

Description

This PR adds support for creating and querying records containers via the SDK.

  • Widen ContainerApply.used_for and Container.used_for to also accept "record", aligning with the v1 API spec (UsedFor enum = node | edge | record | all). Exposes a new public ContainerUsedFor type alias.
  • Add a used_for filter to containers.list() and containers(...) (iterate), forwarded as the usedFor query parameter on GET /models/containers. Accepts a single value or a sequence.

Checklist:

  • Tests added/updated.
  • Documentation updated. Documentation is generated from docstrings - these must be updated according to your change.
    If a new method has been added it should be referenced in cognite.rst in order to generate docs based on its docstring.
  • The PR title follows the Conventional Commit spec.

@evertoncolling
Copy link
Copy Markdown
Contributor Author

This one would close #2391 (which was based on v7)

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.03%. Comparing base (29bb729) to head (3f04056).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2621   +/-   ##
=======================================
  Coverage   93.03%   93.03%           
=======================================
  Files         486      486           
  Lines       49577    49615   +38     
=======================================
+ Hits        46122    46160   +38     
  Misses       3455     3455           
Files with missing lines Coverage Δ
cognite/client/_api/data_modeling/containers.py 98.14% <100.00%> (ø)
...gnite/client/_sync_api/data_modeling/containers.py 97.36% <ø> (ø)
...nite/client/data_classes/data_modeling/__init__.py 100.00% <ø> (ø)
...te/client/data_classes/data_modeling/containers.py 97.68% <100.00%> (+0.06%) ⬆️
...nit/test_api/test_data_modeling/test_containers.py 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@evertoncolling evertoncolling marked this pull request as ready for review May 12, 2026 14:06
@evertoncolling evertoncolling requested review from a team as code owners May 12, 2026 14:06
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the ability to filter containers by the 'used_for' attribute in the Data Modeling API. It adds a new 'ContainerUsedFor' type (supporting 'node', 'edge', 'record', and 'all'), updates the 'list' and 'call' methods in both async and sync container APIs to accept this filter, and includes corresponding unit tests. I have no feedback to provide.

Comment thread cognite/client/data_classes/data_modeling/containers.py
Comment thread cognite/client/data_classes/data_modeling/containers.py Outdated
Comment thread cognite/client/_sync_api/data_modeling/containers.py
Comment thread cognite/client/_sync_api/data_modeling/containers.py
@erlendvollset
Copy link
Copy Markdown
Contributor

🦄

erlendvollset
erlendvollset previously approved these changes May 16, 2026
Filter containers by `used_for`:

>>> record_containers = client.data_modeling.containers.list(used_for="record")
>>> all_containers = client.data_modeling.containers.list(used_for=["all", "record"])
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.

@evertoncolling Won't this exclude "node only" and "edge only" containers? If yes, then we can't name this all_containers, it's just too confusing imo.

Can we, in the SDK, go with node_and_edge instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's true!!!

Even I get confused by this from time to time. But I dont think it would be a good idea to "patch" the name of the filter in the SDK. I would rather align with the API, and document it clearly in the docstrings/comments.

I will fix this in a new commit :)

Irrespective of this PR, we may be able to improve this in the API in the future, paving a way for less confusion. That would need some good discussions, based on how do we see the evolution of DMS and Records, the recommended usage patterns, etc.

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