Specific models in Foundry can be directly published as a function. This approach is similar to functions on models and includes the same benefits, but direct publishing offers a more streamlined, no-code method for operationalizing a model.
To support direct publishing, models must meet the following requirements:
The model API below is supported by direct publishing:
Copied!1 2 3 4 5 6 7 8 9 10 11
def api(cls): inputs = [ ModelInput.Parameter(name="sepal_length", type=float), ModelInput.Parameter(name="sepal_width", type=float), ModelInput.Parameter(name="petal_length", type=float), ModelInput.Parameter(name="petal_width", type=float), ] outputs = [ ModelOutput.Parameter(name="prediction", type=str) ] return ModelApi(inputs, outputs)
Though the model API below is valid, it cannot be directly published as a function because it takes in tabular inputs and returns multiple outputs:
Copied!1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
def api(cls): inputs = [ ModelInput.Tabular( name="table_1", df_type=DFType.PANDAS, columns=[ModelApiColumn(name="text", type=str, required=True)], ), ModelInput.Tabular( name="table_2", df_type=DFType.PANDAS, columns=[ModelApiColumn(name="text", type=str, required=True)], ), ModelInput.Parameter(name="suffix", type=str, required=False), ] outputs = [ ModelOutput.Tabular(name="table_1_out", columns=[]), ModelOutput.Tabular(name="table_2_out", columns=[]), ] return ModelApi(inputs, outputs)
For model APIs that are not supported by direct publishing, use functions on models.
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.
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.
Select the Publish Function button. You will then be guided through the process of setting parameters for the function.
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.
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.
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.
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.
If you attempt to release a model with a different model API to a live deployment, the following warning will appear:
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.
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.