Compute Module Documentation: Missing Steps and Misleading Examples

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

2 Likes

thank you for the feedback Ilan! we will looking into the issues here and into improving the documentation in Compute Module!

1 Like

Hey @ilan.hazan,

It absolutely takes some digging / reading the library code which is why I recorded a YT video to explain things.

https://youtu.be/XWWyVmvqBJ8

Additional resources below including a tutorial from Chris/Dorian linked.

Hope this helps,

## Code and Resources
- **Local Environment Setup:**  
  [Demo Palantir Compute Modules (JS)](https://github.com/silkietools/demo-palantir-compute-modules-js)
  
- **Milwaukee Product Scraper Integration:**  
  [Compute Modules Scraper for Milwaukee Tools (TS)](https://github.com/silkietools/demo-compute-modules-scraper-milwaukee-ts)

## Additional Materials
- **TypeScript Pipeline Demo:**  
  [Watch Demo](https://youtu.be/1Ga_v0477fc?si=X4MeHxtSntPAWXLP)
  
- **Python Compute Modules Article:**  
  [Read Article](https://dorians.medium.com/foundry-compute-modules-0b89d4897cd0)

1 Like