From 2486fa177350c7cb07b2829c12e504d001b6287d Mon Sep 17 00:00:00 2001 From: Serge Smertin <259697+nfx@users.noreply.github.com> Date: Thu, 20 Oct 2022 18:44:34 +0200 Subject: [PATCH 1/2] Deprecate Stack CLI This pull request should add user warning upon invoking stack commands --- databricks_cli/stack/api.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/databricks_cli/stack/api.py b/databricks_cli/stack/api.py index b8bbd16f..049dee80 100644 --- a/databricks_cli/stack/api.py +++ b/databricks_cli/stack/api.py @@ -23,6 +23,7 @@ import os import json +import warnings from datetime import datetime from requests.exceptions import HTTPError @@ -74,6 +75,11 @@ class StackApi(object): def __init__(self, api_client): + warnings.warn('''Stack CLI is deprecated. + + Please switch to using the generally available Databricks Terraform Provider instead. + https://docs.databricks.com/dev-tools/terraform/index.html + ''', DeprecationWarning) self.jobs_client = JobsApi(api_client) self.workspace_client = WorkspaceApi(api_client) self.dbfs_client = DbfsApi(api_client) From fea0446aab7d93af6d32131a9a18f9781770f7bd Mon Sep 17 00:00:00 2001 From: Serge Smertin Date: Thu, 20 Oct 2022 17:21:48 +0000 Subject: [PATCH 2/2] Add more messages --- databricks_cli/stack/api.py | 10 +++++----- databricks_cli/stack/cli.py | 24 +++++++++++++++++------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/databricks_cli/stack/api.py b/databricks_cli/stack/api.py index 049dee80..df0064f0 100644 --- a/databricks_cli/stack/api.py +++ b/databricks_cli/stack/api.py @@ -73,13 +73,13 @@ DBFS_RESOURCE_IS_DIR = 'is_dir' +STACK_CLI_DEPRECATION = '''Stack CLI is deprecated. Please switch to using +the generally available Databricks Terraform Provider instead: +https://docs.databricks.com/dev-tools/terraform/index.html''' + class StackApi(object): def __init__(self, api_client): - warnings.warn('''Stack CLI is deprecated. - - Please switch to using the generally available Databricks Terraform Provider instead. - https://docs.databricks.com/dev-tools/terraform/index.html - ''', DeprecationWarning) + warnings.warn(STACK_CLI_DEPRECATION, DeprecationWarning) self.jobs_client = JobsApi(api_client) self.workspace_client = WorkspaceApi(api_client) self.dbfs_client = DbfsApi(api_client) diff --git a/databricks_cli/stack/cli.py b/databricks_cli/stack/cli.py index a6c90ece..d1c8ff5f 100644 --- a/databricks_cli/stack/cli.py +++ b/databricks_cli/stack/cli.py @@ -28,7 +28,7 @@ from databricks_cli.utils import eat_exceptions, CONTEXT_SETTINGS from databricks_cli.version import print_version_callback, version from databricks_cli.configure.config import provide_api_client, profile_option, debug_option -from databricks_cli.stack.api import StackApi +from databricks_cli.stack.api import StackApi, STACK_CLI_DEPRECATION DEBUG_MODE = True @@ -88,15 +88,18 @@ def _save_json(path, data): @provide_api_client def deploy(api_client, config_path, **kwargs): """ - Deploy a stack to the databricks workspace given a JSON stack configuration template. + [Deprecated] Deploy a stack to the databricks workspace given a JSON stack configuration + template. After deployment, a stack status will be saves at .deployed.json. Please do not edit or move the file as it is generated through the CLI and is used for future deployments of the stack. If you run into errors with the stack status at deployment, - please delete the stack status file and try the deployment again. If the problem persists, - please raise a Github issue on the Databricks CLI repository at - https://www.github.com/databricks/databricks-cli/issues + please delete the stack status file and try the deployment again. + + Please switch to using the generally available Databricks Terraform Provider instead: + https://docs.databricks.com/dev-tools/terraform/index.html """ + click.secho('WARNING: ' + STACK_CLI_DEPRECATION, bg='red', fg='white') click.echo('#' * 80) click.echo('Deploying stack at: {} with options: {}'.format(config_path, kwargs)) stack_config = _load_json(config_path) @@ -127,9 +130,13 @@ def deploy(api_client, config_path, **kwargs): @provide_api_client def download(api_client, config_path, **kwargs): """ - Download workspace notebooks of a stack to the local filesystem given a JSON stack + [Deprecated] Download workspace notebooks of a stack to the local filesystem given a JSON stack configuration template. + + Please switch to using the generally available Databricks Terraform Provider instead: + https://docs.databricks.com/dev-tools/terraform/index.html """ + click.secho('WARNING: ' + STACK_CLI_DEPRECATION, bg='red', fg='white') click.echo('#' * 80) click.echo('Downloading stack at: {} with options: {}'.format(config_path, kwargs)) stack_config = _load_json(config_path) @@ -149,7 +156,10 @@ def download(api_client, config_path, **kwargs): @profile_option def stack_group(): # pragma: no cover """ - [Beta] Utility to deploy and download Databricks resource stacks. + [Deprecated] Utility to deploy and download Databricks resource stacks. + + Please switch to using the generally available Databricks Terraform Provider instead: + https://docs.databricks.com/dev-tools/terraform/index.html """ pass