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 .json and must not point to an existing directory.

Returns:
pathlib.Path

The output path after the JSON file has been written.

Raises:
ValueError

If output does not end with .json or points to a directory.

参数:
返回类型:

Path

参见

build_taskdef

Build 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')