我可以將 Great_Expectations 套件保存到我的 Databricks 社區版的 tmp 檔案夾中,如下所示:
ge_partdf.save_expectation_suite('/tmp/myexpectation_suite.json',discard_failed_expectations=False)
但問題是,當我重新啟動集群時,tmp 檔案夾中的 json 檔案會更長。我猜這是因為駐留在 tmp 檔案夾中的檔案是臨時的。但是,如果我嘗試將其保存在我知道存在于 Databricks 上的檔案夾中,例如 /FileStore/tables,我會收到錯誤訊息:
FileNotFoundError: [Errno 2] No such file or directory: '/FileStore/tables/myexpectation_suite.json'
有人可以讓我知道如何在本地保存在 Databricks 上。
uj5u.com熱心網友回復:
該save_expectation_suite函式使用本地 Python API 并將資料存盤在本地磁盤上,而不是 DBFS 上——這就是檔案消失的原因。
如果您使用完整的 Databricks(在 AWS 或 Azure 上),那么您只需要在/dbfs您的路徑之前添加,檔案將通過所謂的 DBFS 熔絲存盤在 DBFS 上(請參閱檔案)。
在社區版上,您將需要繼續使用到本地磁盤,然后使用dbutils.fs.cp將檔案從本地磁盤復制到 DBFS。
根據評論更新可見性:
要參考本地檔案,您需要附加file://到路徑。所以我們有兩種情況:
- 將生成的套件從本地磁盤復制到 DBFS:
dbutils.fs.cp('file:///tmp/myexpectation_suite.json', "/FileStore/tables")
- 將套件從 DBFS 復制到本地磁盤以加載它:
dbutils.fs.cp("/FileStore/tables/myexpectation_suite.json", 'file:///tmp/myexpectation_suite.json')
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/384970.html
