Add CLI parameters for cdf data respace plan/execute#2522
Conversation
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. |
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
Codecov Report❌ Patch coverage is
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
🚀 New features to boost your workflow:
|
Description
Add CLI parameters for
cdf data respace plan/executeDefine Typer-annotated arguments and options for both subcommands:
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
Changelog
Changed
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 ascsv_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().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. Amodel_validatorrejects 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 inheritedread_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.