-
Notifications
You must be signed in to change notification settings - Fork 234
Add deprecation warning #675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d4ed50f
a811dcd
c887618
e06327d
fddab2c
769e088
0db36b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,28 @@ | |
| # pylint:disable=import-error | ||
| # pylint:disable=bare-except | ||
|
|
||
| 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 | ||
| 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 " | ||
| "consult the documentation for the databricks-sdk-py at " | ||
| "https://databricks-sdk-py.readthedocs.io/en/latest/", | ||
| DeprecationWarning, stacklevel=3) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does the stacklevel mean? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally, if folks use the Databricks CLI itself, they don't see these. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. stacklevel changes the output of warnings.warn. Normally, the warning message starts with the line that the warning.warn call is on, but increasing stacklevel allows the warning to point to the place where the caller uses the library/function in question. In this case, the warning will point to the line with |
||
|
|
||
| issue_deprecation_warning() | ||
|
|
||
| def initialize_cli_for_databricks_notebooks(): | ||
| import IPython | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from databricks_cli import issue_deprecation_warning | ||
|
|
||
| issue_deprecation_warning() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from databricks_cli import issue_deprecation_warning | ||
|
|
||
| issue_deprecation_warning() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from databricks_cli import issue_deprecation_warning | ||
|
|
||
| issue_deprecation_warning() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from databricks_cli import issue_deprecation_warning | ||
|
|
||
| issue_deprecation_warning() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from databricks_cli import issue_deprecation_warning | ||
|
|
||
| issue_deprecation_warning() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from databricks_cli import issue_deprecation_warning | ||
|
|
||
| issue_deprecation_warning() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from databricks_cli import issue_deprecation_warning | ||
|
|
||
| issue_deprecation_warning() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from databricks_cli import issue_deprecation_warning | ||
|
|
||
| issue_deprecation_warning() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from databricks_cli import issue_deprecation_warning | ||
|
|
||
| issue_deprecation_warning() |

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add a check here to only fire the warning once?
I ran
python3 -m databricks_cli.cliand got a spew of a dozen identical warnings.