Using artifact repositories

You can use Snowflake Artifact Repository to install third-party packages in your notebooks.

This preview lets you use Snowflake’s default PyPI Artifact Repository to install PyPI packages with support for package policies. The Snowflake PyPI repo is a schema-level, RBAC-governed object: snowflake.snowpark.pypi_shared_repository.

Privilege requirements

By default, the PUBLIC role has access to the Snowflake PyPI repo. To manage privileges, use the following commands:

-- To revoke access from the PUBLIC role:
REVOKE DATABASE ROLE SNOWFLAKE.PYPI_REPOSITORY_USER FROM ROLE PUBLIC;

-- To grant access to specific roles:
GRANT DATABASE ROLE SNOWFLAKE.PYPI_REPOSITORY_USER TO ROLE <your_user_role>;

Using artifact repositories in Snowsight

You can use artifact repositories in both interactive sessions and scheduled notebooks.

Interactive sessions

  1. Go to Workspaces > Notebooks.

  2. Edit or create a new notebook service.

  3. Choose snowflake.snowpark.pypi_shared_repository from the Artifact Repository dropdown menu.

  4. Select Create and connect.

  5. Install packages by using a Python cell:

    !pip install <package_name>

Scheduled notebooks

In the Scheduling dialog, choose snowflake.snowpark.pypi_shared_repository from the Artifact Repository dropdown menu.

Note

If you’ve selected an artifact repository in the notebook service, you can only install packages from that repository, not through any external access integrations (EAIs).

Setting the default repository

An ACCOUNTADMIN can use a parameter to set the Snowflake PyPI repo as the default. The default repo is automatically selected in the Artifact Repository dropdown, but users can still select a different repository if they have access.

This is an account-level parameter that applies to the notebook service dialogs for all users.

ALTER ACCOUNT SET DEFAULT_PYTHON_ARTIFACT_REPOSITORY = snowflake.snowpark.pypi_shared_repository;

-- To unset the default:
ALTER ACCOUNT UNSET DEFAULT_PYTHON_ARTIFACT_REPOSITORY;

Headless execution with SQL

When you use the EXECUTE NOTEBOOK PROJECT command in scheduling and production workloads, include the ARTIFACT_REPOSITORIES parameter as an optional argument.

EXECUTE NOTEBOOK PROJECT <database_name>.<schema_name>.<project_name>
  MAIN_FILE = 'notebook.ipynb'
  COMPUTE_POOL = '<compute_pool_name>'
  QUERY_WAREHOUSE = '<warehouse_name>'
  RUNTIME = '<runtime_version>'
  [ ARGUMENTS = '<parameter_string>' ]
  [ REQUIREMENTS_FILE = '<path/to/requirements.txt>' ]
  [ EXTERNAL_ACCESS_INTEGRATIONS = ( <integration_name> ) ]
  [ ARTIFACT_REPOSITORIES = snowflake.snowpark.pypi_shared_repository ];

Note

If both EXTERNAL_ACCESS_INTEGRATIONS and ARTIFACT_REPOSITORIES parameters are specified, packages are only installed from the artifact repositories.