Develop ML workflows locally

You can develop Snowflake ML code in an IDE on your machine, such as CoCo Desktop, Visual Studio Code (VS Code), or Cursor, and run resource-intensive work on Snowflake Container Runtime as ML Jobs. Your code connects to Snowflake through a Snowpark session, so the same code works in any local IDE.

For other ways to develop ML workflows, see Development environments for Snowflake ML.

Prerequisites

  • An IDE on your machine:
  • A Python environment on your machine, such as a conda or virtual environment. To use notebooks, the environment needs a Jupyter kernel.
  • A compute pool for ML Jobs. For more information, see Prerequisites.

Install Snowflake ML

In your IDE’s terminal, activate your Python environment and install the Snowflake ML Python package. ML Jobs require version 1.35.0 or later:

pip install "snowflake-ml-python>=1.35.0"

For conda installation and other options, see Using Snowflake ML Locally.

Connect to Snowflake

Your IDE and your Python code can share the connections in your connections.toml file. How you set up a connection depends on the IDE:

In your Python code, create a Snowpark session from a connection in the file:

from snowflake.snowpark import Session

session = Session.builder.config("connection_name", "myconnection").create()

Your Python code runs on your machine until you submit it to Container Runtime as an ML Job. The session runs queries in Snowflake. For more information, see Run training on Container Runtime.

Develop ML code

Use Snowflake ML APIs, such as the Feature Store, Experiments, and the Model Registry, from your Python code. Each IDE adds its own tools for writing and running the code.

CoCo Desktop

CoCo Desktop combines a file editor, an integrated terminal, agentic notebooks, and the CoCo agent. To work in a notebook with the agent:

  1. Create or open a Jupyter notebook (.ipynb file).
  2. Select the kernel for your Python environment. If no kernel is attached when the agent needs one, the agent opens the kernel picker.
  3. Ask the agent to work in the notebook, for example to profile a table or train a baseline model. The agent writes and runs cells and reads the results. You can keep or undo each change.

For more information, see Agentic Notebook. To have the agent build ML workflows from natural-language prompts, use the machine-learning skill. For more information, see Agentic ML with Snowflake CoCo.

VS Code and Cursor

The Snowflake Extension for Visual Studio Code runs SQL and integrates with Snowpark Python to provide debugging, syntax highlighting, and autocomplete for SQL in Python code. To work with the CoCo agent in the editor, use CoCo in the Snowflake Extension for Visual Studio Code. For more information, see CoCo in the Snowflake Extension for Visual Studio Code.

To run notebooks, scripts, and terminals on Snowflake-managed compute instead of your machine, use Remote Development with the Snowflake Extension for Visual Studio Code (preview). For more information, see Remote Development with the Snowflake Extension for Visual Studio Code.

Run training on Container Runtime

When training needs more compute than your machine provides, such as GPUs or distributed training, run the code as an ML Job. The job runs on a compute pool, and you manage it from your local code:

from snowflake.ml.jobs import remote

@remote("MY_COMPUTE_POOL", stage_name="payload_stage", session=session)
def train_model(data_table: str):
    # Provide your ML code here, including imports and function calls
    ...

job = train_model("my_training_data")

To submit a script or a multi-file project instead of a function, use submit_file or submit_directory. For more information, see Snowflake ML Jobs.