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.
| 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.
What does the stacklevel mean?
There was a problem hiding this comment.
Ideally, if folks use the Databricks CLI itself, they don't see these.
There was a problem hiding this comment.
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.
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.
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.
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.