I’m trying to create a function that leverages the batch execution capabilities provided by actions. I noticed in the documentation that there is only one example provided, and it’s in TypeScript. I attempted to implement it in Python but haven’t been successful so far. Below is my test code and a screenshot of the error/response I received from the Action within the Ontology Manager. I tried to follow that oficial recommendation: To enable batched execution, the function must receive a single input parameter containing a list of structs (also known as a “map” or “dictionary”).
Has anyone used this feature with Python before? Do you have any examples?
Goal: To be able to modify more than 10,000 objects in a single action submission.
from ontology_sdk import FoundryClient
from functions.api import function, OntologyEdit
from ontology_sdk.ontology.objects import AndreBarrosFlightAlerts
from ontology_sdk.ontology.object_sets import AndreBarrosFlightAlertsObjectSet
@function(
edits=[AndreBarrosFlightAlerts]
)
def update_delay(batch: list[dict[str, AndreBarrosFlightAlertsObjectSet]]) -> list[OntologyEdit]:
edits = FoundryClient().ontology.edits()
for flight in batch: # Needs adjusts
if flight.arrival_delay is not None:
flight_edit = edits.objects.AndreBarrosFlightAlerts.edit(flight)
flight_edit.arrival_delay = flight.arrival_delay * 1.0
return edits.get_edits()
