gpt4 book ai didi

azure - 在 databricks 笔记本中找不到导入库

转载 作者:行者123 更新时间:2023-12-03 03:44:02 26 4
gpt4 key购买 nike

使用 Azure Devops 管道任务,我导入 azure.databricks.cicd.tools 库并安装 azure-identity 和 azure-keyvault-secrets。当我使用不记名 token 和集群 ID 将这些库添加到集群时,这些库可以很好地安装到集群上,但是当我运行笔记本时,它显示找不到导入模块。你能帮我看看我哪里出错了吗?

    - task: AzurePowerShell@5
inputs:
azureSubscription: xxxxx
ScriptType: InlineScript
Inline: |
Install-Module -Name azure.databricks.cicd.tools -Force -Scope CurrentUser
azurePowerShellVersion: LatestVersion

- task: AzurePowerShell@5
inputs:
azureSubscription: xxxxx
ScriptType: InlineScript
Inline: |
Import-Module -Name azure.databricks.cicd.tools
Add-DatabricksLibrary -BearerToken $(az-bearer-token) -Region $(az-region) -LibraryType "pypi" -LibrarySettings 'azure-identity' -ClusterId 'xxxxxx'
Add-DatabricksLibrary -BearerToken $(az-bearer-token) -Region $(az-region) -LibraryType "pypi" -LibrarySettings 'azure.keyvault.secrets' -ClusterId 'xxxxx'
azurePowerShellVersion: LatestVersion

接着是......

   - task: configuredatabricks@0
- task: DataThirstLtd.databricksDeployScriptsTasks.databricksDeployScriptsTask.databricksDeployScripts@0
- task: executenotebook@0

Library successfully installed on to the cluster

Databricks notebook:
from azure.identity import ClientSecretCredential
from azure.keyvault.secrets import SecretClient
credential = ClientSecretCredential(directory_id, sp_client_id, sp_client_secret, 'login.microsoftonline.com')

Error message:

ImportError: No module named azure.identity

最佳答案

库的安装不是同步的 - 当您执行 Add-DatabricksLibrary 命令时,它会调用 Libraries REST APIinstall 端点,文档说:

The installation is asynchronous - it completes in the background after the request.

您可以使用 Cluster status REST API检查所有库是否都处于 INSTALLED 状态,并仅在此之后触发笔记本。 (我在 azure.databricks.cicd.tools 库中没有看到类似的功能)

关于azure - 在 databricks 笔记本中找不到导入库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69953373/

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