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:
- CoCo Desktop, installed and signed in to your Snowflake account. For more information, see Installation, onboarding, and authentication.
- VS Code or Cursor with the Snowflake Extension for Visual Studio Code installed. VS Code installs the extension from the Visual Studio Marketplace. Cursor installs it from the Open VSX registry, where it’s published as
snowflake.snowflake-vsc. For more information, see Snowflake Extension for Visual Studio Code and Install the extension in Cursor from Open VSX.
- 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:
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:
- CoCo Desktop: CoCo Desktop reads connections from your
~/.snowflake/connections.tomlfile and detects existing connections automatically. - VS Code or Cursor: Sign in to Snowflake from the extension. You can also add and edit connection definitions in your
connections.tomlfile from the extension. For more information, see Sign in to Snowflake with the VS Code extension and Edit the Snowflake `connections.toml` file.
In your Python code, create a Snowpark session from a connection in the file:
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:
- Create or open a Jupyter notebook (
.ipynbfile). - Select the kernel for your Python environment. If no kernel is attached when the agent needs one, the agent opens the kernel picker.
- 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:
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.