-
Notifications
You must be signed in to change notification settings - Fork 234
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
Add deprecation warning #675
base: main
Are you sure you want to change the base?
Changes from 4 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,22 @@ | |
# pylint:disable=import-error | ||
# pylint:disable=bare-except | ||
|
||
import warnings | ||
|
||
|
||
def issue_deprecation_warning(): | ||
# 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", | ||
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. This migration guide doesn't mention the SDK, only the CLI. We should link to SDK docs here, assuming callers are trying to leverage this code as SDK. 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. Hm, we never made a migration guide for the Python SDK... |
||
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.cli
and got a spew of a dozen identical warnings.