snow package create

将 Python 包创建为 zip 文件,该文件可以上传到暂存区并导入到 Snowpark Python 应用程序。

语法

snow snowpark package create
  <name>
  --ignore-anaconda
  --index-url <index_url>
  --skip-version-check
  --allow-shared-libraries
  --connection <connection>
  --host <host>
  --port <port>
  --account <account>
  --user <user>
  --password <password>
  --authenticator <authenticator>
  --workload-identity-provider <workload_identity_provider>
  --private-key-file <private_key_file>
  --token <token>
  --token-file-path <token_file_path>
  --database <database>
  --schema <schema>
  --role <role>
  --warehouse <warehouse>
  --temporary-connection
  --mfa-passcode <mfa_passcode>
  --enable-diag
  --diag-log-path <diag_log_path>
  --diag-allowlist-path <diag_allowlist_path>
  --oauth-client-id <oauth_client_id>
  --oauth-client-secret <oauth_client_secret>
  --oauth-authorization-url <oauth_authorization_url>
  --oauth-token-request-url <oauth_token_request_url>
  --oauth-redirect-uri <oauth_redirect_uri>
  --oauth-scope <oauth_scope>
  --oauth-disable-pkce
  --oauth-enable-refresh-tokens
  --oauth-enable-single-use-refresh-tokens
  --client-store-temporary-credential
  --format <format>
  --verbose
  --debug
  --silent
  --enhanced-exit-codes
  --decimal-precision <decimal_precision>

实参

name

要创建的包的名称。

选项

--ignore-anaconda

不在 Snowflake Anaconda 通道上查找包。默认值:False。

--index-url TEXT

Base URL of the Python Package Index to use for package lookup. This should point to a repository compliant with PEP 503 (the simple repository API) or a local directory laid out in the same format.

--skip-version-check

跳过比较需求和 Anaconda 之间的依赖项版本。默认值:False。

--allow-shared-libraries

当使用通过 PIP 安装的包时,允许使用共享 (.so) 库。默认值:False。

--connection, -c, --environment TEXT

Name of the connection, as defined in your config.toml file. Default: default.

--host TEXT

连接的主机地址。替换为连接指定的值。

--port INTEGER

连接的端口。替换为连接指定的值。

--account, --accountname TEXT

分配给 Snowflake 账户的名称。替换为连接指定的值。

--user, --username TEXT

连接到 Snowflake 的用户名。替换为连接指定的值。

--password TEXT

Snowflake 密码。替换为连接指定的值。

--authenticator TEXT

Snowflake 身份验证器。替换为连接指定的值。

--workload-identity-provider TEXT

工作负载身份提供商(AWS、AZURE、GCP、OIDC)。替换为连接指定的值。

--private-key-file, --private-key-path TEXT

Snowflake 私钥文件路径。替换为连接指定的值。

--token TEXT

连接到 Snowflake 时使用的 OAuth 令牌。

--token-file-path TEXT

连接到 Snowflake 时使用的带有 OAuth 令牌的文件路径。

--database, --dbname TEXT

要使用的数据库。替换为连接指定的值。

--schema, --schemaname TEXT

要使用的数据库架构。替换为连接指定的值。

--role, --rolename TEXT

要使用的角色。替换为连接指定的值。

--warehouse TEXT

要使用的仓库。替换为连接指定的值。

--temporary-connection, -x

Uses a connection defined with command-line parameters, instead of one defined in config. Default: False.

--mfa-passcode TEXT

用于多重身份验证的令牌 (MFA)。

--enable-diag

是否生成连接诊断报告。默认值:False。

--diag-log-path TEXT

Path for the generated report. Defaults to system temporary directory. Default: <system_temporary_directory>.

--diag-allowlist-path TEXT

包含允许列表参数的 JSON 文件的路径。

--oauth-client-id TEXT

身份提供商为 Snowflake 集成提供的客户端 ID 的值。

--oauth-client-secret TEXT

身份提供商为 Snowflake 集成提供的客户端密钥的值。

--oauth-authorization-url TEXT

向驱动程序提供授权码的身份提供商端点。

--oauth-token-request-url TEXT

向驱动程序提供访问令牌的身份提供商端点。

--oauth-redirect-uri TEXT

URI 用于授权码重定向。

--oauth-scope TEXT

身份提供商授权请求中请求的范围。

--oauth-disable-pkce

Disables Proof Key for Code Exchange (PKCE). Default: False.

--oauth-enable-refresh-tokens

Enables a silent re-authentication when the actual access token becomes outdated. Default: False.

--oauth-enable-single-use-refresh-tokens

Whether to opt-in to single-use refresh token semantics. Default: False.

--client-store-temporary-credential

存储临时凭据。

--format [TABLE%JSON%JSON_EXT|CSV]

指定输出格式。默认:TABLE。

--verbose, -v

Displays log entries for log levels info and higher. Default: False.

--debug

Displays log entries for log levels debug and higher; debug logs contain additional information. Default: False.

--silent

关闭到控制台的中间输出。默认值:False。

--enhanced-exit-codes

根据错误类型区分退出错误代码。默认值:False。

--decimal-precision INTEGER

Number of decimal places to display for decimal values. Uses Python’s default precision if not specified. [env var: SNOWFLAKE_DECIMAL_PRECISION].

--help

Displays the help text for this command.

使用说明

The snowpark package create command does the following:

  • 创建准备上传到暂存区的构件。
  • Checks for native libraries and asks if you want to continue. If the native libraries are present in the downloaded packages, this command works the same as the snowpark package build command.

示例

  • This example creates a Python package as a zip file that can be uploaded to a stage and later imported by a Snowpark Python app. Dependencies for the “july” package are found on the Anaconda channel, so they were excluded from the .zip file. The command displays the packages you would need to include in requirements.txt of your Snowpark project.

    snow snowpark package create july==0.1
    Package july.zip created. You can now upload it to a stage using
    snow snowpark package upload -f july.zip -s <stage-name>`
    and reference it in your procedure or function.
    Remember to add it to imports in the procedure or function definition.
    
    The package july is successfully created, but depends on the following
    Anaconda libraries. They need to be included in project requirements,
    as their are not included in .zip.
    matplotlib
    contourpy >=1.0.1
    numpy>=1.20
    bokeh
    selenium
    mypy==1.8.0
    Pillow
    pytest-xdist
    wurlitzer
    cycler >=0.10
    fonttools >=4.22.0
    kiwisolver >=1.3.1
    pyparsing >=2.3.1
    jinja2
    python-dateutil >=2.7
    six >=1.5
    importlib-resources >=3.2.0
  • This example creates the july.zip package that you can use in your Snowpark project without needing to add any dependencies to the requirements.txt file. The error messages indicate that some packages contain shared libraries, which might not work, such as when creating a package using Windows.

    snow snowpark package create july==0.1 --ignore-anaconda --allow-shared-libraries
    2024-04-11 16:24:56 ERROR Following dependencies utilise shared libraries, not supported by Conda:
    2024-04-11 16:24:56 ERROR numpy
    contourpy
    fonttools
    kiwisolver
    matplotlib
    pillow
    2024-04-11 16:24:56 ERROR You may still try to create your package with --allow-shared-libraries, but the might not work.
    2024-04-11 16:24:56 ERROR You may also request adding the package to Snowflake Conda channel
    2024-04-11 16:24:56 ERROR at https://support.anaconda.com/
    
    Package july.zip created. You can now upload it to a stage using
    snow snowpark package upload -f july.zip -s <stage-name>`
    and reference it in your procedure or function.
    Remember to add it to imports in the procedure or function definition.
  • This example fails to create the package because it already exists. You can still forcibly create the package by using the --ignore-anaconda option.

    snow snowpark package create matplotlib
    Package matplotlib is already available in Snowflake Anaconda Channel.