From d4ed50f9570a382cb1798d37fb5d223c81facf6f Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Wed, 4 Oct 2023 16:15:20 +0200 Subject: [PATCH 1/6] Add warning for all imports of the old CLI --- databricks_cli/__init__.py | 7 +++++++ databricks_cli/cluster_policies/__init__.py | 6 ++++++ databricks_cli/clusters/__init__.py | 6 ++++++ databricks_cli/configure/__init__.py | 7 +++++++ databricks_cli/dbfs/__init__.py | 7 +++++++ databricks_cli/groups/__init__.py | 6 ++++++ databricks_cli/instance_pools/__init__.py | 7 +++++++ databricks_cli/jobs/__init__.py | 6 ++++++ databricks_cli/libraries/__init__.py | 7 +++++++ databricks_cli/oauth/__init__.py | 8 ++++++++ databricks_cli/pipelines/__init__.py | 6 ++++++ databricks_cli/repos/__init__.py | 9 ++++++++- databricks_cli/runs/__init__.py | 6 ++++++ databricks_cli/sdk/__init__.py | 7 +++++++ databricks_cli/secrets/__init__.py | 7 +++++++ databricks_cli/stack/__init__.py | 6 ++++++ databricks_cli/tokens/__init__.py | 7 +++++++ databricks_cli/unity_catalog/__init__.py | 6 ++++++ databricks_cli/workspace/__init__.py | 6 ++++++ 19 files changed, 126 insertions(+), 1 deletion(-) diff --git a/databricks_cli/__init__.py b/databricks_cli/__init__.py index ccc04bd5..175b53cf 100644 --- a/databricks_cli/__init__.py +++ b/databricks_cli/__init__.py @@ -24,6 +24,13 @@ # pylint:disable=import-error # pylint:disable=bare-except +import warnings + +warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " + "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " + "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", + DeprecationWarning, stacklevel=2) + def initialize_cli_for_databricks_notebooks(): import IPython diff --git a/databricks_cli/cluster_policies/__init__.py b/databricks_cli/cluster_policies/__init__.py index e69de29b..6983ccad 100644 --- a/databricks_cli/cluster_policies/__init__.py +++ b/databricks_cli/cluster_policies/__init__.py @@ -0,0 +1,6 @@ +import warnings + +warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " + "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " + "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", + DeprecationWarning, stacklevel=2) diff --git a/databricks_cli/clusters/__init__.py b/databricks_cli/clusters/__init__.py index e69de29b..6983ccad 100644 --- a/databricks_cli/clusters/__init__.py +++ b/databricks_cli/clusters/__init__.py @@ -0,0 +1,6 @@ +import warnings + +warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " + "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " + "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", + DeprecationWarning, stacklevel=2) diff --git a/databricks_cli/configure/__init__.py b/databricks_cli/configure/__init__.py index b0c9feac..a49fd5a0 100644 --- a/databricks_cli/configure/__init__.py +++ b/databricks_cli/configure/__init__.py @@ -20,3 +20,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +import warnings + +warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " + "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " + "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", + DeprecationWarning, stacklevel=2) diff --git a/databricks_cli/dbfs/__init__.py b/databricks_cli/dbfs/__init__.py index b0c9feac..a49fd5a0 100644 --- a/databricks_cli/dbfs/__init__.py +++ b/databricks_cli/dbfs/__init__.py @@ -20,3 +20,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +import warnings + +warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " + "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " + "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", + DeprecationWarning, stacklevel=2) diff --git a/databricks_cli/groups/__init__.py b/databricks_cli/groups/__init__.py index e69de29b..6983ccad 100644 --- a/databricks_cli/groups/__init__.py +++ b/databricks_cli/groups/__init__.py @@ -0,0 +1,6 @@ +import warnings + +warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " + "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " + "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", + DeprecationWarning, stacklevel=2) diff --git a/databricks_cli/instance_pools/__init__.py b/databricks_cli/instance_pools/__init__.py index b0c9feac..a49fd5a0 100644 --- a/databricks_cli/instance_pools/__init__.py +++ b/databricks_cli/instance_pools/__init__.py @@ -20,3 +20,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +import warnings + +warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " + "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " + "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", + DeprecationWarning, stacklevel=2) diff --git a/databricks_cli/jobs/__init__.py b/databricks_cli/jobs/__init__.py index e69de29b..6983ccad 100644 --- a/databricks_cli/jobs/__init__.py +++ b/databricks_cli/jobs/__init__.py @@ -0,0 +1,6 @@ +import warnings + +warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " + "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " + "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", + DeprecationWarning, stacklevel=2) diff --git a/databricks_cli/libraries/__init__.py b/databricks_cli/libraries/__init__.py index b0c9feac..a49fd5a0 100644 --- a/databricks_cli/libraries/__init__.py +++ b/databricks_cli/libraries/__init__.py @@ -20,3 +20,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +import warnings + +warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " + "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " + "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", + DeprecationWarning, stacklevel=2) diff --git a/databricks_cli/oauth/__init__.py b/databricks_cli/oauth/__init__.py index dfe79e90..327e3209 100644 --- a/databricks_cli/oauth/__init__.py +++ b/databricks_cli/oauth/__init__.py @@ -20,3 +20,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +import warnings + +warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " + "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " + "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", + DeprecationWarning, stacklevel=2) + diff --git a/databricks_cli/pipelines/__init__.py b/databricks_cli/pipelines/__init__.py index e69de29b..6983ccad 100644 --- a/databricks_cli/pipelines/__init__.py +++ b/databricks_cli/pipelines/__init__.py @@ -0,0 +1,6 @@ +import warnings + +warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " + "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " + "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", + DeprecationWarning, stacklevel=2) diff --git a/databricks_cli/repos/__init__.py b/databricks_cli/repos/__init__.py index 0fd9f1e6..a49fd5a0 100644 --- a/databricks_cli/repos/__init__.py +++ b/databricks_cli/repos/__init__.py @@ -19,4 +19,11 @@ # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and -# limitations under the License. \ No newline at end of file +# limitations under the License. + +import warnings + +warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " + "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " + "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", + DeprecationWarning, stacklevel=2) diff --git a/databricks_cli/runs/__init__.py b/databricks_cli/runs/__init__.py index e69de29b..6983ccad 100644 --- a/databricks_cli/runs/__init__.py +++ b/databricks_cli/runs/__init__.py @@ -0,0 +1,6 @@ +import warnings + +warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " + "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " + "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", + DeprecationWarning, stacklevel=2) diff --git a/databricks_cli/sdk/__init__.py b/databricks_cli/sdk/__init__.py index 9025b6f1..77f931cd 100644 --- a/databricks_cli/sdk/__init__.py +++ b/databricks_cli/sdk/__init__.py @@ -53,3 +53,10 @@ """ from .service import * from .api_client import ApiClient + +import warnings + +warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " + "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " + "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", + DeprecationWarning, stacklevel=2) diff --git a/databricks_cli/secrets/__init__.py b/databricks_cli/secrets/__init__.py index b0c9feac..a49fd5a0 100644 --- a/databricks_cli/secrets/__init__.py +++ b/databricks_cli/secrets/__init__.py @@ -20,3 +20,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +import warnings + +warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " + "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " + "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", + DeprecationWarning, stacklevel=2) diff --git a/databricks_cli/stack/__init__.py b/databricks_cli/stack/__init__.py index e69de29b..6983ccad 100644 --- a/databricks_cli/stack/__init__.py +++ b/databricks_cli/stack/__init__.py @@ -0,0 +1,6 @@ +import warnings + +warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " + "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " + "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", + DeprecationWarning, stacklevel=2) diff --git a/databricks_cli/tokens/__init__.py b/databricks_cli/tokens/__init__.py index b0c9feac..a49fd5a0 100644 --- a/databricks_cli/tokens/__init__.py +++ b/databricks_cli/tokens/__init__.py @@ -20,3 +20,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +import warnings + +warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " + "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " + "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", + DeprecationWarning, stacklevel=2) diff --git a/databricks_cli/unity_catalog/__init__.py b/databricks_cli/unity_catalog/__init__.py index e69de29b..6983ccad 100644 --- a/databricks_cli/unity_catalog/__init__.py +++ b/databricks_cli/unity_catalog/__init__.py @@ -0,0 +1,6 @@ +import warnings + +warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " + "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " + "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", + DeprecationWarning, stacklevel=2) diff --git a/databricks_cli/workspace/__init__.py b/databricks_cli/workspace/__init__.py index e69de29b..6983ccad 100644 --- a/databricks_cli/workspace/__init__.py +++ b/databricks_cli/workspace/__init__.py @@ -0,0 +1,6 @@ +import warnings + +warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " + "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " + "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", + DeprecationWarning, stacklevel=2) From a811dcd19c43d89126724fd74a85164db8fe74b1 Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Wed, 4 Oct 2023 17:57:46 +0200 Subject: [PATCH 2/6] refactor --- databricks_cli/__init__.py | 11 +++++++---- databricks_cli/cluster_policies/__init__.py | 7 ++----- databricks_cli/clusters/__init__.py | 7 ++----- databricks_cli/configure/__init__.py | 7 ++----- databricks_cli/dbfs/__init__.py | 7 ++----- databricks_cli/groups/__init__.py | 7 ++----- databricks_cli/instance_pools/__init__.py | 7 ++----- databricks_cli/jobs/__init__.py | 7 ++----- databricks_cli/libraries/__init__.py | 7 ++----- databricks_cli/oauth/__init__.py | 8 ++------ databricks_cli/pipelines/__init__.py | 7 ++----- databricks_cli/repos/__init__.py | 7 ++----- databricks_cli/runs/__init__.py | 7 ++----- databricks_cli/sdk/__init__.py | 7 ++----- databricks_cli/secrets/__init__.py | 7 ++----- databricks_cli/stack/__init__.py | 7 ++----- databricks_cli/tokens/__init__.py | 7 ++----- databricks_cli/unity_catalog/__init__.py | 7 ++----- databricks_cli/workspace/__init__.py | 7 ++----- 19 files changed, 43 insertions(+), 95 deletions(-) diff --git a/databricks_cli/__init__.py b/databricks_cli/__init__.py index 175b53cf..8ee791eb 100644 --- a/databricks_cli/__init__.py +++ b/databricks_cli/__init__.py @@ -26,11 +26,14 @@ import warnings -warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " - "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " - "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", - DeprecationWarning, stacklevel=2) +def issue_deprecation_warning(): + warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " + "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " + "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", + DeprecationWarning, stacklevel=3) + +issue_deprecation_warning() def initialize_cli_for_databricks_notebooks(): import IPython diff --git a/databricks_cli/cluster_policies/__init__.py b/databricks_cli/cluster_policies/__init__.py index 6983ccad..40e1ce2d 100644 --- a/databricks_cli/cluster_policies/__init__.py +++ b/databricks_cli/cluster_policies/__init__.py @@ -1,6 +1,3 @@ -import warnings +from databricks_cli import issue_deprecation_warning -warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " - "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " - "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", - DeprecationWarning, stacklevel=2) +issue_deprecation_warning() diff --git a/databricks_cli/clusters/__init__.py b/databricks_cli/clusters/__init__.py index 6983ccad..40e1ce2d 100644 --- a/databricks_cli/clusters/__init__.py +++ b/databricks_cli/clusters/__init__.py @@ -1,6 +1,3 @@ -import warnings +from databricks_cli import issue_deprecation_warning -warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " - "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " - "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", - DeprecationWarning, stacklevel=2) +issue_deprecation_warning() diff --git a/databricks_cli/configure/__init__.py b/databricks_cli/configure/__init__.py index a49fd5a0..2bfcca65 100644 --- a/databricks_cli/configure/__init__.py +++ b/databricks_cli/configure/__init__.py @@ -21,9 +21,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import warnings +from databricks_cli import issue_deprecation_warning -warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " - "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " - "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", - DeprecationWarning, stacklevel=2) +issue_deprecation_warning() diff --git a/databricks_cli/dbfs/__init__.py b/databricks_cli/dbfs/__init__.py index a49fd5a0..2bfcca65 100644 --- a/databricks_cli/dbfs/__init__.py +++ b/databricks_cli/dbfs/__init__.py @@ -21,9 +21,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import warnings +from databricks_cli import issue_deprecation_warning -warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " - "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " - "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", - DeprecationWarning, stacklevel=2) +issue_deprecation_warning() diff --git a/databricks_cli/groups/__init__.py b/databricks_cli/groups/__init__.py index 6983ccad..40e1ce2d 100644 --- a/databricks_cli/groups/__init__.py +++ b/databricks_cli/groups/__init__.py @@ -1,6 +1,3 @@ -import warnings +from databricks_cli import issue_deprecation_warning -warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " - "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " - "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", - DeprecationWarning, stacklevel=2) +issue_deprecation_warning() diff --git a/databricks_cli/instance_pools/__init__.py b/databricks_cli/instance_pools/__init__.py index a49fd5a0..2bfcca65 100644 --- a/databricks_cli/instance_pools/__init__.py +++ b/databricks_cli/instance_pools/__init__.py @@ -21,9 +21,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import warnings +from databricks_cli import issue_deprecation_warning -warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " - "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " - "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", - DeprecationWarning, stacklevel=2) +issue_deprecation_warning() diff --git a/databricks_cli/jobs/__init__.py b/databricks_cli/jobs/__init__.py index 6983ccad..40e1ce2d 100644 --- a/databricks_cli/jobs/__init__.py +++ b/databricks_cli/jobs/__init__.py @@ -1,6 +1,3 @@ -import warnings +from databricks_cli import issue_deprecation_warning -warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " - "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " - "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", - DeprecationWarning, stacklevel=2) +issue_deprecation_warning() diff --git a/databricks_cli/libraries/__init__.py b/databricks_cli/libraries/__init__.py index a49fd5a0..2bfcca65 100644 --- a/databricks_cli/libraries/__init__.py +++ b/databricks_cli/libraries/__init__.py @@ -21,9 +21,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import warnings +from databricks_cli import issue_deprecation_warning -warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " - "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " - "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", - DeprecationWarning, stacklevel=2) +issue_deprecation_warning() diff --git a/databricks_cli/oauth/__init__.py b/databricks_cli/oauth/__init__.py index 327e3209..d8d8c017 100644 --- a/databricks_cli/oauth/__init__.py +++ b/databricks_cli/oauth/__init__.py @@ -21,10 +21,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import warnings - -warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " - "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " - "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", - DeprecationWarning, stacklevel=2) +from databricks_cli import issue_deprecation_warning +issue_deprecation_warning() diff --git a/databricks_cli/pipelines/__init__.py b/databricks_cli/pipelines/__init__.py index 6983ccad..40e1ce2d 100644 --- a/databricks_cli/pipelines/__init__.py +++ b/databricks_cli/pipelines/__init__.py @@ -1,6 +1,3 @@ -import warnings +from databricks_cli import issue_deprecation_warning -warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " - "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " - "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", - DeprecationWarning, stacklevel=2) +issue_deprecation_warning() diff --git a/databricks_cli/repos/__init__.py b/databricks_cli/repos/__init__.py index a49fd5a0..2bfcca65 100644 --- a/databricks_cli/repos/__init__.py +++ b/databricks_cli/repos/__init__.py @@ -21,9 +21,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import warnings +from databricks_cli import issue_deprecation_warning -warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " - "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " - "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", - DeprecationWarning, stacklevel=2) +issue_deprecation_warning() diff --git a/databricks_cli/runs/__init__.py b/databricks_cli/runs/__init__.py index 6983ccad..40e1ce2d 100644 --- a/databricks_cli/runs/__init__.py +++ b/databricks_cli/runs/__init__.py @@ -1,6 +1,3 @@ -import warnings +from databricks_cli import issue_deprecation_warning -warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " - "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " - "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", - DeprecationWarning, stacklevel=2) +issue_deprecation_warning() diff --git a/databricks_cli/sdk/__init__.py b/databricks_cli/sdk/__init__.py index 77f931cd..fb253a64 100644 --- a/databricks_cli/sdk/__init__.py +++ b/databricks_cli/sdk/__init__.py @@ -54,9 +54,6 @@ from .service import * from .api_client import ApiClient -import warnings +from databricks_cli import issue_deprecation_warning -warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " - "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " - "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", - DeprecationWarning, stacklevel=2) +issue_deprecation_warning() diff --git a/databricks_cli/secrets/__init__.py b/databricks_cli/secrets/__init__.py index a49fd5a0..2bfcca65 100644 --- a/databricks_cli/secrets/__init__.py +++ b/databricks_cli/secrets/__init__.py @@ -21,9 +21,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import warnings +from databricks_cli import issue_deprecation_warning -warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " - "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " - "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", - DeprecationWarning, stacklevel=2) +issue_deprecation_warning() diff --git a/databricks_cli/stack/__init__.py b/databricks_cli/stack/__init__.py index 6983ccad..40e1ce2d 100644 --- a/databricks_cli/stack/__init__.py +++ b/databricks_cli/stack/__init__.py @@ -1,6 +1,3 @@ -import warnings +from databricks_cli import issue_deprecation_warning -warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " - "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " - "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", - DeprecationWarning, stacklevel=2) +issue_deprecation_warning() diff --git a/databricks_cli/tokens/__init__.py b/databricks_cli/tokens/__init__.py index a49fd5a0..2bfcca65 100644 --- a/databricks_cli/tokens/__init__.py +++ b/databricks_cli/tokens/__init__.py @@ -21,9 +21,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import warnings +from databricks_cli import issue_deprecation_warning -warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " - "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " - "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", - DeprecationWarning, stacklevel=2) +issue_deprecation_warning() diff --git a/databricks_cli/unity_catalog/__init__.py b/databricks_cli/unity_catalog/__init__.py index 6983ccad..40e1ce2d 100644 --- a/databricks_cli/unity_catalog/__init__.py +++ b/databricks_cli/unity_catalog/__init__.py @@ -1,6 +1,3 @@ -import warnings +from databricks_cli import issue_deprecation_warning -warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " - "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " - "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", - DeprecationWarning, stacklevel=2) +issue_deprecation_warning() diff --git a/databricks_cli/workspace/__init__.py b/databricks_cli/workspace/__init__.py index 6983ccad..40e1ce2d 100644 --- a/databricks_cli/workspace/__init__.py +++ b/databricks_cli/workspace/__init__.py @@ -1,6 +1,3 @@ -import warnings +from databricks_cli import issue_deprecation_warning -warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " - "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " - "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", - DeprecationWarning, stacklevel=2) +issue_deprecation_warning() From c88761890cfd4bbe28c9218c686a0f226057dafa Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Wed, 4 Oct 2023 18:07:59 +0200 Subject: [PATCH 3/6] lint --- databricks_cli/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/databricks_cli/__init__.py b/databricks_cli/__init__.py index 8ee791eb..2a28d219 100644 --- a/databricks_cli/__init__.py +++ b/databricks_cli/__init__.py @@ -28,9 +28,10 @@ def issue_deprecation_warning(): - warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python 3.12 will be the last " - "version of Python supported by databricks-cli. Please migrate to databricks-sdk-py as documented in " - "the migration guide: https://docs.databricks.com/en/dev-tools/cli/migrate.html", + warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python " + "3.12 will be the last version of Python supported by databricks-cli. Please " + "migrate to databricks-sdk-py as documented in the migration guide: " + "https://docs.databricks.com/en/dev-tools/cli/migrate.html", DeprecationWarning, stacklevel=3) issue_deprecation_warning() From e06327d186a53eb4f21c0674252bc5e7b469f910 Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Thu, 5 Oct 2023 10:33:38 +0200 Subject: [PATCH 4/6] address comments --- databricks_cli/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/databricks_cli/__init__.py b/databricks_cli/__init__.py index 2a28d219..8f421a14 100644 --- a/databricks_cli/__init__.py +++ b/databricks_cli/__init__.py @@ -28,7 +28,12 @@ def issue_deprecation_warning(): - warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python " + # Don't print deprecation warning when running the CLI itself. + import sys + import os + if sys.argv and os.path.basename(sys.argv[0]) == 'databricks': + return + warnings.warn("the databricks_cli module is deprecated in favor of databricks-sdk-py. Python " "3.12 will be the last version of Python supported by databricks-cli. Please " "migrate to databricks-sdk-py as documented in the migration guide: " "https://docs.databricks.com/en/dev-tools/cli/migrate.html", From 769e088674d2f84e6f9c0c710112835351f66246 Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Thu, 5 Oct 2023 11:16:49 +0200 Subject: [PATCH 5/6] Only issue deprecation warning once --- databricks_cli/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/databricks_cli/__init__.py b/databricks_cli/__init__.py index 8f421a14..d5754382 100644 --- a/databricks_cli/__init__.py +++ b/databricks_cli/__init__.py @@ -27,7 +27,13 @@ import warnings +_has_issued_warning = False + def issue_deprecation_warning(): + global _has_issued_warning + if _has_issued_warning: + return + _has_issued_warning = True # Don't print deprecation warning when running the CLI itself. import sys import os From 0db36b08657997fa7e7e1ec3d83d06c16bd38704 Mon Sep 17 00:00:00 2001 From: Miles Yucht Date: Thu, 5 Oct 2023 11:18:36 +0200 Subject: [PATCH 6/6] address comment --- databricks_cli/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/databricks_cli/__init__.py b/databricks_cli/__init__.py index d5754382..d38c0a7c 100644 --- a/databricks_cli/__init__.py +++ b/databricks_cli/__init__.py @@ -41,8 +41,8 @@ def issue_deprecation_warning(): return warnings.warn("the databricks_cli module is deprecated in favor of databricks-sdk-py. Python " "3.12 will be the last version of Python supported by databricks-cli. Please " - "migrate to databricks-sdk-py as documented in the migration guide: " - "https://docs.databricks.com/en/dev-tools/cli/migrate.html", + "consult the documentation for the databricks-sdk-py at " + "https://databricks-sdk-py.readthedocs.io/en/latest/", DeprecationWarning, stacklevel=3) issue_deprecation_warning()