Model connectivity & developmentManage a modeling projectModeling deployment FAQDirectly publish models as a function

Directly publish models as a function

Models in Foundry can be directly published as a function provided they satisfy the requirements detailed below. This enables usage of models for live inference in Workshop, Vertex and other end-user facing applications. This can be done both from either a model with a direct deployment, or from a Modeling Objective with a live deployment. Both methods are functionally equivalent.

While these functions are simple wrappers around the model, more complex logic can be created by calling them in your code in a Functions repository.

Model requirements

To support direct publishing :

Publish a model as a Function with direct model deployments

To publish a supported model as a Function with a direct model deployment, you must first create a direct model deployment. Once your direct model deployment is running, select the plus + icon in the sidebar and provide a model Function name. This Function will automatically upgrade with each new model version published to the model's branch.

Publish a Function direct model deployment from a model.

Publish a model as a Function in modeling objectives

To publish a supported model as a Function through a modeling objective, you must first create a live deployment. Once your model is running, navigate to the Details page of the deployment. From here, the Publish Function card will be visible.

Function publish card

Select the Publish Function button. You will then be guided through the process of setting parameters for the function.

Publish new function dialog

Once your function has been published, the Publish Function card will display which function is backed by the live deployment. As with all functions, you can view your published function in the Ontology Manager, where health information about the deployment is also available.

Ontology manager function view

It is important to be aware that an objective is limited to producing only one function. However, you can still publish new versions of that same function as needed.

Publish a new function version

When a model is retrained, or the deployment's API changes, you may need to publish a new function version. Below are example cases of when and how to publish a new function version.

Model retraining

When a model is retrained without the model's API changing, there is no need to publish a new function version. The current version will still continue to point to the deployment. However, if you choose to publish a new function version, note that the old function version will continue to work.

Model API change

If you attempt to release a model with a different model API to a live deployment, the following warning will appear:

API change warning

Do not ignore this warning. Updating a live deployment to a new model with a different model API will require manual action to fix downstream usage. The dialog will guide you through the process of publishing new function versions for any deployment affected by the release.

Publish new function version dialog

Any usages of the current function version will break if you choose not to publish a new function version. To resolve this issue, return to the Details page of the deployment and publish a new function version from there.

Functions row-wise publishing

For Models that are single tabular input to single tabular output, row-wise function publishing will be enabled by default. This allows the model API to be flattened for each inference call so that executing the function calls one tabular row as input and outputs one tabular row. Alternatively, consider using an Object or ObjectSet directly in the Model API to facilitate use of your Model with Objects in Functions.

For a model API that looks like the following:

Copied!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 @classmethod def api(cls): inputs = { "input_df": pm.Pandas(columns=[("area_code", int), ("num_bedrooms", int), ("num_bathrooms", int)]) } outputs = { "output_df": pm.Pandas(columns=[("area_code", int), ("num_bedrooms", int), ("num_bathrooms", int), ("predicted_price", int)]) } return inputs, outputs

The direct publishing function signature with row wise would look like:

Copied!
1 2 3 4 5 6 7 8 9 10 export async function housingPriceModelingObjective(parameters: { "area_code": FunctionsApi.Integer; "num_bedrooms": FunctionsApi.Integer; "num_bathrooms": FunctionsApi.Integer; }): Promise<{ "predicted_price": FunctionsApi.Double; "num_bathrooms": FunctionsApi.Integer; "area_code": FunctionsApi.Integer; "num_bedrooms": FunctionsApi.Integer; }>

The direct publishing function signature without row wise would look like:

Copied!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 export async function housingPriceModelingObjective(parameters: { "input_df": Array<{ "num_bathrooms": FunctionsApi.Integer; "area_code": FunctionsApi.Integer; "num_bedrooms": FunctionsApi.Integer; }>; }): Promise<{ "output_df": Array<{ "predicted_price": FunctionsApi.Double; "num_bathrooms": FunctionsApi.Integer; "area_code": FunctionsApi.Integer; "num_bedrooms": FunctionsApi.Integer; }>; }>

To enable or disable row-wise processing for a given function, a new function version must be published and row-wise processing can be toggled under Advanced options.