httk.workflow.hookapi

Small standard-library helpers for executable workflow hooks.

Attributes

Classes

InstantiateRequest

The v1 request passed to an executable instantiate hook.

Functions

instantiate_main(fn)

Run fn as a v1 executable instantiate hook.

collect_main(fn)

Run fn as a streaming executable collector.

Module Contents

httk.workflow.hookapi.COLLECT_STREAM_FORMAT = 'httk-workflow-collect-stream'[source]
httk.workflow.hookapi.COLLECT_STREAM_VERSION = 1[source]
httk.workflow.hookapi.INSTANTIATE_FORMAT = 'httk-workflow-instantiate'[source]
httk.workflow.hookapi.INSTANTIATE_VERSION = 1[source]
class httk.workflow.hookapi.InstantiateRequest[source]

The v1 request passed to an executable instantiate hook.

Parameters:
  • workflow – The declared workflow id.

  • tag – The caller’s tag, or None.

  • parameters – The parameters already supplied for the job.

  • inputs – Hook-consumed input descriptors. A descriptor is either {"kind": "value", "value": ...} or {"kind": "file", "path": "payload-relative/posix/path"}.

The process current working directory is the staging payload. File descriptors therefore name files relative to that directory.

workflow: str[source]
tag: str | None[source]
parameters: collections.abc.Mapping[str, Any][source]
inputs: collections.abc.Mapping[str, collections.abc.Mapping[str, Any]][source]
httk.workflow.hookapi.instantiate_main(fn)[source]

Run fn as a v1 executable instantiate hook.

The hook receives one JSON document on standard input: {"format": "httk-workflow-instantiate", "format_version": 1, "workflow": <workflow-id>, "tag": <string-or-null>, "parameters": {...}, "inputs": {<name>: <descriptor>}}. The current working directory is the staging payload; file descriptors contain payload-relative POSIX paths. The returned mapping must contain parameters and may contain tag; it is emitted as one JSON document on standard output. Exceptions, malformed requests, and invalid responses are reported on standard error and exit with status 1.

Parameters:

fn (collections.abc.Callable[[InstantiateRequest], collections.abc.Mapping[str, Any]]) – Convert the request into parameter mutations and an optional tag.

Returns:

Nothing; the response is written as one JSON document.

Return type:

None

httk.workflow.hookapi.collect_main(fn)[source]

Run fn as a streaming executable collector.

Parameters:

fn (collections.abc.Callable[[collections.abc.Mapping[str, Any]], collections.abc.Mapping[str, Any]]) – Convert one serialized job record into role-to-value wrappers.

Returns:

Nothing; responses are written as JSONL to standard output.

Return type:

None