API reference¶
The installed entry point is cwl2inputs.plugin:cwl2inputs in the
transpiler_mate.plugins group.
| Option | Type | Default | Meaning |
|---|---|---|---|
output / --output |
Path |
inputs.yaml |
Destination YAML file. |
Unknown options are rejected. generate_template(context) returns YAML text;
cwl2inputs.execute(context, options) writes it. Both require a selected process.
The plugin wraps generation and output failures as PluginExecutionError with
the original exception as its cause. Selection errors use the runtime's message.
Generate a YAML input template for the runtime-selected CWL process.
CWL2InputsOptions
¶
Bases: BaseModel
Output options for input template generation.
Source code in src/cwl2inputs/plugin.py
class CWL2InputsOptions(BaseModel):
"""Output options for input template generation."""
model_config = ConfigDict(extra="forbid")
output: Path = Field(
default=Path("inputs.yaml"), description="The output YAML file path"
)
cwl2inputs(context, options)
¶
Write a template, preserving cwltool's defaults and placeholder comments.
Source code in src/cwl2inputs/plugin.py
@transpiler_plugin(
name="cwl2inputs",
description="Generate a CWL inputs YAML template using cwltool.",
options_model=CWL2InputsOptions,
)
def cwl2inputs(context: TranspilerContext, options: CWL2InputsOptions) -> None:
"""Write a template, preserving cwltool's defaults and placeholder comments."""
try:
template = generate_template(context)
options.output.parent.mkdir(parents=True, exist_ok=True)
options.output.write_text(template, encoding="utf-8")
logger.success(f"Input template written to {options.output.absolute()}")
except PluginExecutionError:
raise
except Exception as exc:
raise PluginExecutionError(
f"Unable to generate input template at {options.output.absolute()}: {exc}"
) from exc
generate_template(context)
¶
Render cwltool's template from the resolved graph and selected process.
An explicit source fragment is required, following the runtime's
resolved_process contract. No workflow or container is executed.
Source code in src/cwl2inputs/plugin.py
def generate_template(context: TranspilerContext) -> str:
"""Render cwltool's template from the resolved graph and selected process.
An explicit source fragment is required, following the runtime's
``resolved_process`` contract. No workflow or container is executed.
"""
process = context.resolved_process
document = save(list(context.processes), relative_uris=False)
_remove_anonymous_enum_names(document)
with TemporaryDirectory(prefix="cwl2inputs-") as directory:
source = Path(directory) / "workflow.cwl"
source.write_text(json.dumps(document), encoding="utf-8")
loading_context = LoadingContext()
loading_context.construct_tool_object = default_make_tool
tool = load_tool(
f"{source.as_uri()}#{quote(process.id, safe='/')}", loading_context
)
output = StringIO()
make_template(tool, output)
return output.getvalue()