简体   繁体   English

如何使用 databricks 上的 init bash 脚本从私有 git repo 安装 python package?

[英]How to install python package from private git repo using init bash script on databricks?

I'm trying to pip install a python package from a private github repo using a init.sh script that I uploaded to my s3 bucket.我正在尝试 pip 使用我上传到我的 s3 存储桶的 init.sh 脚本从私有 github 存储库安装 python package。 在此处输入图像描述

This is my init.sh file这是我的 init.sh 文件

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

When I try to create my cluster I get the following error messsage.当我尝试创建我的集群时,我收到以下错误消息。 Init script failure: Cluster scoped init script s3://<s3_bucket>/init.sh failed: Script exit status is non-zero初始化脚本失败: Cluster scoped init script s3://<s3_bucket>/init.sh failed: Script exit status is non-zero

I create a secret through the API with scope and key as private-repo and github .我通过 API 和 scope 创建了一个秘密,密钥为private-repogithub I tested this using a notebook and it worked fine.我用笔记本测试了这个,效果很好。

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

The problem is that you're trying to refer to the secret using the {{secrets/private-repo/github}} syntax, but it doesn't work from the inside of the init script.问题是您正在尝试使用{{secrets/private-repo/github}}语法引用秘密,但它在 init 脚本内部不起作用。

You need to define an environment variable on the cluster level and use that secret syntax there, and then it will be available inside your init script.您需要在集群级别定义一个环境变量并在那里使用该秘密语法,然后它将在您的 init 脚本中可用。 See documentation on that topic.请参阅有关该主题的文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM