new_workflow (workflow generator)
What it is
Creates a new workflow scaffold from a bundled template and writes it to a target directory. Exposed both as a Click subcommand (new workflow) and as a Python function.
Public API
-
new_workflow(workflow_name: str, workflow_path: str = ".", extra_values: dict = {})- Converts
workflow_nameto PascalCase. - Ensures
workflow_pathexists (creates it if missing;"."resolves to current working directory). - Copies the workflow template into
workflow_pathusingCopier, passing template values.
- Converts
-
CLI command:
new workflow WORKFLOW_NAME [WORKFLOW_PATH]- Invokes
new_workflow(WORKFLOW_NAME, WORKFLOW_PATH).
- Invokes
Configuration/Dependencies
-
Dependencies
click(CLI command/arguments)naas_abi_cli(used to locate bundled templates)naas_abi_cli.cli.utils.Copier.Copier(performs the template copy).utils.to_pascal_case(name normalization)
-
Template location
- Computed as:
os.path.join(os.path.dirname(naas_abi_cli.__file__), "cli/new/templates/workflow")
- Computed as:
-
Template values passed
workflow_name_pascal: PascalCase version ofworkflow_name- plus any
extra_valuesmerged in viavalues | extra_values
Usage
CLI
naas-abi new workflow MyWorkflow .
Python
from naas_abi_cli.cli.new.workflow import new_workflow
new_workflow("my_workflow", workflow_path=".")
Caveats
extra_valueshas a mutable default ({}), which can be shared across calls.workflow_nameis converted to PascalCase before templating; the template receivesworkflow_name_pascalonly.