Add functions to Marketplace product [Beta]

Use Foundry DevOps to include your functions in Marketplace products for other users to install and reuse. Learn how to create your first product.

Supported features

DevOps packages functions for installation and reuse, but does not provide user-viewable source code for functions. This means that after installation, you will be able to use the function, but you will not be able to view the function's source logic; the repository accompanying the function will be empty. Functions with model deployment inputs are coming soon.

Adding Functions to products

To add a Function to a product, first create a product and then select the Function content type as below.

add function

You will then be prompted to choose a function and a version. In most cases, you should select the latest version of a function.

add function

While you can select functions directly, we recommend first adding content like Workshop applications and then selecting relevant functions via the dependencies panel as below.

add function via panel

Function overrides at installation

It is possible to modify parts of a function’s behavior at install time by providing a locally defined function which overrides the “static” function input that is shipped with your Marketplace product. To do this, you can specify that a particular function may be overridden by using the @Static decorator.

For example, consider a function that negates a given number:

// Normal Function

import { Function, Double } from "@foundry/functions-api";

export class MyFunctions {

    @Function()
    public async modifyNumber(d: Double): Promise<Double> {
        return -d;
    }

}

To make this function overridable, rewrite it as follows:

// Overridable Function

import { Function, Static, Double } from "@foundry/functions-api";

export class MyFunctions {

    @Function()
    public async modifyNumberByStaticFoo(
        n: Double, 
        @Static() staticFunctionInput: (num: Double) => Promise<Double> = this.defaultFoo
        ): Promise<Double> {
        return await staticFunctionInput(n);
    }

    private async defaultFoo(n: number) {
        return -n;
    }

}

When packaging a static function, inputs will appear as staticFunctionInputs during installation, as shown below. Installers can then provide their own function logic that will override the default behavior. Conceptually, the staticFunctionInputs serve as function input parameters to the overridable function.

function override

For example, you may have a supply chain optimization function whose logic needs slight adjustments in another context. To allow this, specify that the function is overridable before packaging it, and then override it during installation.