Skip to main content
Version: Current

Snowflake Model Registry integration

Overview​

Nussknacker can call models registered in the Snowflake Model Registry and served in Snowpark Container Services. Once the integration is configured, Nussknacker generates an ML Enricher component, which can be used in the scenario to infer ML models.

The ML Enricher lists the models of one Snowflake schema and, for each model, the versions that are served in Snowpark Container Services. The ML Enricher calls the service's public endpoint, so create the service with mv.create_service(..., ingress_enabled=True). It calls the version's predict_proba function when the version has one, otherwise predict. The input fields and their types come from that function's signature in the registry. The ML Enricher reads that signature with SHOW FUNCTIONS IN MODEL, which lists the functions of a version only when the version can run in a warehouse. So log the version with target_platforms=["WAREHOUSE", "SNOWPARK_CONTAINER_SERVICES"], the default outside Container Runtime (see target platforms).

Model outputs​

Snowflake does not tell Nussknacker the names of a model's outputs. The ML Enricher uses the names Snowflake gives when a model is logged without naming them:

Model taskFunctionOutput
binary classificationpredict_probaoutput_feature_0 and output_feature_1, the probabilities of class 0 and class 1
binary or multi-class classification, when the version has no predict_probapredictoutput_feature_0, the class, of the Unknown type: a number, a text or a boolean, as the model returns it
regressionpredictoutput_feature_0, the prediction

Multi-class classifiers logged with snowflake-ml-python have predict_proba, whose outputs Nussknacker cannot tell, so they are not supported yet. Neither are models of other tasks and models logged with custom output names.

Configuration​

Set it up in the Integrations view of the Designer, in the Snowflake ML part of the Snowflake integration. Or put the configuration in the configuration file:

components.fraud-models {
providerType: "snowflakeMl"
componentPrefix: "fraud-"
modelsCache { type: "expiry", modelNames: "30 seconds", modelVersions: "30 seconds", model: "60 minutes" }
snowflake {
accountUrl: "https://<organization>-<account>.snowflakecomputing.com"
token: ${SNOWFLAKE_PAT}
role: "NU_APP"
}
registrySchema: "MY_DB.MODELS"
}

The token is a programmatic access token. Its user must be under a network policy that allows both the Designer and the Nussknacker runtime: both call Snowflake. Its role needs USAGE on the database and schema, READ on the models, and, for each model service, USAGE on the service and the service role <service>!ALL_ENDPOINTS_USAGE.

Each call waits for the model service up to httpClient.timeout (10 seconds by default); in a Flink scenario, the timeout of the model configuration (10 seconds by default) limits it too. A suspended service resumes on the first call, but Snowflake does not hold that call: until the service runs (about 30 seconds for a small model on a CPU node), it answers each call with 503 and the event fails. A service created with min_instances=0 starts on the first call, which can take minutes, and Snowflake closes a connection to a public endpoint after 90 seconds without activity: no timeout bridges these starts, so do not suspend a service that a scenario uses, and keep one instance running for scenarios that must answer.