Search code examples
pythonsnowflake-cloud-data-platform

How to change the python RUNTIME version of stored procedures deployed with Snowflake CLI?


I have been using Snowflake CLI to orchestrate and deploy stored procedures to Snowflake Data Warehouse.

I have my app setup properly (as described in the documentation: Snowflake CLI project definition) in my local repo:

enter image description here

Everything works as expected. To deploy my app, I just use the snow snowpark deploy --replace command.

This is an example of one of the stored procedure I have deployed (which works perfectly):

enter image description here

However, I have come across the following information about Python runtime_version support:

  • Stage One: Starting October 14, 2024, Snowflake will no longer apply security patches or other updates to the Python 3.8 runtime, and objects using the Python 3.8 runtime will no longer be eligible for technical support.
  • Stage Two: Starting March 31, 2025, you will no longer be able to create new objects using Python 3.8.

I tried to search in the documentation available a way of changing the default python's runtime version for the deployed stored procedures, but I was not able to find anything. I tried to execute snow snowpark deploy --env RUNTIME_VERSION='3.9' --replace command instead, but it didn't work.

Is there a way we can change the runtime version?

See:

  1. Status of Python versions
  2. Snowflake Python Runtime Support

Solution

  • If you're using the latest version of the cli (v3.0.1 is what I tested with) then the default runtime version is 3.10.

    In any case, you can change that by providing the 'runtime' property. For example, here's my hello procedure definition in my snowflake.yml file:

      hello_procedure:
    type: procedure
    identifier:
      name: hello_procedure
    handler: procedures.hello_procedure
    runtime: 3.9
    signature:
      - name: name
        type: string
    returns: string
    meta:
      use_mixins:
        - snowpark_shared
    

    The result is the following create stored procedure SQL statement:

    create or replace procedure IDENTIFIER('SNOWPARK_EXAMPLE.TEST_SCHEMA.hello_procedure')(name string)
    copy grants
    returns string
    language python
    runtime_version=3.9
    imports=('@SNOWPARK_EXAMPLE.TEST_SCHEMA.dev_deployment/my_snowpark_project/app.zip')
    handler='procedures.hello_procedure'
    packages=('snowflake-snowpark-python')
    

    runtime_version would have pointed to 3.10 if I haven't provided that in my yml configuration file, because that's the default in the snowflake-cli version 3.0.1. I had to build that from source though using the instructions here.