[英]how to send parameters to databricks notebook?
I triggering databricks notebook using the following code:我使用以下代码触发数据块笔记本:
TOKEN = "xxxxxxxxxxxxxxxxxxxx"
headers = {"Authorization": "Bearer %s" % TOKEN}
data = {
"job_id": xx,
"notebook_task": {
"base_parameters": {
"param1":"key1",
"param2": "key2",
}
},
}
resp = requests.post(
"https://xxxxxx.cloud.databricks.com/api/2.0/jobs/run-now",
headers=headers,
data=json.dumps(data),
)
when i try to access it using dbutils.widgets.get("param1")
, im getting the following error:当我尝试使用
dbutils.widgets.get("param1")
访问它时,我收到以下错误:
com.databricks.dbutils_v1.InputWidgetNotDefined: No input widget named param1
I tried using notebook_params also, resulting in the same error.我也尝试使用 notebook_params,导致同样的错误。
base_parameters
is used only when you create a job. base_parameters
仅在您创建作业时使用。 When you trigger it with run-now
, you need to specify parameters as notebook_params
object ( doc ), so your code should be :当您使用
run-now
触发它时,您需要将参数指定为notebook_params
对象( doc ),因此您的代码应该是:
data = {
"job_id": xx,
"notebook_params": {
"param1":"key1",
"param2": "key2",
},
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.