Skip to content

feat (cli-cicd integration): Enhance import command interface#1

Open
aviatco wants to merge 5 commits intodev/aviatcohen/cli-cicd-intergation-mainfrom
dev/aviatcohen/cicd-import-command-interface
Open

feat (cli-cicd integration): Enhance import command interface#1
aviatco wants to merge 5 commits intodev/aviatcohen/cli-cicd-intergation-mainfrom
dev/aviatcohen/cicd-import-command-interface

Conversation

@aviatco
Copy link
Owner

@aviatco aviatco commented Feb 10, 2026

📥 Pull Request

✨ Description of new changes

This pull request introduces significant improvements to the import command 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:

  • The import command now supports two mutually exclusive flows: Direct API (using path and -i/--input) and CI/CD (using --config-file and --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]
  • A new validation function validate_import_args ensures 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]
  • The import_command and 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:

  • Improved error messages for unsupported commands, missing parameters, and incorrect flow usage, including more descriptive context about item types and flows. (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]
  • Added a new error code for import validation errors. (src/fabric_cli/core/fab_constant.py src/fabric_cli/core/fab_constant.pyR285)

Documentation and Examples:

Codebase Cleanup:

Changelog:

@aviatco aviatco marked this pull request as ready for review February 10, 2026 16:50

@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}"

Choose a reason for hiding this comment

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

not sure it actually break into a new line.

Copy link
Owner Author

Choose a reason for hiding this comment

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

it is - I test it.
but I see not the string is wrong - I wanted it without the "correct" - will remove it

Comment on lines +1 to +4
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

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

what would be if i'm in some path and do import --config-file?

e.g.,

fab:ws.workspace/$ import --config-file <>

Comment on lines +23 to +24
elif args.config_file:
import_cicd.import_with_config_file(args)

Choose a reason for hiding this comment

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

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}"

Choose a reason for hiding this comment

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

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)"

Choose a reason for hiding this comment

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

nit: capital C


@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)"

Choose a reason for hiding this comment

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

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"

Choose a reason for hiding this comment

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

capital E


@staticmethod
def import_no_flow_specified_error() -> str:
return "either -i/--input (with path) or --config-file (with --env) must be specified"

Choose a reason for hiding this comment

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

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}'"

Choose a reason for hiding this comment

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

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)",

Choose a reason for hiding this comment

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

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)",

Choose a reason for hiding this comment

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

same.. this is transparent to users

"--config-file",
metavar="PATH",
type=str,
help="Path to local config file. When used, --env is required. Only used in CI/CD flow.",

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

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"

Choose a reason for hiding this comment

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

InvalidImportArguments ?

Comment on lines +45 to +47
_check_required_param(args, 'path', 'path', 'Direct API', flow_syntax)
_check_required_param(args, 'input', '-i/--input',
'Direct API', flow_syntax)

Choose a reason for hiding this comment

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

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?

Comment on lines +461 to +463
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))

Choose a reason for hiding this comment

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

i think it is not necessary, we use this only in one place, hence we can validate the import_args there

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