cognite-sdk-python
cognite-sdk-python copied to clipboard
fix(sequences): accept list ids/external_ids in retrieve_last_row (#2266)
Fixes #2266.
Summary
SequencesDataAPI.retrieve_last_row now accepts:
id: int | typing.Sequence[int] | Noneexternal_id: str | SequenceNotStr[str] | None
Behavior:
- Single identifier → returns
SequenceRows - Multiple identifiers → aggregates into
SequenceRowsList
Rationale
Docs and docstring say lists are supported, but the implementation only handled single values. This aligns code with docs and mirrors the list semantics used elsewhere.
Implementation notes
- Normalize identifiers via
IdentifierSequence.load(...) - For multiple identifiers, call
/sequences/data/latestper identifier and aggregate usingexecute_tasks(...) - Keep single-identifier path unchanged
- Updated docstring (types + return description)
Testing done
- Unit tests added:
tests/tests_unit/test_api/test_sequences_data.py- list of
external_id→ returnsSequenceRowsList, 2 HTTP calls - single
id→ returnsSequenceRows, 1 HTTP call
- list of
- Local checks:
poetry run pytest -q tests/tests_unit -k retrieve_last_rowpoetry run pre-commit run --all-files(ruff, ruff-format, mypy, custom checks, pydoclint) all pass
Note that the integration tests were not run locally; CI should cover these.
Backwards compatibility
- No breaking changes: single-identifier behavior unchanged
- Expanded accepted types only
Files changed
cognite/client/_api/sequences.pytests/tests_unit/test_api/test_sequences_data.py
Checklist
- [x] Tests added/updated
- [x] Docstring updated (docs are generated from docstrings)
Using Gemini Code Assist
The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.
| Feature | Command | Description |
|---|
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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.
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 :thumbsup: and :thumbsdown: 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.