【问题标题】:I/O operations with Azure Databricks REST Jobs API使用 Azure Databricks REST Jobs API 的 I/O 操作
【发布时间】:2020-07-06 14:21:37
【问题描述】:

我想通过以下方式使用 REST Jobs API 执行 Azure Databricks 笔记本的内容:

  1. 将一组 key:value 参数传递给笔记本的 PySpark 上下文
  2. 根据参数执行一些 Python 计算

对于第 1 点,我使用以下内容(如文档 here 所建议的那样):

curl -n -X POST -H 'Content-Type: application/json' -d '{"name": "endpoint job", "existing_cluster_id": "xxx", "notebook_task": {"notebook_path": "path"}, "base_parameters": {"input_multiple_polygons": "input_multiple_polygons", "input_date_start": "input_date_start", "input_date_end": "input_date_end" }}' https://yyy.azuredatabricks.net/api/2.0/jobs/runs/submit

为了解决第 2 点,我尝试了以下方法但没有成功:

2.1.方法一input = spark.conf.get("base_parameters", "default")

2.2.方法二input = spark.sparkContext.getConf().getAll()

2.3.方法3

a = dbutils.widgets.getArgument("input_multiple_polygons", "default")

b = dbutils.widgets.getArgument("input_date_start", "default")

c = dbutils.widgets.getArgument("input_date_end", "default")

input = [a,b,c]

2.4.方法4(根据官方文档here):

a = dbutils.widgets.get("input_multiple_polygons")

b = dbutils.widgets.get("input_date_start")

c = dbutils.widgets.get("input_date_end")

input = [a,b,c]

REST 作业端点工作正常并且执行成功,但是,上述四种方法似乎都无法将参数传递给 PySpark 上下文。

我确定我在 curl 部分或 args 检索部分中做了一些不正确的事情,但我无法确定问题所在。谁能建议问题出在哪里?

【问题讨论】:

  • 如果答案对您有帮助,您可以接受它作为答案(单击答案旁边的复选标记,将其从灰色切换为已填充。)。这对其他社区成员可能是有益的。谢谢。

标签: databricks azure-databricks


【解决方案1】:

看起来您没有将 base_parameter 作为一个元素包含在 notebook_task 中。你可以试试下面的东西吗?我假设您正在为 base_parameters 传递正确的值,因为示例共享显示参数值与参数名称相同。

curl -n -X POST -H 'Content-Type: application/json' -d '{"name": "endpoint job", "existing_cluster_id": "xxx", "notebook_task": {"notebook_path": "path", "base_parameters": {"input_multiple_polygons": "input_multiple_polygons", "input_date_start": "input_date_start", "input_date_end": "input_date_end" }}}' https://yyy.azuredatabricks.net/api/2.0/jobs/runs/submit

识别其外观的简单方法是使用 UI 定义作业并使用 api/2.0/jobs/get?job_id=<jobId> 查看 JSON 响应。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-10
    相关资源
    最近更新 更多