AutomationContext Reference
The AutomationContext is your function’s interface to Speckle at runtime. It provides:
- Access to model data that triggered the automation
- Authentication for Speckle API interactions
- Methods to report results and analysis findings
- Tools to create new model versions and file artifacts
- Logging capabilities for debugging
Properties
Core Properties
These properties provide essential context about the current automation run:automation_run_data: The current automation run data as an AutomationRunData objectspeckle_client: The Speckle client instance used to interact with the Speckle server
AutomationRunData
TheAutomationRunData 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)
Configuration values
The Automate runtime also feeds your function with the following data if it has been defined:function_inputs: Values for each of yourFunctionInputsfields
Methods
TheAutomationContext provides a range of methods to interact with Speckle data, manage results, and log progress.
Working with Data
Reporting Function Success
Use these methods to update the automation run status. Note that if you call multiple status methods, only the last one will be recorded and displayed in the UI. This may cause confusion if multiple status methods are called.Handling Results
These methods help in tagging and categorizing objects with statuses:affected_objects takes the objects themselves (one Base or a list), not their ids.
Best Practices for object annotations
- Use categories to group related annotations, and provide clear, actionable messages.
- Avoid creating too many annotations, e.g. one per object. Instead, group related objects and annotate them together.
- Categories can be used to group annotations by severity, type, result description or any other relevant criteria.
attach_result_to_objects()is a generic method that can be used to add any type of annotation to objects. An additionallevelparameter can be used to specify the type of annotation.- The
metadataparameter can be used to store additional arbitrary information about the objects, as a key:value store.
Creating function artefacts
Manage new model versions and save result as file/blob artefacts:
Signatures and return values are in the API Reference; examples are in Function Artefacts.
Context Views
Lastly a property of theAutomationContext which is part result part context context_view records a view state for the function run, in the form of the url schema to reference specific federations of models and model@version together in a scene. The 3D viewer does not show Automate results; see Viewing Automation Results for where run results appear.