{"id":5486,"library":"snowflake-ml-python","title":"Snowflake ML Python Library","description":"The Snowflake ML Python Library (snowflake-ml-python) is the official client for interacting with Snowflake to build and deploy machine learning solutions. It provides interfaces for machine learning lifecycle management including session management, model development, model registry, feature store, and experiment tracking. The library is actively maintained with frequent minor releases, typically on a monthly to bi-monthly cadence, and is currently at version 1.34.0.","status":"active","version":"1.34.0","language":"en","source_language":"en","source_url":"https://github.com/snowflakedb/snowflake-ml-python","tags":["snowflake","machine-learning","ml","data-science","cloud","snowpark"],"install":[{"cmd":"pip install snowflake-ml-python","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"Required to establish the underlying Snowpark connection.","symbol":"Session","correct":"from snowflake.snowpark import Session"},{"note":"Obtains the ML-specific session object, typically from an existing Snowpark Session.","symbol":"get_session","correct":"from snowflake.ml.session import get_session"},{"note":"Main class for interacting with the Snowflake Model Registry.","symbol":"Model","correct":"from snowflake.ml.model import Model"},{"note":"Provides methods for managing models in the Snowflake Model Registry.","symbol":"Registry","correct":"from snowflake.ml.registry import Registry"}],"quickstart":{"code":"import os\nfrom snowflake.snowpark import Session\nfrom snowflake.ml.session import get_session\n\n# Ensure environment variables are set for connection:\n# SNOWFLAKE_ACCOUNT, SNOWFLAKE_USER, SNOWFLAKE_PASSWORD, SNOWFLAKE_ROLE,\n# SNOWFLAKE_WAREHOUSE, SNOWFLAKE_DATABASE, SNOWFLAKE_SCHEMA\nconnection_parameters = {\n    \"account\": os.environ.get(\"SNOWFLAKE_ACCOUNT\", \"your_account\"),\n    \"user\": os.environ.get(\"SNOWFLAKE_USER\", \"your_user\"),\n    \"password\": os.environ.get(\"SNOWFLAKE_PASSWORD\", \"your_password\"),\n    \"role\": os.environ.get(\"SNOWFLAKE_ROLE\", \"your_role\"),\n    \"warehouse\": os.environ.get(\"SNOWFLAKE_WAREHOUSE\", \"your_warehouse\"),\n    \"database\": os.environ.get(\"SNOWFLAKE_DATABASE\", \"your_database\"),\n    \"schema\": os.environ.get(\"SNOWFLAKE_SCHEMA\", \"your_schema\"),\n}\n\nsession = None\ntry:\n    # Establish a Snowpark Session\n    session = Session.builder.configs(connection_parameters).create()\n    print(\"Snowpark Session created successfully.\")\n    print(f\"Current database: {session.get_current_database()}, schema: {session.get_current_schema()}\")\n\n    # Obtain the Snowflake ML Session (uses the Snowpark session)\n    ml_session = get_session(session)\n    print(\"Snowflake ML Session obtained successfully.\")\n\n    # You can now use ml_session for various ML tasks, e.g.,\n    # ml_session.model.deploy(...)\n    # ml_session.feature_store.register_feature_view(...)\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\nfinally:\n    if session:\n        session.close()\n        print(\"Snowpark Session closed.\")","lang":"python","description":"This quickstart demonstrates how to establish a Snowflake ML Session by first creating a Snowpark Session using environment variables for connection parameters. This session is the entry point for all operations within the snowflake-ml-python library."},"warnings":[{"fix":"Grant `USAGE` privilege on the model and required schema/database objects to the executing role. Always verify required privileges in the official Snowflake documentation.","message":"Incorrect permissions can prevent model inference. Previously, `model_version.run()` required `READ` privilege on the model instead of `USAGE`, leading to failures. While fixed in 1.27.0, ensure your Snowflake role has appropriate `USAGE` grants on the model and other necessary objects.","severity":"gotcha","affected_versions":"<1.27.0 (bug), all (general permission issue)"},{"fix":"Ensure all identifiers (table names, column names) that are case-sensitive or contain special characters are consistently quoted and handled correctly throughout your Snowflake objects and Python code. Upgrade to 1.34.0+ for fixes related to Feature Store SQL generation.","message":"Handling case-sensitive or Unicode identifiers (e.g., Japanese column names) can lead to errors due to incorrect quoting in generated SQL. This particularly affected `generate_dataset()` and `generate_training_set()` for Feature Store operations.","severity":"gotcha","affected_versions":"<1.34.0 (bug), all (general Snowflake behavior)"},{"fix":"Consult the latest documentation for `ParamSpec` usage. Test thoroughly when combining `ParamSpec` with complex deployment scenarios (e.g., partitioned inference, custom handlers). Upgrade to recent versions for improved support and stability.","message":"Using `ParamSpec` (inference parameters) with table functions or partitioned model methods has historically had issues, leading to runtime failures or incorrect behavior. While fixes have been released, understanding the nuances of `ParamSpec` with various model types (custom, sklearn, PyTorch) and deployment configurations is crucial.","severity":"gotcha","affected_versions":"<1.29.0 (bug), <1.32.0 (limited support), all (complexity)"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}