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
实参¶
name要创建的包的名称。
选项¶
--ignore-anaconda不在 Snowflake Anaconda 通道上查找包。默认值:False。
--index-url TEXT用于查找包的 Python 包索引的基础 URL。它应指向一个符合 PEP 503 的存储库(简单存储库 API)或以相同格式布局的本地目录。
--skip-version-check跳过比较需求和 Anaconda 之间的依赖项版本。默认值:False。
--allow-shared-libraries当使用通过 PIP 安装的包时,允许使用共享 (.so) 库。默认值:False。
--connection, -c, --environment TEXT连接名称,如您在
config.toml文件中所定义。默认值:default。--host TEXT连接的主机地址。替换为连接指定的值。
--port INTEGER连接的端口。替换为连接指定的值。
--account, --accountname TEXT分配给 Snowflake 账户的名称。替换为连接指定的值。
--user, --username TEXT连接到 Snowflake 的用户名。替换为连接指定的值。
--password TEXTSnowflake 密码。替换为连接指定的值。
--authenticator TEXTSnowflake 身份验证器。替换为连接指定的值。
--workload-identity-provider TEXTWorkload identity provider (AWS, AZURE, GCP, OIDC). Overrides the value specified for the connection.
--private-key-file, --private-key-path TEXTSnowflake 私钥文件路径。替换为连接指定的值。
--token TEXT连接到 Snowflake 时使用的 OAuth 令牌。
--token-file-path TEXT连接到 Snowflake 时使用的带有 OAuth 令牌的文件路径。
--database, --dbname TEXT要使用的数据库。替换为连接指定的值。
--schema, --schemaname TEXT要使用的数据库架构。替换为连接指定的值。
--role, --rolename TEXT要使用的角色。替换为连接指定的值。
--warehouse TEXT要使用的仓库。替换为连接指定的值。
--temporary-connection, -x使用命令行参数定义的连接,而不是在配置中定义的连接。默认值:False。
--mfa-passcode TEXT用于多重身份验证的令牌 (MFA)。
--enable-diag是否生成连接诊断报告。默认值:False。
--diag-log-path TEXT生成的报告的路径。默认为系统临时目录。默认:<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 TEXTURI 用于授权码重定向。
--oauth-scope TEXT身份提供商授权请求中请求的范围。
--oauth-disable-pkce禁用代码交换证明密钥 (PKCE)。默认值:
False。--oauth-enable-refresh-tokens在实际访问令牌过期时启用静默重新身份验证。默认值:
False。--oauth-enable-single-use-refresh-tokens是否选择启用一次性刷新令牌语义。默认值:
False。--client-store-temporary-credential存储临时凭据。
--format [TABLE|JSON|JSON_EXT|CSV]指定输出格式。默认:TABLE。
--verbose, -v显示日志级别
info及更高级别的日志条目。默认值:False。--debug显示日志级别
debug及更高级别的日志条目;调试日志包含其他信息。默认值:False。--silent关闭到控制台的中间输出。默认值:False。
--enhanced-exit-codes根据错误类型区分退出错误代码。默认值:False。
--help显示此命令的帮助文本。
使用说明¶
snowpark package create 命令用于执行以下操作:
创建准备上传到暂存区的构件。
检查原生库并询问是否要继续。如果下载的包中存在原生库,则此命令的工作方式与
snowpark package build命令相同。
示例¶
此示例将 Python 包创建为 zip 文件,该文件可以上传到暂存区,然后由 Snowpark Python 应用程序导入。“july”包的依赖项位于 Anaconda 通道上,因此它们被排除在
.zip文件之外。命令显示您需要包含在 Snowpark 项目的requirements.txt中的包。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
此示例创建您可以在 Snowpark 项目中使用的
july.zip包,而无需向requirements.txt文件添加任何依赖项。错误消息指示某些包包含共享库,这些库可能无法正常工作,例如在使用 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.
此示例无法创建包,因为包已存在。您仍然可以使用
--ignore-anaconda选项强制创建包。snow snowpark package create matplotlib
Package matplotlib is already available in Snowflake Anaconda Channel.