-
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?
Conversation
Codecov ReportAttention:
📢 Thoughts on this report? Let us know!. |
databricks_cli/__init__.py
Outdated
|
||
|
||
def issue_deprecation_warning(): | ||
warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python " |
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.
warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python " | |
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) |
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.
What does the stacklevel mean?
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.
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 comment
The 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 import databricks_cli
:
When I run this databricks binary, I see that the deprecation warning is not printed, but it is when imported. |
databricks_cli/__init__.py
Outdated
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, we never made a migration guide for the Python SDK...
import sys | ||
import os | ||
if sys.argv and os.path.basename(sys.argv[0]) == 'databricks': | ||
return |
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.
This PR adds a deprecation warning with a call-to-action for users to move to https://github.com/databricks/databricks-sdk-py.