Skip to content

ModelManager

Helper class to manage trained and registered models.

NameTypeDescriptionOptional
connectorSnowflakeConnectorThe connector object used for sending requests to the GNN engine.No

An instance of the ModelManager class.

from relationalai_gnns import ModelManager
model_manager = ModelManager(connector =connector)

Lists all models that have been trained and registered.

Returns:
A dictionary containing:

Example:

from relationalai_gnns import ModelManager
model_manager = ModelManager()
model_manager.list_models()

Permanently deletes a trained model from the RelationalAI application stage.

Parameters:

NameTypeDescriptionOptional
model_run_idstrUnique identifier of the trained model run.No

Example:

from relationalai_gnns import ModelManager
model_manager = ModelManager()
model_manager.delete_model(
model_run_id="abc123"
)

Registers a trained model in the Snowflake Model Registry.
The model is stored under the specified name and version in the database and schema where the tracker has permissions.
Registration is only allowed if a valid model_run_id exists.
Duplicate version names for a model are not allowed.

⚠️ Note: Ensure the native app has the necessary permissions to the specified database and schema.

-- Grant access to resources needed to register a model in Snowflake.
GRANT USAGE ON DATABASE <DATABASE> TO APPLICATION RELATIONALAI;
GRANT USAGE ON SCHEMA <DATABASE>.<SCHEMA> TO APPLICATION RELATIONALAI;
GRANT CREATE MODEL ON SCHEMA <DATABASE>.<SCHEMA> TO APPLICATION RELATIONALAI;

Parameters:

NameTypeDescriptionOptional
model_run_idstrUnique identifier of the trained model run.No
model_namestrName to assign to the registered model.No
version_namestrVersion name for the model.No
database_namestrDatabase where the model will be registered.No
schema_namestrSchema in the database where the model will be registered.No
commentstrOptional comment for model registration.Yes

Example:

from relationalai_gnns import ModelManager
model_manager = ModelManager()
model_manager.register_model(
model_run_id=train_job.model_run_id,
model_name="new_model",
version_name="v3",
database_name="database_name",
schema_name="schema_name",
comment="Production-ready model",
)