Hi everyone,
I’ve been working through the “Build a compute module-backed function” example in the Compute Module documentation, and I’ve run into some issues that I feel need to be addressed. In this post I will show you how to make it works. While the documentation provides a good starting point, it is incomplete and misleading in some key areas. Here’s a detailed breakdown of the problems:
Missing Steps in the Example
The Overview claims that after following the example, you should be able to use the compute module in a workshop. However, the guide abruptly ends with a vague statement:
“Once the configuration is updated, you can start the compute module on the Overview page, test it using the bottom Query panel, and view the logs.”
This is frustrating because it skips the critical steps of “registering the function” and “using it effectively in a workshop”. I spent time struggling with this before realizing that the documentation lacked guidance in the following areas:
Function Registration
- By default, functions are registered as “global.” What exactly does “global” mean here? One noticeable issue is that “global” functions are not visible in the Code Repository, which added to my confusion. For the function to be visible, you should register it as Ontology.
- In the Python code we implemented in the Docker container, the “add” function returns a String, not an Integer, which was not reflected in the documentation. This means you need to register it as returning String.
Example Code Issues
The provided example code contains errors and is not functional as written.
Here’s the corrected index.ts
for reference:
Note as stated above, the “add” function returns String.
// Import the necessary modules from the Foundry functions API
import { Function, Integer, IntegerPropertyBaseType } from "@foundry/functions-api";
import { Objects, Queries } from "@foundry/ontology-api";
export class MyFunctions {
@Function()
public async myHelloWorld(append: string): Promise<string> {
// Call the "add" function with the required parameters
return await Queries.myhelloworld({ name: ' ' + append });
}
@Function()
public async myAdd(a: Integer, b: Integer): Promise<string> {
return await Queries.myadd({ x: a, y: b });
}
}
I hope this feedback helps improve the documentation for future users. If anyone else has run into similar issues or has insights to share, I’d love to hear your thoughts.
Thanks!
Ilan