feat (cli-cicd integration): Enhance import command interface#1
Conversation
|
|
||
| @staticmethod | ||
| def import_required_param_missing(param_display_name: str, flow_name: str, flow_syntax: str) -> str: | ||
| return f"{param_display_name} is required for {flow_name} flow.\nCorrect syntax: {flow_syntax}" |
There was a problem hiding this comment.
not sure it actually break into a new line.
There was a problem hiding this comment.
it is - I test it.
but I see not the string is wrong - I wanted it without the "correct" - will remove it
| from argparse import Namespace | ||
|
|
||
| def import_with_config_file(args: Namespace) -> None: | ||
| """Import using config file and environment parameters - delegates to CICD library.""" No newline at end of file |
There was a problem hiding this comment.
why do we need specific file for it and can't it be in the same file of the regular process?
| context = handle_context.get_command_context(args.path, raise_error=False) | ||
| context.check_command_support(Command.FS_IMPORT) | ||
| if hasattr(args, 'path') and args.path: | ||
| # In CICD flow - no path elements involved, skip command support check |
There was a problem hiding this comment.
what would be if i'm in some path and do import --config-file?
e.g.,
fab:ws.workspace/$ import --config-file <>| elif args.config_file: | ||
| import_cicd.import_with_config_file(args) |
There was a problem hiding this comment.
else? do we need want to return missing input? what happened?
|
|
||
| @staticmethod | ||
| def import_required_param_missing(param_display_name: str, flow_name: str, flow_syntax: str) -> str: | ||
| return f"{param_display_name} is required for {flow_name} flow.\nCorrect syntax: {flow_syntax}" |
There was a problem hiding this comment.
can you give example of correct syntax?
nit: i'd phrase it differently like, Please use ... instead
|
|
||
| @staticmethod | ||
| def import_mixed_flows_error() -> str: | ||
| return "cannot mix Direct API flow parameters (path, -i, --format) with CICD flow parameters (--config-file, --env, -P)" |
|
|
||
| @staticmethod | ||
| def import_mixed_flows_error() -> str: | ||
| return "cannot mix Direct API flow parameters (path, -i, --format) with CICD flow parameters (--config-file, --env, -P)" |
There was a problem hiding this comment.
this message isn't clear to users. they don't know what direct api vs config. it should be something like
arguments mismatch. you cannot use combination from path/input with config-file/env/params
|
|
||
| @staticmethod | ||
| def import_no_flow_specified_error() -> str: | ||
| return "either -i/--input (with path) or --config-file (with --env) must be specified" |
|
|
||
| @staticmethod | ||
| def import_no_flow_specified_error() -> str: | ||
| return "either -i/--input (with path) or --config-file (with --env) must be specified" |
There was a problem hiding this comment.
this text isn't clear. can we think of something else?
| def command_not_supported(command: str) -> str: | ||
| return f"not supported for command '{command}'" | ||
| def command_not_supported(command: str, item_type: str) -> str: | ||
| return f"Command '{command}' is not supported for item type '{item_type}'" |
There was a problem hiding this comment.
not specifically for items, right? if that's the case, let's rephrase the text to when item_type is not None
| def register_import_parser(subparsers: _SubParsersAction) -> None: | ||
| import_examples = [ | ||
| "# import a notebook from a local directory", | ||
| "# import a notebook from a local directory (Direct API call flow)", |
There was a problem hiding this comment.
from user perspective, i am not aware of such flow.
| "$ import pip.Notebook -i /tmp/pip1.DataPipeline -f", | ||
| "# import a pipeline from a local directory (Direct API call flow)", | ||
| "$ import pip.Notebook -i /tmp/pip1.DataPipeline -f\n", | ||
| "# import using config file and environment (CI/CD flow - no path needed)", |
| "--config-file", | ||
| metavar="PATH", | ||
| type=str, | ||
| help="Path to local config file. When used, --env is required. Only used in CI/CD flow.", |
There was a problem hiding this comment.
local config file is overloaded term in the cli context. we should use some other distinct name
| "--env", | ||
| metavar="ENV_NAME", | ||
| type=str, | ||
| help="Environment name as defined in config file. Required when using --config-file. Only used in CI/CD flow.", |
There was a problem hiding this comment.
i think environment also is a bit overloaded. what do you think about --stage ? @shirasassoon ?
| "--format", | ||
| metavar="", | ||
| help="Input format. Optional, supported for notebooks (.ipynb, .py)", | ||
| help="Input format for current flow only. Optional, supported for notebooks (.ipynb, .py). Only used in Direct API call flow.", |
There was a problem hiding this comment.
what does it mean 'current flow only'?
| ERROR_UNIVERSAL_SECURITY_DISABLED = "UniversalSecurityDisabled" | ||
| ERROR_SPN_AUTH_MISSING = "ServicePrincipalAuthMissing" | ||
| ERROR_JOB_FAILED = "JobFailed" | ||
| ERROR_IMPORT_VALIDATION = "ImportValidationError" |
| _check_required_param(args, 'path', 'path', 'Direct API', flow_syntax) | ||
| _check_required_param(args, 'input', '-i/--input', | ||
| 'Direct API', flow_syntax) |
There was a problem hiding this comment.
looks to me too hard coded. tomorrow we will change in the parser the text and we will forget this place. can we think on another approach?
| from fabric_cli.parsers.fab_parser_validators import validate_import_args | ||
|
|
||
| import_parser.set_defaults(func=fs.import_command, validate_args=lambda args: validate_import_args(args)) |
There was a problem hiding this comment.
i think it is not necessary, we use this only in one place, hence we can validate the import_args there
📥 Pull Request
✨ Description of new changes
This pull request introduces significant improvements to the
importcommand interface in the CLI, enabling support for both Direct API and CI/CD flows with clear argument validation and user guidance. The changes add mutually exclusive argument groups for the two flows, enforce correct usage with custom validators, improve error messages, and update documentation and examples to reflect the new interface.Import Command Interface and Validation:
importcommand now supports two mutually exclusive flows: Direct API (usingpathand-i/--input) and CI/CD (using--config-fileand--env). Argument parsing enforces that only one flow can be used at a time, and provides detailed error messages if parameters are missing or flows are mixed. (src/fabric_cli/parsers/fab_fs_parser.py[1] [2];src/fabric_cli/parsers/fab_parser_validators.py[3]validate_import_argsensures that required parameters for each flow are provided and that the flows are not mixed. Custom error messages guide the user to correct syntax. (src/fabric_cli/parsers/fab_parser_validators.py[1];src/fabric_cli/errors/common.py[2]import_commandand its implementation have been updated to handle both flows, delegating to the correct import logic based on the arguments. (src/fabric_cli/commands/fs/fab_fs.py[1];src/fabric_cli/commands/fs/fab_fs_import.py[2]Error Handling and Messages:
src/fabric_cli/errors/hierarchy.py[1];src/fabric_cli/core/hiearchy/fab_base_item.py[2] [3];src/fabric_cli/core/hiearchy/fab_element.py[4];src/fabric_cli/errors/common.py[5]src/fabric_cli/core/fab_constant.pysrc/fabric_cli/core/fab_constant.pyR285)Documentation and Examples:
src/fabric_cli/parsers/fab_fs_parser.pysrc/fabric_cli/parsers/fab_fs_parser.pyL393-R400)Codebase Cleanup:
fab_fs_import_item.pyfile, as its functionality is now split between flow-specific modules. (src/fabric_cli/commands/fs/impor/fab_fs_import_item.pysrc/fabric_cli/commands/fs/impor/fab_fs_import_item.pyL1-L126)Changelog:
.changes/unreleased/added-20260210-123451.yaml.changes/unreleased/added-20260210-123451.yamlR1-R6)