如何使用 databricks 上的 init bash 脚本从私有 git 存储库安装 python 包?

问题描述 投票:0回答:1

我正在尝试使用我上传到我的 s3 存储桶的 init.sh 脚本从私人 github 存储库 pip 安装 python 包。

这是我的 init.sh 文件

#!/bin/bash
TOKEN={{secrets/private-repo/github}}
pip install git+https://${TOKEN}@github.com/<path-to-repo>

当我尝试创建集群时,收到以下错误消息。 初始化脚本失败:

Cluster scoped init script s3://<s3_bucket>/init.sh failed: Script exit status is non-zero

我通过 API 创建一个秘密,其范围和密钥为

private-repo
github
。我用笔记本测试了这个,效果很好。

使用的文档: https://docs.databricks.com/security/secrets/secrets.html#reference-a-secret-in-an-environment-variable

databricks init
1个回答
2
投票

问题是您尝试使用

{{secrets/private-repo/github}}
语法引用秘密,但它在 init 脚本内部不起作用。

您需要在集群级别定义一个环境变量并在那里使用该秘密语法,然后它将在您的初始化脚本中可用。请参阅有关该主题的文档

将此行从初始化脚本添加到

Cluster > Advanced options > Spark > Environment variables
部分。

TOKEN={{secrets/private-repo/github}}
© www.soinside.com 2019 - 2024. All rights reserved.