0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Databricks にて dbutils.notebook.run 実行時のエラー調査方法

Last updated at Posted at 2024-09-10

概要

Databricks にて処理の共通化を実施するために dbutils.notebook.run により他のノートブックを実行することがあるのですが、実行先のノートブックでエラーが発生した際の調査手順を紹介します。

実行先のノートブックでエラーが発生する際には下記のようなエラーが発生します。エラーが発生した際のこのスクリーンショットやエラーメッセージを送付されることがありますが、エラー原因が書かれていないため調査ができません。

Py4JJavaError: An error occurred while calling o417.run.
: com.databricks.WorkflowException: com.databricks.NotebookExecutionException: FAILED: Workload failed, see run output for details
	at com.databricks.workflow.WorkflowDriver.run(WorkflowDriver.scala:99)

image.png

エラーとなったノートブックのStart timeの時刻を選択して、実行先のノートブックの実行結果を表示してエラーメッセージを確認する必要があります。下記エラーメッセージでは、int 関数に渡された文字が不適切であるようです。

image.png

image.png

本記事では、ノートブックを作成し、エラーを発生後にそのエラーを修正する手順まで紹介します。

dbutils.notebook.runによる処理の共通化については下記の記事で紹介しています。

事前準備

1. 実行先ノートブックをexecutor_notebook_01という名称で作成して、下記のコードを記述

# Widget を定義
dbutils.widgets.text("input_value", "1")
input_value = dbutils.widgets.get("input_value")
# Widget から取得した値を数値型に変換
input_value_to_int = int(input_value)

image.png

2. 同一のディレクトリに、実行元ノートブックをrunner_noteboke_01という名称で作成して、下記のコードを記述

nb_path = "executor_notebook_01"
nb_para = {
    "input_value": "a",
}
timeout = 0
dbutils.notebook.run(nb_path, timeout, nb_para)

image.png

エラーの再現と対応方法

1. エラーを再現

1-1. 実行元ノートブックであるrunner_noteboke_01を実行してエラーとなることを確認
Py4JJavaError: An error occurred while calling o412.run.
: com.databricks.WorkflowException: com.databricks.NotebookExecutionException: FAILED: Workload failed, see run output for details
	at com.databricks.workflow.WorkflowDriver.run(WorkflowDriver.scala:99)

image.png

ValueError: invalid literal for int() with base 10: 'a'

image.png

2. エラーへの対応方法

2-1. 実行元ノートブックであるrunner_noteboke_01内のinput_valueの値を100に変更

nb_path = "executor_notebook_01"
nb_para = {
-    "input_value": "a",
+    "input_value": "100",
}
timeout = 0

image.png

2-2. 実行元ノートブックを実行して正常終了することを確認

image.png

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?