First Speckle Automation

Hi All,

I’m trying to develop a function for my first automation. Running it on the cloud works perfect but I want to start testing it on my local environment as it’s more practical.

Correct me if I’m wrong but reading the documentation I saw two ways of testing a python function:

The first one is sing the docker image and running:

docker run speckle_automate_python_example \ python -u main.py run function_inputs.json

The documentation seems outdated on this command but I managed to use it

When running this command I get the following error: gql.transport.exceptions.TransportQueryError: {'message': "Invalid status change. Attempting to move from 'succeeded' to 'running'.", 'locations': [{'line': 2, 'column': 3}], 'path': ['automateFunctionRunStatusReport'], 'extensions': {'code': 'FUNCTION_RUN_REPORT_STATUSES_ERROR', 'statusCode': 400}}

The second way is actually executing the test, for this case I execute poetry run pytest and the execution of the test gets blocked forever, there’s no message or nothing. For this I also tried to create a C# function and the same happened.

Thank you for your help in advance!
Best,
Julio

The methodology for testing locally has changed now in the public beta phase:

Where was the docker run reference?

2 Likes

@jonathon I found it on the README of the created automation function. This is the base repo that is forked when creating it: GitHub - specklesystems/speckle_automate_python_example: Example function written for Speckle Automate in python

Regarding the link you shared… I did try that but my test function gets blocked. Is it correct running poetry run pytest?

Best,
Julio

1 Like

Have you set up .env file with the appropriate details?

Great. Thanks for the info :pray:, that was an oversight on our part, we put efforts into the docs but let this slip. I’ll rectify in the template files.

1 Like

Yes, I filled the .env.

Had two issues, the first is that I missed filling the stream:write scope on the token and after that I found that the automation was not configured as a test automation. Created a test automation and ran it but it took more than 25 minutes to execute. Is that timing correct?

Best,
Julio

Is that execution time with the bare template or after you’ve added custom code?

The execution was basically the bare template, I’m sharing the actual code executed:

def automate_function_without_inputs(automate_context: AutomationContext) -> None:
    """A function example without inputs.

    If your function does not need any input variables,
     besides what the automation context provides,
     the inputs argument can be omitted.
    """

    version_root_object = automate_context.receive_version()

    print("Report file: ", version_root_object)

    automate_context.mark_run_success("No forbidden types found.")

Maybe the issue is with the print? Also even though the execution was successful I don’t see any logs.

Best,
Julio

1 Like

I’ll look into what I can