Skip to main content

Advanced Usage

Running a specific task

If you want to run the workflow to retrieve the output of another task, you can use Client.run_task():

with Client(url="https://your.scale.endpoint.url") as client:
results = client.run_task("infer_yolo_v8", "path/to/image1.jpg")

Advanced configuration and output selection

If you need to select outputs from various tasks or set parameters for intermediate tasks, you can use a Context object for maximum flexibility:

context = client.build_context()

A context holds specific configuration for your deployment, which you can reuse across multiple runs.

Using Context.add_output, you can select specific outputs from any task in your workflow:

# Add ALL outputs from the "ocv_blur" task
context.add_output("ocv_blur")

# Add output 1 from "infer_yolo_v8"
context.add_output("infer_yolo_v8", 1)

# Add ALL outputs from the "infer_yolo_v8_seg" task
# Save them to project's storage (will be returned as StorageObjectIO)
context.add_output("infer_yolo_v8_seg", save_temporary=True)

You can also use Context.set_parameters to edit configuration of any task:

context.set_parameters("infer_yolo_v8", {"conf_thres": 0.5})

To run using a context, you can pass it to the Client.run_on() method:

with Client(url="https://your.scale.endpoint.url") as client:
results = client.run_on(context, "path/to/image1.jpg")

Chaining deployments

You can chain multiple deployments together by passing the outputs of one deployment as inputs to another:

with Client(url="https://your.scale.endpoint.url") as client1, \
Client(url="https://your.other.scale.endpoint.url") as client2:
results1 = client1.run("path/to/image1.jpg")
results2 = client2.run(results1)

You can also forward selected outputs using Results.get_output():

results1 = client1.run("path/to/image1.jpg")
results2 = client2.run(results1.get_output(1), results1.get_output(2))