我如何传递而不是在数据块作业中获取传递的参数

How can I pass and than get the passed arguments in databricks job

我正在尝试在我的数据块作业中传递和获取参数,它是 spark_python_task 类型它不是笔记本。我使用来自 pycharm 的 dbx 部署了我的工作。我有 deployment.json 个配置部署内容的文件。

如果按照documentation about deployment file,可以看到可以指定参数为parameters数组:

{
  "name": "this-parameter-is-required!",
  "spark_python_task": {
      "python_file": "path/to/entrypoint.py" 
  },
  "parameters": [
     "--conf-file",
     "conf/test/sample.json"
  ]
}

参数作为命令行参数传递,因此您可以使用 sys.argv, or built-in argparse library.

从代码中获取它们