【问题标题】:Execute git pull on databricks notebook using CLI and/or API使用 CLI 和/或 API 在 databricks 笔记本上执行 git pull
【发布时间】:2021-11-30 22:20:56
【问题描述】:

使用 Databricks Repos,您可以将 git repo 添加到 Databricks 并执行 git 操作,例如 git pull。这是通过单击左上角的分支名称,然后单击“拉”按钮来完成的。

我想在不点击浏览器中的内容的情况下执行此操作。

  • 什么是 Databricks CLI 语法,用于触发给定 repo 上的 git pull?
  • 什么是 Databricks API 端点,用于触发给定 repo 上的 git pull?

我会假设两者都是可能的(this answer 暗示如此),但只提供一个就足以回答我的问题。


有人可能想知道如果拉动不是微不足道的,例如,我期望会发生什么。分支已经发散,或者“您的未分级更改将被拉动...”。在这种情况下,简单地出错就足够了。我打算确保它永远不会通过其他机制发生。

【问题讨论】:

    标签: databricks databricks-cli databricks-rest-api databricks-repos


    【解决方案1】:

    对于 databricks-cli,它是 databricks repos update 命令:

    >databricks repos update -h     
    Usage: databricks repos update [OPTIONS]
    
      Checks out the repo to the given branch or tag. This call returns an error
      if the branch  or tag doesn't exist.
    
    Options:
      --repo-id TEXT  Repo ID
      --path TEXT     Workspace path of the repo object
      --branch TEXT   Branch name
      --tag TEXT      Tag name
    

    即使 repo 在给定的分支上,它也会结帐分支:

    databricks repos update --path /Repos/.... --branch releases
    

    您可以在 following repository 中找到它的工作演示,该演示显示了 Repos 与 Azure DevOps 的集成。

    对于 REST API,有 corresponding endpoint。与 CLI 的唯一区别是它只接受 Repository ID,而不接受路径,但您可以通过 Workspace API 的Get Status endpoint 从路径中找到 Repos ID。您可以找到同一演示存储库的example in the history(请注意,从那时起,Repos API 可能会发生变化)

    【讨论】:

    • 非常感谢 Alex 的出色回答!我在浏览文档时看到了repos update,但不知何故,我认为它正在更新 git 状态之外的其他内容。我猜应该更仔细地阅读。我尝试了你的命令,它们奏效了,非常感谢!
    • 查看 nutter 演示 - 我从一月份开始运行它
    猜你喜欢
    • 1970-01-01
    • 2023-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-27
    • 2021-05-22
    • 1970-01-01
    相关资源
    最近更新 更多