Hello,
I’m trying to play around with the Foundry AIP and I’m running into a problem while trying to use a User Defined Function in either the Pipeline Builder or the Workshop of my project. All the data I’m using is made up just for practice, but I keep on running into this error where even though my function returns a list(or array) of dictionaries, the Workshop and Pipeline Builder both say it is returning a map(dictionary). I’m confused because every test I’ve ran in the code repository has indicated that my function indeed returns a list at the top level. Code pasted below, error message in Workshop is “Unsupported function return type: map” when I try to use it as an Object Set, and the function doesn’t even appear when I try to use it’s output as a struct array.
Code:
# Returns ShipName, HullName, and CountOf(Jobs) for each hull of each ship
@function
def gather_ship_jobs() → List[Dict[str, str]]:
client = FoundryClient()
results = (
client.ontology.objects.ShipJob
.group_by(ShipJob.object_type.ship_name.exact())
.group_by(ShipJob.object_type.ship_hull.exact())
.count()
.compute()
)
job_list = \[
{
"Ship Name": str(row.group\["shipName"\]),
"Ship Hull": str(row.group\["shipHull"\]),
"Job Count": str(int(row.metrics\[0\].value))
}
for row in results.data
\]
return job_list
#Count Buckets will take gathered ship Jobs and return a string that reads:
#“{Ship Name} – {Ship Hull} – {Count(Jobs)} – {proper bucket} jobs”
#buckets are 0-5, 6-10, and 10+ jobs
@function
def countBuckets() → List[Dict[str, str]]:
hulls = gather_ship_jobs()
for hull in hulls:
if int(hull\["Job Count"\]) < 6:
hull\["Bucket"\] = "0-5 Jobs"
elif int(hull\["Job Count"\]) < 10:
hull\["Bucket"\] = "6-10 Jobs"
else:
hull\["Bucket"\] = "10+ Jobs"
return hulls