在 Databricks 資產組合中定義 Artifact 設定
本文說明如何在 Databricks Asset Bundles 中覆寫工件的設定。 請參閱 什麼是 Databricks 資產套件組合?
在 Azure Databricks 組態檔中,您可以使用 targets
對應中的工件設定來覆寫最上層 artifacts
對應中的工件設定,例如:
# ...
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
對應和 targets
中的 artifacts
對應中。 在此範例中,targets
中 artifacts
對應中的 path
優先於最上層 artifacts
對應中的 path
,以定義工件的設定(省略部分內容以簡化):
# ...
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",
"...": "..."
}
},
"...": "..."
}