Bildirim temelli Otomasyon Paketleri yapılandırması

Bu makalede, Bildirim temelli Otomasyon Paketlerini (eski adı Databricks Varlık Paketleri) tanımlayan paket yapılandırma dosyalarının söz dizimi açıklanmaktadır. Bkz. Bildirim temelli Otomasyon Paketleri nelerdir?.

Paket oluşturmak ve bunlarla çalışmak için bkz. Bildirim temelli Otomasyon Paketleri Geliştirme.

Paket yapılandırma başvurusu için bkz . Yapılandırma başvurusu.

databricks.yml

Paket, paket proje klasörünün kökünde adlı databricks.yml bir (ve yalnızca bir) yapılandırma dosyası içermelidir. databricks.yml bir paketi tanımlayan ana yapılandırma dosyasıdır, ancak eşlemede kaynak yapılandırma dosyaları gibi diğer yapılandırma dosyalarına include başvurabilir. Paket yapılandırması YAML ile ifade edilir. YAML hakkında daha fazla bilgi için resmi YAML belirtimine bakın.

En databricks.yml basiti, gerekli bir üst düzey eşleme ve hedef dağıtım olan paket adını tanımlar.

bundle:
  name: my_bundle

targets:
  dev:
    default: true

Tüm üst düzey eşlemelerle ilgili ayrıntılar için bkz . Yapılandırma başvurusu.

Tavsiye

Bildirim temelli Otomasyon Paketleri için Python desteği, Python'da kaynakları tanımlamanızı sağlar. Bkz . Python'da paket yapılandırması.

Şartname

Aşağıdaki YAML belirtimi Bildirim temelli Otomasyon Paketleri için üst düzey yapılandırma anahtarları sağlar. Tam yapılandırma başvurusu için bkz . Yapılandırma başvurusu ve Bildirim temelli Otomasyon Paketleri kaynakları.

# This is the default bundle configuration if not otherwise overridden in
# the "targets" top-level mapping.
bundle: # Required.
  name: string # Required.
  databricks_cli_version: string
  cluster_id: string
  deployment: Map
  git:
    origin_url: string
    branch: string

# This is the identity to use to run the bundle
run_as:
  - user_name: <user-name>
  - service_principal_name: <service-principal-name>

# These are any additional configuration files to include.
include:
  - '<some-file-or-path-glob-to-include>'
  - '<another-file-or-path-glob-to-include>'

# These are any scripts that can be run.
scripts:
  <some-unique-script-name>:
    content: string

# These are any additional files or paths to include or exclude.
sync:
  include:
    - '<some-file-or-path-glob-to-include>'
    - '<another-file-or-path-glob-to-include>'
  exclude:
    - '<some-file-or-path-glob-to-exclude>'
    - '<another-file-or-path-glob-to-exclude>'
  paths:
    - '<some-file-or-path-to-synchronize>'

# These are the default artifact settings if not otherwise overridden in
# the targets top-level mapping.
artifacts:
  <some-unique-artifact-identifier>:
    build: string
    dynamic_version: boolean
    executable: string
    files:
      - source: string
    path: string
    type: string

# These are for any custom variables for use throughout the bundle.
variables:
  <some-unique-variable-name>:
    description: string
    default: string or complex
    lookup: Map
    type: string # The only valid value is "complex" if the variable is a complex variable, otherwise do not define this key.

# These are the workspace settings if not otherwise overridden in
# the targets top-level mapping.
workspace:
  artifact_path: string
  host: string
  profile: string
  resource_path: string
  root_path: string
  state_path: string

# These are the permissions to apply to resources defined
# in the resources mapping.
permissions:
  - level: <permission-level>
    group_name: <unique-group-name>
  - level: <permission-level>
    user_name: <unique-user-name>
  - level: <permission-level>
    service_principal_name: <unique-principal-name>

# These are the resource settings if not otherwise overridden in
# the targets top-level mapping.
resources:
  alerts:
    <unique-alert-name>:
      # alert settings
  apps:
    <unique-app-name>:
      # app settings
  catalogs:
    <unique-catalog-name>:
      # catalog settings
  clusters:
    <unique-cluster-name>:
      # cluster settings
  dashboards:
    <unique-dashboard-name>:
      # dashboard settings
  database_catalogs:
    <unique-database-catalog-name>:
      # database catalog settings
  database_instances:
    <unique-database-instance-name>:
      # database instance settings
  experiments:
    <unique-experiment-name>:
      # experiment settings
  jobs:
    <unique-job-name>:
      # job settings
  model_serving_endpoints:
    <unique-model-serving-endpoint-name>:
    # model_serving_endpoint settings
  pipelines:
    <unique-pipeline-name>:
      # pipeline settings
  postgres_branches:
    <unique-postgres-branch-name>:
      # postgres branch settings
  postgres_endpoints:
    <unique-postgres-endpoint-name>:
      # postgres endpoint settings
  postgres_projects:
    <unique-postgres-project-name>:
      # postgres project settings
  quality_monitors:
    <unique-quality-monitor-name>:
    # quality monitor settings
  registered_models:
    <unique-registered-model-name>:
    # registered model settings
  schemas:
    <unique-schema-name>:
      # schema settings
  secret_scopes:
    <unique-secret-scope-name>:
      # secret scopes settings
  sql_warehouses:
    <unique-sql-warehouse-name>:
      # sql warehouse settings
  synced_database_tables:
    <unique-synced-database-table-name>:
      # synced database table settings
  volumes:
    <unique-volume-name>:
    # volumes settings

# These are the targets to use for deployments and workflow runs. One and only one of these
# targets can be set to "default: true".
targets:
  <some-unique-programmatic-identifier-for-this-target>:
    artifacts:
      # artifact build settings for this target
    bundle:
      # bundle settings for this target
    default: boolean
    git: Map
    mode: string
    permissions:
      # permissions for this target
    presets:
      <preset>: <value>
    resources:
      # resource settings for this target
    sync:
      # sync settings for this target
    variables:
      <defined-variable-name>: <non-default-value> # value for this target
    workspace:
      # workspace settings for this target
    run_as:
      # run_as settings for this target

Örnekler

Bu bölüm, paketlerin nasıl çalıştığını ve yapılandırmayı nasıl yapılandırabileceğinizi anlamanıza yardımcı olacak bazı temel örnekler içerir.

Uyarı

Paket özelliklerini ve yaygın paket kullanım örneklerini gösteren yapılandırma örnekleri için bkz . Paket yapılandırma örnekleri ve GitHub'daki paket örnekleri deposu.

Aşağıdaki örnek paket yapılandırması, paket yapılandırma dosyasıyla aynı dizinde bulunan adlı hello.py bir yerel dosya databricks.ymlbelirtir. Bu not defterini, belirtilen küme kimliğine sahip uzak kümeyi kullanarak bir görev olarak çalıştırır. Uzak çalışma alanı URL'si ve çalışma alanı kimlik doğrulaması kimlik bilgileri, çağıranın adlı yerel DEFAULT okunur.

bundle:
  name: hello-bundle

resources:
  jobs:
    hello-job:
      name: hello-job
      tasks:
        - task_key: hello-task
          existing_cluster_id: 1234-567890-abcde123
          notebook_task:
            notebook_path: ./hello.py

targets:
  dev:
    default: true

Aşağıdaki örnek, belirtilen çalışma alanı URL'si ile eşleşen prod girdisinden okunan farklı bir uzak çalışma alanı URL'si ve çalışma alanı kimlik doğrulama bilgilerini kullanan ve adı .databrickscfg olan bir hedef ekler. Bu hedef, çağıranın host dosyasında yer alır. Bu görev aynı not defterini çalıştırır ancak belirtilen küme kimliğine sahip farklı bir harici küme kullanır.

Uyarı

Databricks, paket yapılandırma dosyalarınızı daha taşınabilir hale getirdiğinden, mümkün olduğunca host eşlemesi yerine default eşlemesini kullanmanız önerilmektedir. Eşlemeyi host ayarlamak, Databricks CLI'ya dosyanızda .databrickscfg eşleşen bir profil bulmasını ve ardından kullanılacak Databricks kimlik doğrulama türünü belirlemek için bu profilin alanlarını kullanmasını gerektirir. Eşleşen host alana sahip birden çok profil varsa, kullanılacak profili belirtmek için paket komutlarında seçeneğini kullanmanız --profile gerekir.

"notebook_task eşlemesini prod eşlemesi içinde bildirmenize gerek yoktur çünkü notebook_task eşlemesi resources eşlemesi içinde açıkça geçersiz kılınmadığında, üst düzey notebook_task eşlemesi içindeki prod eşlemesini kullanabilir."

bundle:
  name: hello-bundle

resources:
  jobs:
    hello-job:
      name: hello-job
      tasks:
        - task_key: hello-task
          existing_cluster_id: 1234-567890-abcde123
          notebook_task:
            notebook_path: ./hello.py

targets:
  dev:
    default: true
  prod:
    workspace:
      host: https://<production-workspace-url>
    resources:
      jobs:
        hello-job:
          name: hello-job
          tasks:
            - task_key: hello-task
              existing_cluster_id: 2345-678901-fabcd456

Bu işi doğrulamak, dağıtmak ve hedef içinde çalıştırmak için aşağıdaki paket komutlarınıdev kullanın. Bir paketin yaşam döngüsü hakkında ayrıntılı bilgi için bkz. Bildirim temelli Otomasyon Paketleri Geliştirme.

# Because the "dev" target is set to "default: true",
# you do not need to specify "-t dev":
databricks bundle validate
databricks bundle deploy
databricks bundle run hello_job

# But you can still explicitly specify it, if you want or need to:
databricks bundle validate
databricks bundle deploy -t dev
databricks bundle run -t dev hello_job

Bunun yerine bu işi doğrulamak, dağıtmak ve hedefte prod çalıştırmak için:

# You must specify "-t prod", because the "dev" target
# is already set to "default: true":
databricks bundle validate
databricks bundle deploy -t prod
databricks bundle run -t prod hello_job

Tanımların ve ayarların paketler arasında daha modüler hale getirilmesi ve daha iyi yeniden kullanılması için paket yapılandırmanızı ayrı dosyalara bölün:

# databricks.yml

bundle:
  name: hello-bundle

include:
  - '*.yml'
# hello-job.yml

resources:
  jobs:
    hello-job:
      name: hello-job
      tasks:
        - task_key: hello-task
          existing_cluster_id: 1234-567890-abcde123
          notebook_task:
            notebook_path: ./hello.py
# targets.yml

targets:
  dev:
    default: true
  prod:
    workspace:
      host: https://<production-workspace-url>
    resources:
      jobs:
        hello-job:
          name: hello-job
          tasks:
            - task_key: hello-task
              existing_cluster_id: 2345-678901-fabcd456

Ek kaynaklar