gpt4 book ai didi

python - Azure Databricks 集群初始化脚本 - 安装 python 轮

转载 作者:行者123 更新时间:2023-12-03 01:32:25 27 4
gpt4 key购买 nike

我有一个Python脚本,它在databricks中安装一个存储帐户,然后从该存储帐户安装一个轮子。我试图将其作为集群初始化脚本运行,但它一直失败。我的脚本的形式如下:

#/databricks/python/bin/python
mount_point = "/mnt/...."
configs = {....}
source = "...."
if not any(mount.mountPoint == mount_point for mount in dbutils.fs.mounts()):
dbutils.fs.mount(source = source, mount_point = mount_point, extra_configs = configs)
dbutils.library.install("dbfs:/mnt/.....")
dbutils.library.restartPython()

当我直接在笔记本中运行它时它可以工作,但如果我保存到名为 dbfs:/databricks/init_scripts/datalakes/init.py 的文件并将其用作集群初始化脚本,则集群无法启动,错误消息表明 init 脚本的退出状态非零。我检查了日志,看起来它是作为 bash 而不是 python 运行的:

bash: line 1: mount_point: command not found

我尝试从包含这一行的名为 init.bash 的 bash 脚本运行 python 脚本:

/databricks/python/bin/python "dbfs:/databricks/init_scripts/datalakes/init.py"

然后使用init.bash的集群启动失败,日志显示找不到python文件:

/databricks/python/bin/python: can't open file 'dbfs:/databricks/init_scripts/datalakes/init.py': [Errno 2] No such file or directory

谁能告诉我如何让它工作?

相关问题:Azure Databricks cluster init script - Install wheel from mounted storage

最佳答案

我采用的解决方案是运行一个笔记本,该笔记本安装存储并创建一个仅安装轮子的 bash 初始化脚本。像这样的事情:

mount_point = "/mnt/...."
configs = {....}
source = "...."
if not any(mount.mountPoint == mount_point for mount in dbutils.fs.mounts()):
dbutils.fs.mount(source = source, mount_point = mount_point, extra_configs = configs)

dbutils.fs.put("dbfs:/databricks/init_scripts/datalakes/init.bash","""
/databricks/python/bin/pip install "../../../dbfs/mnt/package-source/parser-3.0-py3-none-any.whl"""", True)"

关于python - Azure Databricks 集群初始化脚本 - 安装 python 轮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61077447/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com