Skip to content

Add CLI parameters for cdf data respace plan/execute#2522

Merged
ivansurif merged 6 commits intomainfrom
feature/data-respace-cli-params
Feb 17, 2026
Merged

Add CLI parameters for cdf data respace plan/execute#2522
ivansurif merged 6 commits intomainfrom
feature/data-respace-cli-params

Conversation

@ivansurif
Copy link
Contributor

@ivansurif ivansurif commented Feb 15, 2026

Description

Add CLI parameters for cdf data respace plan/execute

Define Typer-annotated arguments and options for both subcommands:

  • plan: csv_file (positional), --output-file/-o (default: respace_plan.json)
  • execute: plan_file (positional), --backup-dir/-b (required), --dry-run/-d

Add RespaceMapping and RespaceMappingList data classes for future CSV
input parsing (columns: sourceSpace, externalId, targetSpace). External
ID is preserved — only the space changes. These classes are not yet
wired into the command logic.

Bump

  • Patch
  • Skip

Changelog

Changed

  • cognite_toolkit/_cdf_tk/apps/_respace_app.py

What changed: The respace_plan() and respace_execute() methods previously had no parameters. They now have full Typer-annotated CLI parameter definitions:

  • respace_plan()
    Added two parameters:
    • csv_file: required positional argument pointing to an existing CSV file. Typer validates that the file exists, is a file (not a directory), and resolves it to an absolute path. Help text documents the expected columns: sourceSpace, externalId, targetSpace.
    • output_file: optional named option (--output-file / -o) defaulting to respace_plan.json in the current working directory.

Both parameters are forwarded to RespaceCommand.plan().

  • respace_execute()
    Added three parameters:
    • plan_file: required positional argument pointing to an existing JSON plan file, with the same path validation as csv_file.
    • backup_dir: required named option (--backup-dir / -b). No exists check since the user might pass a directory that doesn't exist yet. The execute command would create it during execution.
    • dry_run: optional boolean flag (--dry-run / -d) defaulting to False.

All three parameters are forwarded to RespaceCommand.execute().

  • cognite_toolkit/_cdf_tk/commands/_respace.py

What changed: Two additions: the command methods now accept parameters, and two new data classes were added for future CSV parsing.

  • RespaceMapping: A new Pydantic model representing a single row of the input CSV. It has three required string fields (source_space, external_id, target_space) with alias_generator=to_camel_case so camelCase CSV headers (sourceSpace, externalId, targetSpace) map to snake_case fields. A model_validator rejects rows where sourceSpace == targetSpace. The external ID is preserved — only the space changes.
  • RespaceMappingList: A ModelList[RespaceMapping] subclass that provides CSV schema validation and parsing via the inherited read_csv_file() method. Only implements the required abstract method _get_base_model_cls(). Not yet wired into the command logic.
  • RespaceCommand.plan(): Signature changed from plan(self) to plan(self, csv_file: Path, output_file: Path). Prints the received parameters as confirmation before the placeholder message.
  • RespaceCommand.execute(): Signature changed from execute(self) to execute(self, plan_file: Path, backup_dir: Path, dry_run: bool = False). Prints the received parameters, using the verb-swapping pattern ("Would execute" / "Executing") to indicate dry run mode, consistent with the existing codebase style.

@ivansurif ivansurif requested review from a team as code owners February 15, 2026 18:05
@gemini-code-assist
Copy link
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.

@ivansurif ivansurif requested a review from doctrino February 15, 2026 18:05
@github-actions
Copy link

github-actions bot commented Feb 15, 2026

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
34409 29536 86% 80% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
cognite_toolkit/_cdf_tk/commands/_respace.py 63% 🟢
TOTAL 63% 🟢

updated for commit: e2f9021 by action🐍

@codecov
Copy link

codecov bot commented Feb 15, 2026

Codecov Report

❌ Patch coverage is 62.50000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.83%. Comparing base (81b84de) to head (e2f9021).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
cognite_toolkit/_cdf_tk/commands/_respace.py 62.50% 9 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #2522    +/-   ##
========================================
  Coverage   85.83%   85.83%            
========================================
  Files         410      414     +4     
  Lines       34222    34409   +187     
========================================
+ Hits        29373    29536   +163     
- Misses       4849     4873    +24     
Files with missing lines Coverage Δ
cognite_toolkit/_cdf_tk/commands/_respace.py 62.50% <62.50%> (-7.50%) ⬇️

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

doctrino
doctrino previously approved these changes Feb 16, 2026
Copy link
Collaborator

@doctrino doctrino left a comment

Choose a reason for hiding this comment

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

Good to go

@ivansurif ivansurif merged commit da5d8e0 into main Feb 17, 2026
32 of 34 checks passed
@ivansurif ivansurif deleted the feature/data-respace-cli-params branch February 17, 2026 10:08
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