工作區 CLI (舊版)
重要
此檔已淘汰,且可能未更新。
此資訊適用於舊版 Databricks CLI 0.18 版和更新版本。 Databricks 建議您改用較新的 Databricks CLI 0.205 版或更新版本。 請參閱 什麼是 Databricks CLI?。 若要尋找 Databricks CLI 版本請執行 databricks -v
。
若要從 Databricks CLI 0.18 版或更新版本移轉至 Databricks CLI 0.205 版或更新版本,請參閱 Databricks CLI 移轉。
您可以將 Databricks 工作區 CLI 子命令附加至 , databricks workspace
以執行這些命令。 這些子命令會呼叫 工作區 API。
databricks workspace -h
Usage: databricks workspace [OPTIONS] COMMAND [ARGS]...
Utility to interact with the Databricks workspace. Workspace paths must be
absolute and be prefixed with `/`.
Common Options:
-v, --version [VERSION]
-h, --help Show this message and exit.
Commands:
delete Deletes objects from the Databricks workspace. rm and delete are synonyms.
Options:
-r, --recursive
export Exports a file from the Databricks workspace.
Options:
-f, --format FORMAT SOURCE, HTML, JUPYTER, or DBC. Set to SOURCE by default.
-o, --overwrite Overwrites file with the same name as a workspace file.
export_dir Recursively exports a directory from the Databricks workspace.
Options:
-o, --overwrite Overwrites local files with the same names as workspace files.
import Imports a file from local to the Databricks workspace.
Options:
-l, --language LANGUAGE SCALA, PYTHON, SQL, R [required]
-f, --format FORMAT SOURCE, HTML, JUPYTER, or DBC. Set to SOURCE by default.
-o, --overwrite Overwrites workspace files with the same names as local files.
import_dir Recursively imports a directory to the Databricks workspace.
Only directories and files with the extensions .scala, .py, .sql, .r, .R,
.ipynb are imported. When imported, these extensions are stripped off
the name of the notebook.
Options:
-o, --overwrite Overwrites workspace files with the same names as local files.
-e, --exclude-hidden-files
list Lists objects in the Databricks workspace. ls and list are synonyms.
Options:
--absolute Displays absolute paths.
-l Displays full information including ObjectType, Path, Language
ls Lists objects in the Databricks workspace. ls and list are synonyms.
Options:
--absolute Displays absolute paths.
-l Displays full information including ObjectType, Path, Language
mkdirs Makes directories in the Databricks workspace.
rm Deletes objects from the Databricks workspace. rm and delete are synonyms.
Options:
-r, --recursive
從工作區刪除物件
若要顯示使用方式檔,請執行 databricks workspace delete --help
或 databricks workspace rm --help
。
databricks workspace delete --recursive "/Users/someone@example.com/My Folder"
或:
databricks workspace rm --recursive "/Users/someone@example.com/My Folder"
如果成功,就不會顯示任何輸出。
將檔案從工作區匯出至本機文件系統
若要顯示使用方式檔,請執行 databricks workspace export --help
。
databricks workspace export --overwrite --format JUPYTER "/Users/someone@example.com/My Python Notebook" /Users/me/Downloads
這個選項也可用來從 Databricks Git 資料夾匯出筆記本:
databricks workspace export "/Repos/someone@example.com/MyRepoNotebook" /Users/me/Downloads
如果成功,就不會顯示任何輸出。
將目錄從工作區匯出至本機文件系統
若要顯示使用方式檔,請執行 databricks workspace export_dir --help
。
databricks workspace export_dir --overwrite /Users/someone@example.com/my-folder /Users/me/Downloads/my-folder
/Users/someone@example.com/my-folder/My Python Notebook -> /Users/me/Downloads/my-folder/My Python Notebook.py
/Users/someone@example.com/my-folder/My Scala Notebook -> /Users/me/Downloads/my-folder/My Scala Notebook.scala
/Users/someone@example.com/my-folder/My R Notebook -> /Users/me/Downloads/my-folder/My R Notebook.r
/Users/someone@example.com/my-folder/My SQL Notebook -> /Users/me/Downloads/my-folder/My SQL Notebook.sql
將檔案從本機檔系統匯入工作區
若要顯示使用方式檔,請執行 databricks workspace import --help
。
只能匯入擴展名.scala
為 、.py
、.sql
、 .r
.R
的檔案。
匯入時,這些延伸模組會從筆記本名稱中移除。
databricks workspace import ./a.py /Users/someone@example.com/example
./a.py -> /Users/someone@example.com/example/a
將目錄從本機檔系統匯入工作區
若要顯示使用方式檔,請執行 databricks workspace import_dir --help
。
此命令會以遞歸方式將目錄從本機檔系統匯入工作區。 只會匯入延伸名為 、、、 .sql
.R
.r
的.scala
目錄和檔案。 .py
匯入時,這些延伸模組會從筆記本名稱中移除。
若要覆寫目標路徑的現有筆記本,請新增 旗標 --overwrite
或 -o
。
tree
.
├── a.py
├── b.scala
├── c.sql
├── d.R
└── e
databricks workspace import_dir . /Users/someone@example.com/example
./a.py -> /Users/someone@example.com/example/a
./b.scala -> /Users/someone@example.com/example/b
./c.sql -> /Users/someone@example.com/example/c
./d.R -> /Users/someone@example.com/example/d
databricks workspace ls /Users/someone@example.com/example -l
NOTEBOOK a PYTHON
NOTEBOOK b SCALA
NOTEBOOK c SQL
NOTEBOOK d R
DIRECTORY e
列出工作區中的物件
若要顯示使用方式檔,請執行 databricks workspace list --help
或 databricks workspace ls --help
。
databricks workspace list --absolute --long --id /Users/someone@example.com
或:
databricks workspace ls --absolute --long --id /Users/someone@example.com
NOTEBOOK /Users/someone@example.com/My Python Notebook PYTHON 1234567898012345
NOTEBOOK /Users/someone@example.com/My Scala Notebook SCALA 2345678980123456
NOTEBOOK /Users/someone@example.com/My R Notebook R 3456789801234567
DIRECTORY /Users/someone@example.com/My Directory 4567898012345678
MLFLOW_EXPERIMENT /Users/someone@example.com/My_Experiment 5678980123456789
在工作區中建立目錄
若要顯示使用方式檔,請執行 databricks workspace mkdirs --help
。
databricks workspace mkdirs "/Users/someone@example.com/My New Folder"
如果成功,就不會顯示任何輸出。