本文介绍了如何在 Databricks 资产捆绑包中替代项目设置。 请参阅什么是 Databricks 资产捆绑包?
在 Azure Databricks 捆绑包配置文件中,可以使用 artifacts 映射中的项目设置覆盖顶层 targets 映射中的项目设置,例如:
# ...
artifacts:
<some-unique-programmatic-identifier-for-this-artifact>:
# Artifact settings.
targets:
<some-unique-programmatic-identifier-for-this-target>:
artifacts:
<the-matching-programmatic-identifier-for-this-artifact>:
# Any more artifact settings to join with the settings from the
# matching top-level artifacts mapping.
如果在同一项目的顶级 artifacts 映射和 targets 映射中定义了任何项目设置,则 targets 映射中的设置优先于顶级 artifacts 映射中的设置。
示例 1:仅在顶级项目映射中定义的项目设置
为了实际演示其工作原理,在以下示例中,path 是在顶级 artifacts 映射中定义的,这定义了项目的所有设置(为简单起见,省略号指示省略的内容):
# ...
artifacts:
my-artifact:
type: whl
path: ./my_package
# ...
当你为此示例运行 databricks bundle validate 时,生成的图形为:
{
"...": "...",
"artifacts": {
"my-artifact": {
"type": "whl",
"path": "./my_package",
"...": "..."
}
},
"...": "..."
}
示例 2:在多个项目映射中定义的冲突项目设置
在此示例中,path 是同时在顶级 artifacts 映射和 artifacts 中的 targets 映射中定义的。 在此示例中,path 的 artifacts 映射中的 targets 优先于顶级 path 映射中的 artifacts,可用于定义项目的设置(为简单起见,省略号指示省略的内容):
# ...
artifacts:
my-artifact:
type: whl
path: ./my_package
targets:
dev:
artifacts:
my-artifact:
path: ./my_other_package
# ...
在为此示例运行 databricks bundle validate 时,生成的图形为(为简单起见,省略号指示省略的内容):
{
"...": "...",
"artifacts": {
"my-artifact": {
"type": "whl",
"path": "./my_other_package",
"...": "..."
}
},
"...": "..."
}