Cortex Sandboxes quickstart¶
Run your first command in an isolated Linux container in your Snowflake account. After you install, run the command with either the CLI or the Python SDK.
Before you start¶
You need Python 3.11 or later, pip, and a Snowflake account with Cortex Sandboxes enabled. To get access, contact your Snowflake account representative.
Install¶
This installs the SDK and the snow sandbox CLI plugin together. If you already have Snowflake CLI, install into the Python environment it runs from, so it can find the plugin. If snow sandbox is an unknown command after this step, see CLI-specific issues.
Set up a connection¶
To see the Snowflake connections you have, run:
If the list is empty, create one and test it. Follow the prompts, then use the name you chose in place of your_connection on this page:
Make it your default connection. The CLI guide and the tutorials use the default connection when you don’t name one:
Run a command with the CLI¶
Use this path to try a sandbox from your terminal without writing any code.
The CLI creates the sandbox, runs the command, and removes the sandbox when the command finishes.
To run a Python file instead, pass its path:
Run a command with the Python SDK¶
Use this path when you want to create sandboxes from your own code.
Save this as hello.py:
Important
Run hello.py from a local terminal, not from a Snowflake Workspace. A sandbox created from a Workspace doesn’t get the credentials it needs to connect back to Snowflake.
Run it:
The with block creates the sandbox and removes it when the block ends, including when the command raises an error. You don’t need a separate cleanup step.
Next steps¶
- Tutorial: Work with sandboxes using the Python SDK: named sandboxes, detached tasks, querying Snowflake from inside a sandbox, and running many sandboxes in parallel.
- Working with the Cortex Sandboxes CLI: run directories and App modules, detached runs, logs, and the interactive terminal.
- Connect to Snowflake from the SDK: other ways to supply credentials, such as environment variables.
- Cortex Sandboxes tutorials: governance, secrets and egress, and agent frameworks.
- Troubleshooting Cortex Sandboxes: common errors and what they mean.