ray.workflow.get_metadata#

ray.workflow.get_metadata(workflow_id: str, task_id: str | None = None) Dict[str, Any][source]#

Get the metadata of the workflow.

This will return a dict of metadata of either the workflow ( if only workflow_id is given) or a specific workflow task (if both workflow_id and task id are given). Exception will be raised if the given workflow id or task id does not exist.

If only workflow id is given, this will return metadata on workflow level, which includes running status, workflow-level user metadata and workflow-level running stats (e.g. the start time and end time of the workflow).

If both workflow id and task id are given, this will return metadata on workflow task level, which includes task inputs, task-level user metadata and task-level running stats (e.g. the start time and end time of the task).

Parameters:
  • workflow_id – The workflow to get the metadata of.

  • task_id – If set, fetch the metadata of the specific task instead of the metadata of the workflow.

Examples

from ray import workflow

@ray.remote
def trip():
   pass

workflow_task = trip.options(
    **workflow.options(task_id="trip", metadata={"k1": "v1"})).bind()
workflow.run(workflow_task,
    workflow_id="trip1", metadata={"k2": "v2"})
workflow_metadata = workflow.get_metadata("trip1")
print(workflow_metadata)

task_metadata = workflow.get_metadata("trip1", "trip")
print(task_metadata)
{'status': 'SUCCESSFUL', 'user_metadata': {'k2': 'v2'}, 'stats': {'start_time': ..., 'end_time': ...}}
{'task_id': 'trip', 'task_options': {'task_type': 'FUNCTION', 'max_retries': 3, 'catch_exceptions': False, 'retry_exceptions': False, 'checkpoint': True, 'ray_options': {'_metadata': {'workflow.io/options': {'task_id': 'trip', 'metadata': {'k1': 'v1'}}}}}, 'user_metadata': {'k1': 'v1'}, 'workflow_refs': [], 'stats': {'start_time': ..., 'end_time': ...}}
Returns:

A dictionary containing the metadata of the workflow.

Raises:

ValueError – if given workflow or workflow task does not exist.

PublicAPI (alpha): This API is in alpha and may change before becoming stable.