new_workflow (workflow generator)
What it is
- Implements the
naas-abi-cli new workflowcommand. - Copies a workflow template directory into a target path, injecting a PascalCase workflow name into template values.
Public API
-
new_workflow(workflow_name: str, workflow_path: str = ".", extra_values: dict = {})- Normalizes
workflow_nameto PascalCase. - Resolves
workflow_path:"."becomesos.getcwd()- Creates the directory if it does not exist
- Uses
Copierto copy templates from the package template folder toworkflow_path. - Passes template values:
workflow_name_pascal(PascalCase string)- merged with
extra_values(using dict union|)
- Normalizes
-
CLI entrypoint (Click command)
naas-abi-cli new workflow WORKFLOW_NAME [WORKFLOW_PATH]- Implemented by
_new_workflow(...), which delegates tonew_workflow(...).
Configuration/Dependencies
- Python packages
click(CLI wiring)naas_abi_cli(used to locate installed template files)
- Internal utilities
Copierfromnaas_abi_cli.cli.utils.Copier(performs template copy)to_pascal_casefrom.utils(name normalization)
- Template location
<naas_abi_cli package>/cli/new/templates/workflow
Usage
From CLI
naas-abi-cli new workflow MyWorkflow .
From Python
from naas_abi_cli.cli.new.workflow import new_workflow
new_workflow("my_workflow", "./out")
Caveats
extra_valueshas a mutable default ({}); avoid mutating it inside callers. Prefer passing an explicit dict if needed.- Requires Python support for dict union (
values | extra_values), i.e., Python 3.9+.