我可以使用 Visual Studio 代碼從我的 Linux Centos VM 連接到 Azure Databricks 集群。
下面的代碼甚至可以正常作業
from pyspark.sql import SparkSession
spark = SparkSession.builder.getOrCreate()
print("Cluster access test - ",spark.range(100).count())
setting = spark.conf.get("spark.master") # returns local[*]
if "local" in setting:
from pyspark.dbutils import DBUtils
dbutils = DBUtils().get_dbutils(spark)
else:
print("Do nothing - dbutils should be available already")
out = dbutils.fs.ls('/FileStore/')
print(out)
我在本地有一個筆記本,它使用%run path/anothernotebook.
由于 %run 字串被注釋 # python 沒有執行它。
所以我試圖包括dbutils.notebook.run('pathofnotebook')但它錯誤說明筆記本
Exception has occurred: AttributeError
'SparkServiceClientDBUtils' object has no attribute 'notebook'
是否可以在本地除錯呼叫另一個筆記本的筆記本?
uj5u.com熱心網友回復:
這是不可能的 - Databricks Connect 中包含的 dbutils 實作僅支持“fs”和“secrets”子命令(請參閱檔案)。
Databricks Connect 旨在處理本地開發的代碼,而不是筆記本。如果您可以將該筆記本的內容打包為 Python 包,那么您就可以對其進行除錯。
PS 請考慮到 dbutils.notebook.run 將 notebook 作為單獨的作業執行,與 %run 形成對比
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/311450.html
