工作区 CLIWorkspace CLI
可以通过将 Databricks 工作区 CLI 子命令追加到 databricks workspace
之后来运行这些命令。You run Databricks workspace CLI subcommands by appending them to databricks workspace
.
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
列出工作区文件List workspace files
databricks workspace ls /Users/example@databricks.com
Usage Logs ETL
Common Utilities
guava-21.0
导入笔记本的本地目录Import a local directory of notebooks
databricks workspace import_dir
命令以递归方式将目录从本地文件系统导入到工作区。The databricks workspace import_dir
command recursively imports a directory from the local filesystem to the Workspace. 仅导入扩展名为 .scala
、.py
、.sql
、.r
、.R
的目录和文件。Only directories and files with the extensions of .scala
, .py
, .sql
, .r
, .R
are imported.
导入后,将从笔记本名称中删除这些扩展名。When imported, these extensions are stripped from the notebook name.
若要覆盖目标路径上的现有笔记本,请添加标志 -o
。To overwrite existing notebooks at the target path, add the flag -o
.
tree
.
├── a.py
├── b.scala
├── c.sql
├── d.R
└── e
databricks workspace import_dir . /Users/example@databricks.com/example
./a.py -> /Users/example@databricks.com/example/a
./b.scala -> /Users/example@databricks.com/example/b
./c.sql -> /Users/example@databricks.com/example/c
./d.R -> /Users/example@databricks.com/example/d
databricks workspace ls /Users/example@databricks.com/example -l
NOTEBOOK a PYTHON
NOTEBOOK b SCALA
NOTEBOOK c SQL
NOTEBOOK d R
DIRECTORY e
将工作区文件夹导出到本地文件系统Export a workspace folder to the local filesystem
可以将笔记本文件夹从工作区导出到本地文件系统。You can export a folder of notebooks from the workspace to the local filesystem. 若要执行此操作,请运行:To do this, run:
databricks workspace export_dir /Users/example@databricks.com/example .