替代 Databricks 资产捆绑包中的群集设置
本文介绍如何替代 Databricks 资产捆绑包中 Azure Databricks 群集的设置。 请参阅什么是 Databricks 资产捆绑包?
在 Azure Databricks 捆绑配置文件中,可以将顶级 resources
映射中的群集设置与 targets
映射中的群集设置合并,如以下所示。
对于作业,请使用作业定义中的 job_cluster_key
映射,将顶级 resources
映射中的群集设置与 targets
映射中的群集设置联接,例如(省略号指示省略的内容,为简洁起见):
# ...
resources:
jobs:
<some-unique-programmatic-identifier-for-this-job>:
# ...
job_clusters:
- job_cluster_key: <some-unique-programmatic-identifier-for-this-key>
new_cluster:
# Cluster settings.
targets:
<some-unique-programmatic-identifier-for-this-target>:
resources:
jobs:
<the-matching-programmatic-identifier-for-this-job>:
# ...
job_clusters:
- job_cluster_key: <the-matching-programmatic-identifier-for-this-key>
# Any more cluster settings to join with the settings from the
# resources mapping for the matching top-level job_cluster_key.
# ...
如果在顶级 resources
映射和同一 job_cluster_key
的 targets
映射中都定义了任何群集设置,则 targets
映射中的设置优先于顶级 resources
映射中的设置。
对于 Delta Live Tables 管道,请使用管道定义的 cluster
内的 label
映射,将顶级 resources
映射中的群集设置与 targets
映射中的群集设置联接起来,例如(省略号指示省略的内容,为简洁起见):
# ...
resources:
pipelines:
<some-unique-programmatic-identifier-for-this-pipeline>:
# ...
clusters:
- label: default | maintenance
# Cluster settings.
targets:
<some-unique-programmatic-identifier-for-this-target>:
resources:
pipelines:
<the-matching-programmatic-identifier-for-this-pipeline>:
# ...
clusters:
- label: default | maintenance
# Any more cluster settings to join with the settings from the
# resources mapping for the matching top-level label.
# ...
如果在顶级 resources
映射和同一 label
的 targets
映射中都定义了任何群集设置,则 targets
映射中的设置优先于顶级 resources
映射中的设置。
示例 1:在多个资源映射中定义的新作业群集设置,且无设置冲突
在此示例中,顶级 resources
映射中的 spark_version
与 resources
映射中 node_type_id
和 num_workers
在 targets
中相结合,以定义名为 my-cluster
的 job_cluster_key
的设置(省略号指示省略的内容,为简洁起见):
# ...
resources:
jobs:
my-job:
name: my-job
job_clusters:
- job_cluster_key: my-cluster
new_cluster:
spark_version: 13.3.x-scala2.12
targets:
development:
resources:
jobs:
my-job:
name: my-job
job_clusters:
- job_cluster_key: my-cluster
new_cluster:
node_type_id: Standard_DS3_v2
num_workers: 1
# ...
为此示例运行 databricks bundle validate
时,生成的图形如下所示(省略号指示省略的内容,为简洁起见):
{
"...": "...",
"resources": {
"jobs": {
"my-job": {
"job_clusters": [
{
"job_cluster_key": "my-cluster",
"new_cluster": {
"node_type_id": "Standard_DS3_v2",
"num_workers": 1,
"spark_version": "13.3.x-scala2.12"
}
}
],
"...": "..."
}
}
}
}
示例 2:在多个资源映射中定义的新作业群集设置存在冲突
在此示例中,spark_version
和 num_workers
在顶级 resources
映射和 targets
的 resources
映射中定义。 在此示例中,targets
中 resources
映射中的 spark_version
和 num_workers
优先于顶级 resources
映射中的 spark_version
和 num_workers
,以定义命名 my-cluster
job_cluster_key
的设置(省略号指示省略的内容,为简洁起见):
# ...
resources:
jobs:
my-job:
name: my-job
job_clusters:
- job_cluster_key: my-cluster
new_cluster:
spark_version: 13.3.x-scala2.12
node_type_id: Standard_DS3_v2
num_workers: 1
targets:
development:
resources:
jobs:
my-job:
name: my-job
job_clusters:
- job_cluster_key: my-cluster
new_cluster:
spark_version: 12.2.x-scala2.12
num_workers: 2
# ...
为此示例运行 databricks bundle validate
时,生成的图形如下所示(省略号指示省略的内容,为简洁起见):
{
"...": "...",
"resources": {
"jobs": {
"my-job": {
"job_clusters": [
{
"job_cluster_key": "my-cluster",
"new_cluster": {
"node_type_id": "Standard_DS3_v2",
"num_workers": 2,
"spark_version": "12.2.x-scala2.12"
}
}
],
"...": "..."
}
}
}
}
示例 3:在多个资源映射中定义的管道群集设置,且无设置冲突
在此示例中,顶级 resources
映射中的 node_type_id
结合了 targets
中 resources
映射中的 num_workers
,以定义名称为 default
的 label
的设置(省略号指示省略的内容,为简洁起见):
# ...
resources:
pipelines:
my-pipeline:
clusters:
- label: default
node_type_id: Standard_DS3_v2
targets:
development:
resources:
pipelines:
my-pipeline:
clusters:
- label: default
num_workers: 1
# ...
为此示例运行 databricks bundle validate
时,生成的图形如下所示(省略号指示省略的内容,为简洁起见):
{
"...": "...",
"resources": {
"pipelines": {
"my-pipeline": {
"clusters": [
{
"label": "default",
"node_type_id": "Standard_DS3_v2",
"num_workers": 1
}
],
"...": "..."
}
}
}
}
示例 4:在多个资源映射中定义的有冲突管道群集设置
在此示例中,num_workers
在顶级 resources
映射和 targets
的 resources
映射中定义。 targets
的 resources
映射中的 num_workers
优先于顶级 resources
映射中的 num_workers
,用于为名为 default
的 label
定义设置(为简洁起见,下面用省略号表示省略的内容):
# ...
resources:
pipelines:
my-pipeline:
clusters:
- label: default
node_type_id: Standard_DS3_v2
num_workers: 1
targets:
development:
resources:
pipelines:
my-pipeline:
clusters:
- label: default
num_workers: 2
# ...
为此示例运行 databricks bundle validate
时,生成的图形如下所示(省略号指示省略的内容,为简洁起见):
{
"...": "...",
"resources": {
"pipelines": {
"my-pipeline": {
"clusters": [
{
"label": "default",
"node_type_id": "Standard_DS3_v2",
"num_workers": 2
}
],
"...": "..."
}
}
}
}