-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for the experimental Databricks CLI launcher (#517)
- Loading branch information
Showing
4 changed files
with
104 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,4 +148,5 @@ dev/cleanup.py | |
.databricks | ||
.vscode | ||
|
||
.python-version | ||
.python-version | ||
.databricks-login.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
name: ucx | ||
description: Unity Catalog Migration Toolkit (UCX) | ||
install: | ||
warehouse_types: | ||
- PRO | ||
script: src/databricks/labs/ucx/install.py | ||
entrypoint: src/databricks/labs/ucx/cli.py | ||
min_python: 3.10 | ||
commands: | ||
- name: open-remote-config | ||
description: Opens remote configuration in the browser | ||
|
||
- name: workflows | ||
description: Show deployed workflows and their state | ||
table_template: |- | ||
Step\tState\tStarted | ||
{{range .}}{{.step}}\t{{.state}}\t{{.started}} | ||
{{end}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import json | ||
import logging | ||
import sys | ||
import webbrowser | ||
|
||
from databricks.sdk import WorkspaceClient | ||
|
||
from databricks.labs.ucx.install import WorkspaceInstaller | ||
|
||
logger = logging.getLogger("databricks.labs.ucx") | ||
|
||
|
||
def workflows(): | ||
ws = WorkspaceClient() | ||
installer = WorkspaceInstaller(ws) | ||
logger.info("Fetching deployed jobs...") | ||
print(json.dumps(installer.latest_job_status())) | ||
|
||
|
||
def open_remote_config(): | ||
ws = WorkspaceClient() | ||
installer = WorkspaceInstaller(ws) | ||
|
||
ws_file_url = installer.notebook_link(installer.config_file) | ||
webbrowser.open(ws_file_url) | ||
|
||
|
||
MAPPING = { | ||
"open-remote-config": open_remote_config, | ||
"workflows": workflows, | ||
} | ||
|
||
|
||
def main(raw): | ||
payload = json.loads(raw) | ||
command = payload["command"] | ||
if command not in MAPPING: | ||
msg = f"cannot find command: {command}" | ||
raise KeyError(msg) | ||
flags = payload["flags"] | ||
log_level = flags.pop("log_level") | ||
if log_level != "disabled": | ||
databricks_logger = logging.getLogger("databricks") | ||
databricks_logger.setLevel(log_level.upper()) | ||
|
||
kwargs = {k.replace("-", "_"): v for k, v in flags.items()} | ||
MAPPING[command](**kwargs) | ||
|
||
|
||
if __name__ == "__main__": | ||
main(*sys.argv[1:]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters