Skip to content
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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Add deprecation warning #675

wants to merge 7 commits into from

Conversation

mgyucht
Copy link
Contributor

@mgyucht mgyucht commented Oct 4, 2023

This PR adds a deprecation warning with a call-to-action for users to move to https://github.com/databricks/databricks-sdk-py.

@mgyucht mgyucht requested a review from pietern October 4, 2023 15:59
@codecov-commenter
Copy link

codecov-commenter commented Oct 4, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Files Coverage Δ
databricks_cli/cluster_policies/__init__.py 100.00% <100.00%> (ø)
databricks_cli/clusters/__init__.py 100.00% <100.00%> (ø)
databricks_cli/configure/__init__.py 100.00% <100.00%> (ø)
databricks_cli/dbfs/__init__.py 100.00% <100.00%> (ø)
databricks_cli/groups/__init__.py 100.00% <100.00%> (ø)
databricks_cli/instance_pools/__init__.py 100.00% <100.00%> (ø)
databricks_cli/jobs/__init__.py 100.00% <100.00%> (ø)
databricks_cli/libraries/__init__.py 100.00% <100.00%> (ø)
databricks_cli/oauth/__init__.py 100.00% <100.00%> (ø)
databricks_cli/pipelines/__init__.py 100.00% <100.00%> (ø)
... and 8 more

📢 Thoughts on this report? Let us know!.



def issue_deprecation_warning():
warnings.warn("the databricks-cli module is deprecated in favor of databricks-sdk-py. Python "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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:
Screenshot 2023-10-05 at 10 41 20

@mgyucht
Copy link
Contributor Author

mgyucht commented Oct 5, 2023

When I run this databricks binary, I see that the deprecation warning is not printed, but it is when imported.
Screenshot 2023-10-05 at 10 41 50
#675 (comment)

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",
Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants