Search code examples
pythonsnowflake-cloud-data-platform

How to install a locally developed python wheel file as part of a native Snowflake app


I am trying to install a local python wheel file as part of a Snowflake native app.

I tried the steps in the following article: https://medium.com/snowflake/introducing-simple-workflow-for-using-python-packages-in-snowpark-928f667ff1aa

But, I keep getting the following error:

093082 (42601): 01b44791-0102-aab9-0000-0002b61281f9: Failed to execute setup script:
Uncaught exception of type 'STATEMENT_ERROR' on line 34 at position 0 : SQL compilation error: Package 'perpetual' is not supported.

The only difference is that they use a package from pypi in the medium article but I am trying to install a local wheel file.

Is there a way to install locally developed python wheel file as part of a native Snowflake app?


Solution

  • There isn't enough context in your question to give a definite answer. The following code works to incorporate a Python wheel file in a Python UDF. Perhaps you can use a similar technique in your code. First, the wheel file must be uploaded into a Snowflake stage. Then you append the wheel file to the Python system path.

    CREATE OR REPLACE FUNCTION ULID()
    RETURNS VARCHAR(16777216)
    LANGUAGE PYTHON
    RUNTIME_VERSION = '3.8'
    HANDLER = 'ulid'
    IMPORTS = ('@PYTHON_PACKAGES/python_ulid-1.1.0-py3-none-any.whl')
    AS '
    import sys
    
    import_dir = sys._xoptions.get("snowflake_import_directory")
    sys.path.append(import_dir + "python_ulid-1.1.0-py3-none-any.whl")
    from ulid import ULID
    
    def ulid():
      a_ulid = ULID()
      return str(a_ulid)
    ';