perago.build_workspace_free_task_output#

perago.build_workspace_free_task_output(task, raw_result)[源代码]#

Validate and wrap a workspace-free task result.

The helper applies the task output model outside the invocation path so tests and runtime integrations can reuse the exact same output contract.

Parameters:
taskTaskDefinition

Loaded workspace-free task definition whose output model validates the result.

raw_resultobject

Value returned by the task callable. Pydantic model instances are dumped before being revalidated with extra="forbid"; mappings and other supported values are validated directly by the output model.

Returns:
dict of str to Any

Output wrapper containing only "result".

Raises:
TaskInputError

If task is a workspace task.

pydantic.ValidationError

If raw_result does not satisfy the task output model or contains extra fields.

参数:
返回类型:

dict[str, Any]

参见

invoke_workspace_free_task

Invoke a workspace-free task and build this output wrapper.

build_workspace_task_output

Build the corresponding workspace task output wrapper.

Examples

>>> task_def = load_module_task("app.workers.metadata_validate")
>>> build_workspace_free_task_output(task_def, {"valid": False, "reason": "missing"})
{'result': {'valid': False, 'reason': 'missing'}}