Reference for the AutomationContext interface in Speckle Automate
AutomationContext
Referenceautomation_run_data
: The current automation run data as an AutomationRunData objectspeckle_client
: The Speckle client instance used to interact with the Speckle serverserver_transport
: It is unlikely you will need to interact with this directly, as the SDK has methods to abstract this awayAutomationRunData
object has the following properties that help with identifying the current run:
project_id
: The project ID of the current automation runspeckle_server_url
: The Speckle server URLautomation_id
: The automation ID the function is configured withautomation_run_id
: The ID of the current automation runfunction_run_id
: The ID of the current function run[triggers]
: The list of triggers that initiated the automation run (this is a single model id for now)function_inputs
: Values for each of your FunctionInputs
fieldsAutomationContext
provides a range of methods to interact with Speckle data, manage results, and log progress.
Method | Description |
---|---|
receive_version() | Retrieve the model data that triggered this run |
Method | Description |
---|---|
mark_run_success( message ) | Report successful completion |
mark_run_failed( message ) | Report failure with details. A failure may be a legitimate result depending on the function use case. |
mark_run_exception( message ) | Report an exception during execution, this relates to code error or could be for incorrect model format. |
Method | Description |
---|---|
attach_error_to_objects(category, object_ids, message, metadata) | Flag objects with issues |
attach_warning_to_objects(category, object_ids, message, metadata) | Add warnings to objects |
attach_success_to_objects(category, object_ids, message, metadata) | Mark objects as successfully processed |
attach_info_to_objects(category, object_ids, message, metadata}) | Add informational notes to objects |
attach_result_to_objects()
is a generic method that can be used to add any type of annotation to objects. An additional level
parameter can be used to specify the type of annotation.metadata
parameter can be used to store additional arbitrary information about the objects, as a key:value store.gradient: Bool
and gradientValues: List[str]
and can be used:Method | Description |
---|---|
create_new_version_in_project(...) | Create a model version in a specific project |
store_file_result(...) | Save a file or blob as an artefact |
AutomationContext
which is part result part context context_view
can be used to set the view state that will be displayed in the UI when viewing the function results. This can be used to display a custom view for the function run, it is in the form of the url schema to reference specific federations of models and model@version together in a scene.