如何添加新的python包装雪板

发布于 2025-02-12 07:17:24 字数 254 浏览 1 评论 0原文

我正在为python使用Snowpark。 我想导入imblearn软件包,但是当我在 https://repo.anaconda。 com/pkgs/snowflake/此包装未安装在Snowpark Anaconda中 环境。如何在雪板上使用此软件包?

I am using Snowpark for Python.
I want to import imblearn package but when I check pre-installed packages at https://repo.anaconda.com/pkgs/snowflake/ this package is not installed in the Snowpark anaconda environment. How can use this package on snowpark?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

盗心人 2025-02-19 07:17:24

由Anaconda构建和提供的许多开源第三方Python软件包可在雪花内部使用。

雪花不断增加新包装。但是,如果您找不到特定的软件包,则

  • 首先检查该软件包是否只有本机Python代码(纯Python软件包),如果是的,请安装到本地包裹,将其安装到雪花舞台上并在导入参数或add_import()方法中添加此阶段路径。这应该起作用。

  • 如果没有,只要等待它可用。

同样在雪花中,您可以使用此查询来获取有关包装的详细信息:
选择 *来自inforys_schema.packages whenglagenage ='python';

A number of open source third-party Python packages that are built and provided by Anaconda are made available to use out of the box inside Snowflake.

Snowflake is constantly adding new packages. But if you don't find a specific package then

  • First check if the package has only native python code(pure python package), if so, then install the package to your local, zip it and put it to the snowflake stage and add this stage path in the imports parameter or add_import() method. This should work.

  • If not, all one can do is wait for it to be available.

Also in snowflake you can use this query to get the details about the packages:
select * from information_schema.packages where language = 'python';

带上头具痛哭 2025-02-19 07:17:24

如果您要使用的软件包只有本机Python代码,则可以使用它。

最简单的方法是将软件包安装到您的本地环境中,然后将安装目录缩回,并在使用 imports 参数时添加zip create function add_import时()方法如果使用雪板API。

If the package you want to use only have native Python code then you might be able to use it.

Simplest way is to install the package into your local environment and then zip the installation directory and and add that zip using the IMPORTS parameter when using CREATE FUNCTION or the add_import() method if using Snowpark API.

自此以后,行同陌路 2025-02-19 07:17:24

我们已经做了同样的事情,但是对于shap

您需要在本地安装软件包,然后将该软件包拉动。

pip install -t shap shap
cd shap
zip -r shap.zip shap/

然后将该邮政编码复制到S3位置,为此您有一个雪花阶段。在下面的示例中,我们的阶段是python_packages

然后,使用add_import将Snowpark指导使用它...

from snowflake.snowpark import Session
from snowflake.snowpark.types import StringType

session = Session.builder.configs(connection_parameters).create()
session.add_import("@PYTHON_PACKAGES/shap.zip")
session.add_packages("numpy", "pandas==1.3.5","scipy","scikit-learn", "numba", "slicer", "tqdm")

def test():
    import shap
    return shap.__version__

test_udf = session.udf.register(
    name="TEST",
    func=test,
    replace=True,
    return_type=StringType()
)
session.sql("select test()").show()

We've done the same, but for shap.

You need to install the package locally and zip up that package.

pip install -t shap shap
cd shap
zip -r shap.zip shap/

Then copy that zip file to an S3 location, for which you have a Snowflake stage. In the example below, our stage is PYTHON_PACKAGES.

Then, use add_import to direct Snowpark to use it...

from snowflake.snowpark import Session
from snowflake.snowpark.types import StringType

session = Session.builder.configs(connection_parameters).create()
session.add_import("@PYTHON_PACKAGES/shap.zip")
session.add_packages("numpy", "pandas==1.3.5","scipy","scikit-learn", "numba", "slicer", "tqdm")

def test():
    import shap
    return shap.__version__

test_udf = session.udf.register(
    name="TEST",
    func=test,
    replace=True,
    return_type=StringType()
)
session.sql("select test()").show()
苏大泽ㄣ 2025-02-19 07:17:24

我使用snowsql和雪花中的工作表做到了这一点

I did this using SnowSQL, and a worksheet within Snowflake

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文