Snowflake CLI: Where It Wins Over Snowsight
Summary
The Snowflake CLI (the "snow" command) offers a robust development environment for Snowpark Python UDFs and Streamlit apps, addressing limitations of the Snowsight web interface for complex projects. While Snowsight excels at ad hoc SQL and data exploration, the CLI provides essential features like version control, local testing, and repeatable builds. The article demonstrates this by detailing the process of building, testing, and deploying a Python UDF for phone number cleaning, which requires the `phonenumbers` package. Key steps include installing the CLI, scaffolding a project with `snow init --template example_snowpark`, defining the UDF and its dependencies in `snowflake.yml` and `requirements.txt`, performing local unit tests with `pytest` in 16 milliseconds, and deploying via `snow snowpark deploy`. This workflow enables environment swapping via named connection profiles and ensures dependencies are resolved against Snowflake's Anaconda channel, contrasting with Snowsight's manual, UI-driven approach.
Key takeaway
For MLOps Engineers or Software Engineers shipping Snowpark pipelines or Streamlit apps, you should adopt the Snowflake CLI for your development workflow. It enables critical practices like local unit testing, declarative dependency management via `requirements.txt`, and version control, which Snowsight lacks. This approach significantly reduces debugging cycles and ensures repeatable, scalable deployments across environments, making it indispensable for collaborative projects and CI/CD integration.
Key insights
The Snowflake CLI provides a robust, scalable development environment for Snowpark and Streamlit, surpassing Snowsight for complex, collaborative projects.
Principles
- Development environments require version control.
- Local testing reduces debug cycles and costs.
- Declarative manifests enable repeatable deployments.
Method
The method involves installing the CLI, scaffolding a project with `snow init`, defining functions and dependencies in `snowflake.yml` and `requirements.txt`, local unit testing with `pytest`, and deploying via `snow snowpark deploy`.
In practice
- Use `snow init` for project scaffolding.
- Define dependencies in `requirements.txt`.
Topics
- Snowflake CLI
- Snowpark
- Python UDFs
- Streamlit
- Local Testing
- Dependency Management
- CI/CD
Best for: Machine Learning Engineer, MLOps Engineer, Software Engineer
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by Data Engineering on Medium.