perago.write_taskdef#
- perago.write_taskdef(task, output)[源代码]#
Write a generated Conductor TaskDef to a JSON file.
The parent directory is created when needed, and the file is written with stable indentation so the generated TaskDef can be reviewed before it is registered with Conductor.
- Parameters:
- taskTaskDefinition
Validated task definition to serialize.
- outputpathlib.Path
Destination JSON file path. The path must end with
.jsonand must not point to an existing directory.
- Returns:
- pathlib.Path
The output path after the JSON file has been written.
- Raises:
- ValueError
If
outputdoes not end with.jsonor points to a directory.
- 参数:
task (TaskDefinition)
output (Path)
- 返回类型:
参见
build_taskdefBuild the TaskDef mapping without writing a file.
Examples
>>> task_def = load_module_task("app.workers.metadata_validate") >>> write_taskdef(task_def, Path("generated/metadata.validate.json")) PosixPath('generated/metadata.validate.json')