Databricks のジョブ、Lakeflow パイプライン、宣言的自動化バンドル(DAB・構成ファイルで処理を定義する仕組み)に対応したサーバーレス・コンピューティング(管理者が利用者に代わってサーバーを管理する仕組み)リソース。STANDARD または PERFORMANCE_OPTIMIZED で実行でき、サーバーレスでは処理が実行できない場合のみクラシック方式を用います。 ジョブやパイプラインの作成、デプロイ、スケジューリング、編集、またはコンピューティング環境を決定する際に使用します。ジョブの仕様書を記述する前に実行してください。既存のクラシック方式の処理を移行する場合は、databricks-serverless-migration を使用してください。
Serverless compute for Databricks jobs, Lakeflow pipelines and Declarative Automation Bundles (DABs), with STANDARD or PERFORMANCE_OPTIMIZED and classic only where serverless cannot run the workload. Use when creating, deploying, scheduling or editing a job or pipeline, or deciding its compute. Invoke BEFORE writing a job spec. For migrating existing classic workloads, use databricks-serverless-migration.
はじめに: 基本的な CLI の操作、認証、プロフィール選択には親スキルの databricks-core を使用してください。
このスキルは計算環境を決定します。別のスキルや例(例えば databricks-jobs)がクラスター設定を示す場合、このスキルに従ってください。
作成するすべてのジョブ、パイプライン、バンドルに対して、サーバーレスがデフォルトの計算環境です。ユーザーが明確にクラスターを要求する場合は、その要求に従い、1行でサーバーレスオプションについて言及してください。既存のジョブを編集する場合は、ユーザーが変更を要求しない限り、その計算環境を保持します。追加するタスクはこのスキルに従います。
従来型の計算環境を使用するのは、以下の場合のみです:
%scala):サーバーレスノートブックは Python と SQL のみ対応apt-get)または pip での提供がないネイティブライブラリその場合、ブロック(制約)されたタスクのみにクラスター設定を行い(最新 LTS ランタイムで autoscale: {min_workers: 1, max_workers: 4} の小規模な job_clusters エントリ1 つ)、その他のタスクはすべてサーバーレスのままにして、ブロック理由を1行で記載してください。ブロックされたパイプラインの場合は、serverless: true の代わりにパイプラインに clusters ブロックを設定してください。
従来型にする理由ではないもの:JAR タスク内の Scala または Java(JAR タスクはサーバーレスで実行)、GPU(サーバーレス対応)、大規模データ、長い実行時間、Kafka、コスト(サーバーレス STANDARD はほとんどの場合、従来型オンデマンドと同等以下)、慣習。
新規ジョブ:new_cluster、job_clusters、job_cluster_key、existing_cluster_id、instance_pool_id、node_type_id、num_workers、autoscale、spark_version は記載しないでください。クラスター指定のないタスクはサーバーレスで実行されます。既存のジョブの場合は、すでに持つクラスター設定を保持してください。
ノートブックタスク:追加の設定は不要です。Python スクリプト、wheel、JAR タスクはライブラリをジョブレベルの環境から取得します。ワークスペースが提供する最新の環境バージョンを文字列として使用してください:
environments:
- environment_key: default
spec:
environment_version: "4" # 例;最新を使用
dependencies: ["requests==2.32.3"] # バージョンはピン留め;JAR は java_dependencies に
tasks:
- task_key: main
spark_python_task: {python_file: /Workspace/.../main.py}
environment_key: default
SQL タスク:サーバーレス SQL ウェアハウス。パイプライン:serverless: true、clusters ブロックなし。
ストリーミング:.trigger(availableNow=True)を使用(サーバーレスが対応するトリガー;processingTime や continuous トリガーは非対応)。常時処理の場合は、そのストリームを継続ジョブ(continuous: {pause_status: UNPAUSED};1 回の実行が終わると次の実行がすぐに始まる)で実行するか、継続パイプラインを使用してください。
作成するすべてのジョブにタグを付ける(リソース追跡用;他の Databricks スキルと同様):ジョブレベルで tags: {"aidevkit_project": "ai-dev-kit"}。ユーザーが既に持つタグは保持してください。
ジョブレベルの performance_target を設定してください:
STANDARD:時間が重要ではなく、速度より費用が優先される場合:スケジュール済みバッチ処理と ETL、夜間や週単位の実行、またはユーザーがレイテンシ要件なしと述べたジョブ。実行の開始まで数分かかり、費用が低くなります。これがデフォルトの選択肢です。
PERFORMANCE_OPTIMIZED:ユーザーが SLA またはランタイムに対して厳密な期限を指定した場合、実行結果を人が待つ場合、またはジョブが 30 分ごとまたはそれ以上の頻度で実行される場合のみ。
performance_target はノートブックタスクを含むジョブ全体に適用されます(対話型ノートブックのみ常時パフォーマンス最適化で実行)。選択したモードと理由を1行で述べてください。例:「STANDARD:夜間バッチ、期限なし」
サーバーレス GPU タスクは performance_target を無視します。
パイプラインは独自の performance_target を持ちません。パイプラインをスケジュール実行するには、pipeline_task を持つジョブからトリガーして、そのジョブにモードを設定してください。ジョブのモードがパイプライン更新に適用されます。継続パイプラインは、継続ジョブが実行する場合のみ STANDARD で実行されます。
サーバーレスは Unity Catalog テーブル、/Volumes/... パス、Unity Catalog 外部ロケーションの背後にあるクラウドパス、および dbfs:/databricks-datasets/ のサンプルデータを読み取ることができます。DBFS マウント(dbfs:/mnt/...)またはその他の DBFS ルートパスは読み取れません。これが DBFS ブロッカーとしてカウントされるものです。
DataFrame と SQL API のみ(RDD、sc.*、spark.sparkContext なし);Unity Catalog の 3 部構成テーブル名;DBFS マウント(dbfs:/mnt/...)ではなく /Volumes/... パス;availableNow ストリーミングトリガー;.cache() や .persist() なし;executor、driver、メモリ設定の spark.conf.set なし;環境内のピン留めされた依存関係;初期化スクリプトなし。
ユーザーは配置を待っています。短い1 回のパスを行い、その後配置してください。
ジョブが実行するファイルのみをスキャン(grep や rg などのテキスト検索;リポ全体を読まない)して、以下を探してください:sc.、sparkContext、.rdd、parallelize、mapPartitions、reduceByKey、groupByKey、dbfs:/、/dbfs/、dbutils.fs.mount、.cache(、.persist(、spark.conf.set、processingTime、continuous=、writeStream、hive_metastore.、GLOBAL TEMP、hivevar、init_scripts、apt-get、docker、および他の言語:%scala または %r が全体的なマジックコマンド(# MAGIC %r;%run ではない)、.r ファイルと R ノートブック、SparkR および sparklyr。R セルと Scala セルは従来型に移行します(セクション 1)。
軽微なブロッカー:修正してサーバーレスで配置。すべての修正が機械的でローカル、ロジックを保持、インフラ新規構築不要、かつ総編集数が約 5 件以下の場合:
.cache()、.persist()、.unpersist()、setLogLevel、executor/driver/AQE spark.conf.set 行を削除pip install または requirements.txt を環境に移動(バージョンはピン留め).trigger(availableNow=True) を追加(processingTime または continuous トリガーがあるストリームはステップ 4 ブロッカー)dbfs:/mnt/... パスを /Volumes/... パスに置き換え。ただしボリュームのストレージロケーションがマウントのソースである場合のみ、ジョブが同じデータを読み込みます。同じ名前のボリュームでは不十分です。そうでなければマウントはステップ 4 ブロッカーです。CREATE GLOBAL TEMP VIEW を CREATE TEMP VIEW に、その global_temp.<view> 読み取りを <view> に変更(同じファイルが該当ビューを作成・読み込む場合;サーバーレスはグローバル一時ビューなし)。別のタスクまたはノートブックが読み込むグローバル一時ビューはステップ 4 ブロッカー。hive_metastore 内のテーブルはステップ 4 ブロッカー。回答で行った各編集を列記してください。
RDD または SparkContext コード:DataFrame に翻訳してサーバーレスで配置。以下のすべてが満たされる場合のみ:
/Volumes/... パス、外部ロケーション背後のクラウドパス、または dbfs:/databricks-datasets/)。新規セットアップは不要。元ファイルを <name>.classic.py として次に保存し、ジョブが翻訳されたファイルを指すようにしてください。翻訳はまだ実行されていないことをユーザーに伝え、従来型バージョンとの出力比較を行う 1 回のテスト実行を提案してください。
さらに大規模な場合:書き直さないでください。 そのタスクを今従来型に配置し(セクション 1)、その他のタスクはサーバーレスのままにして、最後に以下のように述べてください:「<タスク>をステップ 4 ブロッカーの理由で従来型のままにしました。サーバーレスに移行するには、databricks-serverless-migration スキルを使用してください」大規模とは:ステップ 3 の条件に当てはまらない RDD コード(例えば DBFS マウントを読み込む)、同じストレージにボリュームがないマウント、Hive Metastore から Unity Catalog への移行、JAR の再コンパイル、ネットワーク変更、ストリーム動作の変更(常時 processingTime または continuous ストリーム)、またはステップ 3 翻訳以外で約 5 件を上回る編集。
移行するかどうかを確認するため立ち止まらないでください。配置し、その後何をしたかを報告してください。
| 問題 | 解決策 |
|---|---|
Libraries field is not supported for serverless task(ライブラリフィールドはサーバーレスタスク非対応) |
ライブラリを environments[].spec.dependencies に移動(JAR は java_dependencies)してタスクに environment_key を設定 |
| サーバーレスジョブの開始が遅い | performance_target: PERFORMANCE_OPTIMIZED;ユーザーが高速開始を必要とする場合のみ(セクション 3) |
Only remote Spark sessions ... are supported(リモート Spark セッションのみ対応)または別の RDD エラー |
RDD/SparkContext コード:セクション 5 のステップ 3 または 4 |
FIRST: Use the parent databricks-core skill for CLI basics, authentication and profile selection.
This skill decides compute. Where another skill or example (for example databricks-jobs) shows
cluster configuration, follow this skill instead.
Serverless is the default compute for every job, pipeline and bundle you create. If the user explicitly asks for a cluster, do what they ask and mention the serverless option in one line. When editing an existing job, keep its compute unless the user asks to change it; tasks you add follow this skill.
Use classic compute only for:
%scala): serverless notebooks run Python and SQL only;apt-get) or native libraries with no pip equivalent;Then give only the blocked task a cluster (one small job_clusters entry with the latest LTS
runtime and autoscale: {min_workers: 1, max_workers: 4}), keep every other task serverless, and
state the blocker in one line. For a blocked pipeline, give the pipeline a clusters block instead
of serverless: true.
Not reasons for classic: Scala or Java in a JAR task (JAR tasks run on serverless), GPUs (serverless GPU), large data, long runtimes, Kafka, cost (serverless STANDARD is on par with or cheaper than on-demand classic in most cases), or habit.
new_cluster, job_clusters, job_cluster_key, existing_cluster_id,
instance_pool_id, node_type_id, num_workers, autoscale, spark_version. A task without a
cluster runs on serverless. In an existing job, keep the cluster settings it has.environments:
- environment_key: default
spec:
environment_version: "4" # example; use the latest
dependencies: ["requests==2.32.3"] # pin versions; JARs go in java_dependencies
tasks:
- task_key: main
spark_python_task: {python_file: /Workspace/.../main.py}
environment_key: default
serverless: true, no clusters block..trigger(availableNow=True), the trigger serverless supports (no processingTime
or continuous triggers). For always-on processing, run that stream in a continuous job
(continuous: {pause_status: UNPAUSED}), which starts the next run as soon as one finishes, or use
a continuous pipeline.tags: {"aidevkit_project": "ai-dev-kit"}. Keep tags the user already has.Set the job-level performance_target:
STANDARD when nothing is time-critical and cost matters more than speed: scheduled batch and
ETL, nightly or weekly runs, or any job where the user states no latency need. Runs start within
minutes instead of seconds and cost less. This is the default choice.PERFORMANCE_OPTIMIZED only when the user names an SLA or a deadline that is tight relative
to the runtime, a person waits on the result, or the job runs every 30 minutes or more often.performance_target applies to the whole job, notebook tasks included (only interactive notebooks
always run performance-optimized). Say which mode you chose and why in one line, e.g. "STANDARD:
nightly batch, no deadline."
Serverless GPU tasks ignore performance_target.
Pipelines have no performance_target of their own. To schedule a pipeline, trigger it from a job
with a pipeline_task and set the mode on that job; the job's mode applies to the pipeline update.
A continuous pipeline runs in STANDARD only when a continuous job runs it.
Serverless reads Unity Catalog tables, /Volumes/... paths, cloud paths behind a Unity Catalog
external location, and the sample data under dbfs:/databricks-datasets/. It cannot read DBFS
mounts (dbfs:/mnt/...) or other DBFS root paths; only those count as a DBFS blocker.
DataFrame and SQL APIs only (no RDDs, sc.*, spark.sparkContext); Unity Catalog three-part table
names; /Volumes/... paths instead of DBFS mounts (dbfs:/mnt/...); availableNow streaming
triggers; no .cache() or .persist(); no spark.conf.set for executor, driver or memory
settings; pinned dependencies in the environment, never init scripts.
The user is waiting for the deployment. Spend one short pass, then deploy.
Scan only the files the job runs (a text search such as grep or rg; do not read the whole
repo) for: sc., sparkContext,
.rdd, parallelize, mapPartitions, reduceByKey, groupByKey, dbfs:/, /dbfs/,
dbutils.fs.mount, .cache(, .persist(, spark.conf.set, processingTime, continuous=,
writeStream, hive_metastore., GLOBAL TEMP, hivevar, init_scripts, apt-get, docker,
and other languages: %scala or %r as the whole magic (# MAGIC %r, not %run), .r files
and R notebooks, SparkR and sparklyr. R and Scala cells go to classic (section 1).
Minor blockers: fix them and deploy on serverless if every fix is mechanical and local, keeps the logic, needs no new infrastructure, and there are about 5 small edits or fewer in total:
.cache(), .persist(), .unpersist(), setLogLevel, executor/driver/AQE spark.conf.set linespip installs or requirements.txt into the environment, pinned.trigger(availableNow=True) to a stream that sets no trigger, in a job that runs on a
schedule anyway (a stream with a processingTime or continuous trigger is a step 4 blocker)dbfs:/mnt/... path with a /Volumes/... path only when that volume's storage
location is the mount's source, so the job reads the same data; a volume with a similar name is
not enough. Otherwise the mount is a step 4 blocker.CREATE GLOBAL TEMP VIEW becomes CREATE TEMP VIEW, and its global_temp.<view> reads become
<view>, when the same file creates and reads the view (serverless has no global temp views); a
global temp view that another task or notebook reads is a step 4 blockerhive_metastore is a step 4 blockerList every edit you made in your reply.
RDD or SparkContext code: translate it to DataFrames and deploy on serverless only if all of these hold:
/Volumes/... path, a cloud path behind an external location, or dbfs:/databricks-datasets/),
so nothing new has to be set up.Save the original next to it as <name>.classic.py and point the job at the translated file.
Tell the user that the translation has not been run yet and suggest one test run that compares
the output with the classic version.
Anything bigger: do not rewrite. Put that task on classic now (section 1), keep the other
tasks serverless, and end with: "Kept <task> on classic because <blocker>. To move it to
serverless, use the databricks-serverless-migration skill." Bigger means: RDD code that fails any
condition in step 3 (for example it reads a DBFS mount), mounts with no volume on the same
storage, Hive Metastore to Unity Catalog, recompiling a JAR, networking changes, changing what a
stream does (an always-on processingTime or continuous stream), or more than about 5 edits
besides a step 3 translation.
Do not stop to ask whether to migrate. Deploy, then report what you did.
| Issue | Solution |
|---|---|
Libraries field is not supported for serverless task |
Move libraries into environments[].spec.dependencies (JARs: java_dependencies) and set environment_key on the task |
| Serverless job starts too slowly | performance_target: PERFORMANCE_OPTIMIZED, only if the user needs fast starts (section 3) |
Only remote Spark sessions ... are supported or another RDD error |
RDD/SparkContext code: section 5, step 3 or 4 |
[PATH_NOT_FOUND] or no access on dbfs:/mnt/... |
DBFS mounts do not work on serverless: use a volume on the same storage (section 5, step 2), otherwise step 4 |
| Serverless is not enabled or not available in the workspace | Put the job on classic and tell the user (section 1) |
A sibling skill's example uses job_clusters for a new job |
Leave the cluster block out; this skill decides compute. Existing jobs keep their compute |
原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。