Submitting Workflows
After initialization, Python can leverage the Fuzzball API by referencing the variable
api_instance
. The code snippet below uses the Fuzzball
workflow service API to submit a
job. It does this by:
- creating a Fuzzball workflow definition object called
workflow_definition
- reading a Fuzzball workflow definition file located at path
/home/bphan/fuzzball-workflow-examples/hello-world/hello-world.yaml
and assigning the value to the objectworkflow_definition
- creating a
StartWorkflowRequest
with the namehello-world-from-python-sdk
and the workflow definition saved in the variableworkflow_definition
- starting a workflow through the Fuzzball API by calling the function
start_workflow()
After submission, the code prints the UUID returned in the response.
workflow_definition_path = "/home/bphan/fuzzball-workflow-examples/hello-world/hello-world.yaml"
workflow_definition = fuzzball.WorkflowDefinition()
with open(os.path.expanduser(workflow_definition_path)) as stream:
try:
workflow_definition = yaml.safe_load(stream)
except yaml.YAMLError as exc:
print(exc)
sys.exit(-1)
response = api_instance.start_workflow(
fuzzball.StartWorkflowRequest(
name="hello-world-from-python-sdk",
definition=workflow_definition)
)
Lastly
print("Job submitted to Fuzzball with UUID {}".format(response.id))
Combining the initialization code with the workflow submission code yields output similar to the following:
$ python submit-fuzzball-workflow.py
Job submitted to Fuzzball with UUID 20a709cd-55db-4731-af70-a4830e32d6b6