Typos that trigger me (#31)
This commit is contained in:
committed by
GitHub
parent
ded12e7118
commit
1e3a3fdeb0
@@ -1,6 +1,6 @@
|
||||
"""This module contains the business logic of the function.
|
||||
"""This module contains the function's business logic.
|
||||
|
||||
Use the automation_context module to wrap your function in an Autamate context helper
|
||||
Use the automation_context module to wrap your function in an Automate context helper.
|
||||
"""
|
||||
|
||||
from pydantic import Field, SecretStr
|
||||
@@ -14,14 +14,14 @@ from flatten import flatten_base
|
||||
|
||||
|
||||
class FunctionInputs(AutomateBase):
|
||||
"""These are function author defined values.
|
||||
"""These are function author-defined values.
|
||||
|
||||
Automate will make sure to supply them matching the types specified here.
|
||||
Please use the pydantic model schema to define your inputs:
|
||||
https://docs.pydantic.dev/latest/usage/models/
|
||||
"""
|
||||
|
||||
# an example how to use secret values
|
||||
# An example of how to use secret values.
|
||||
whisper_message: SecretStr = Field(title="This is a secret message")
|
||||
forbidden_speckle_type: str = Field(
|
||||
title="Forbidden speckle type",
|
||||
@@ -39,13 +39,13 @@ def automate_function(
|
||||
"""This is an example Speckle Automate function.
|
||||
|
||||
Args:
|
||||
automate_context: A context helper object, that carries relevant information
|
||||
automate_context: A context-helper object that carries relevant information
|
||||
about the runtime context of this function.
|
||||
It gives access to the Speckle project data, that triggered this run.
|
||||
It also has conveniece methods attach result data to the Speckle model.
|
||||
It gives access to the Speckle project data that triggered this run.
|
||||
It also has convenient methods for attaching result data to the Speckle model.
|
||||
function_inputs: An instance object matching the defined schema.
|
||||
"""
|
||||
# the context provides a conveniet way, to receive the triggering version
|
||||
# The context provides a convenient way to receive the triggering version.
|
||||
version_root_object = automate_context.receive_version()
|
||||
|
||||
objects_with_forbidden_speckle_type = [
|
||||
@@ -56,7 +56,7 @@ def automate_function(
|
||||
count = len(objects_with_forbidden_speckle_type)
|
||||
|
||||
if count > 0:
|
||||
# this is how a run is marked with a failure cause
|
||||
# This is how a run is marked with a failure cause.
|
||||
automate_context.attach_error_to_objects(
|
||||
category="Forbidden speckle_type"
|
||||
f" ({function_inputs.forbidden_speckle_type})",
|
||||
@@ -70,15 +70,15 @@ def automate_function(
|
||||
f"{function_inputs.forbidden_speckle_type}"
|
||||
)
|
||||
|
||||
# set the automation context view, to the original model / version view
|
||||
# to show the offending objects
|
||||
# Set the automation context view to the original model/version view
|
||||
# to show the offending objects.
|
||||
automate_context.set_context_view()
|
||||
|
||||
else:
|
||||
automate_context.mark_run_success("No forbidden types found.")
|
||||
|
||||
# if the function generates file results, this is how it can be
|
||||
# attached to the Speckle project / model
|
||||
# If the function generates file results, this is how it can be
|
||||
# attached to the Speckle project/model
|
||||
# automate_context.store_file_result("./report.pdf")
|
||||
|
||||
|
||||
@@ -94,10 +94,10 @@ def automate_function_without_inputs(automate_context: AutomationContext) -> Non
|
||||
|
||||
# make sure to call the function with the executor
|
||||
if __name__ == "__main__":
|
||||
# NOTE: always pass in the automate function by its reference, do not invoke it!
|
||||
# NOTE: always pass in the automate function by its reference; do not invoke it!
|
||||
|
||||
# pass in the function reference with the inputs schema to the executor
|
||||
# Pass in the function reference with the inputs schema to the executor.
|
||||
execute_automate_function(automate_function, FunctionInputs)
|
||||
|
||||
# if the function has no arguments, the executor can handle it like so
|
||||
# If the function has no arguments, the executor can handle it like so
|
||||
# execute_automate_function(automate_function_without_inputs)
|
||||
|
||||
Reference in New Issue
Block a user