Skip to content

[CDF-27582] 🚨Check instance space existence. #2799

Merged
doctrino merged 6 commits intomainfrom
migration-validate-space
Mar 30, 2026
Merged

[CDF-27582] 🚨Check instance space existence. #2799
doctrino merged 6 commits intomainfrom
migration-validate-space

Conversation

@doctrino
Copy link
Copy Markdown
Contributor

Description

Please describe the change you have made.

Bump

  • Patch
  • Skip

Changelog

Improved

  • [alpha] When running cdf migrate assets/events/files/timeseries/annotations, Toolkit will now check that the target instance space(s) exist before starting.

@doctrino doctrino requested review from a team as code owners March 27, 2026 11:55
@gemini-code-assist
Copy link
Copy Markdown
Contributor

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 👍 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.

@doctrino doctrino enabled auto-merge (squash) March 27, 2026 11:55
@doctrino
Copy link
Copy Markdown
Contributor Author

/gemini review

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 a validation step in the stream_data method to ensure that instance spaces exist in CDF before migration begins. Feedback identifies a potential runtime error due to SpaceId potentially lacking a hash implementation for set operations and points out an inefficient duplicate API call that could be optimized by passing the retrieved space source to downstream methods.

else:
raise ToolkitNotImplementedError(f"Selector {type(selector)} is not supported for stream_data")
existing = self.client.tool.spaces.retrieve(instance_spaces)
if missing := set(instance_spaces).difference({item.as_id() for item in existing}):
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.

critical

This line, and line 94 (list({SpaceId(...)})), rely on SpaceId being hashable to be used in a set. However, the SpaceId class does not appear to have a __hash__ method defined, unlike other similar identifier classes in the project (e.g., ViewNoVersionId). This could lead to a TypeError at runtime if SpaceId is not hashable by default in your Pydantic configuration. Please verify that SpaceId is hashable. If not, you should implement __hash__ on it.

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.

It is frozen and thus hashable.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 27, 2026

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
39560 33453 85% 80% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
cognite_toolkit/_cdf_tk/commands/_migrate/migration_io.py 85% 🟢
TOTAL 85% 🟢

updated for commit: f23ffd8 by action🐍

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 27, 2026

Codecov Report

❌ Patch coverage is 85.71429% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.56%. Comparing base (2db8d81) to head (f23ffd8).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
..._toolkit/_cdf_tk/commands/_migrate/migration_io.py 85.71% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2799      +/-   ##
==========================================
- Coverage   84.57%   84.56%   -0.01%     
==========================================
  Files         447      447              
  Lines       39552    39560       +8     
==========================================
+ Hits        33450    33453       +3     
- Misses       6102     6107       +5     
Files with missing lines Coverage Δ
..._toolkit/_cdf_tk/commands/_migrate/migration_io.py 84.89% <85.71%> (-0.25%) ⬇️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@doctrino doctrino merged commit 5c2354e into main Mar 30, 2026
14 checks passed
@doctrino doctrino deleted the migration-validate-space branch March 30, 2026 07:31
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