我想从 python 文件运行 azure databricks 笔记本,我有 client_id、secret 和 token id。我尝试通过创建 databricks 客户端来运行它,但似乎没有可以运行 databricks 笔记本的包。 TIA 如有任何建议
答案应该像我们运行数据工厂一样运行数据砖笔记本,就像这段代码一样
adf_client = DataFactoryManagementClient(credentials, subscription_id)
run_response = adf_client.pipelines.create_run(rg_name, df_name, df_pipeline_name, parameters=...............
pipeline_run = adf_client.pipeline_runs.get(rg_name, df_name, run_response.run_id)
status = pipeline_run.status
while status == 'Queued' or status == 'InProgress':
time.sleep(5)
status = adf_client.pipeline_runs.get(rg_name, df_name, run_response.run_id).status
最佳答案
您可以使用 databricks Rest API 来触发 databricks 作业。您必须首先使用集群和笔记本配置作业。
您可以查看this blog这证明了这一点。该博客讨论了通过 postman 调用 API。您只需将其替换为 python 代码即可。
触发作业的官方databricks Rest API文档可以找到here 。 Databricks documentation还展示了如何使用 python 代码调用 API。
您可以使用 databricks token 或 AAD 不记名 token 进行授权。
关于python - 无法从 python 文件运行 azure databricks,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75206084/