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

[PROD-37308] Preserve original databricks.sdk.runtime for internal purposes #96

Merged
merged 6 commits into from
May 10, 2023

Conversation

dby-tmwctw
Copy link
Contributor

@dby-tmwctw dby-tmwctw commented May 5, 2023

Changes

We want to use databricks-sdk in DBR but currently installing it breaks existing databricks.sdk.runtime module we added. This PR fix it by using the internal packages if existed, and fall-back to OSS implementation if that does not exist.

Tests

  • Manual testing on E2 Dogfood

  • make test run locally

  • make fmt applied

  • relevant integration tests applied

@codecov-commenter
Copy link

codecov-commenter commented May 5, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (c42296e) 52.72% compared to head (218a714) 52.72%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #96   +/-   ##
=======================================
  Coverage   52.72%   52.72%           
=======================================
  Files          29       29           
  Lines       17067    17067           
=======================================
  Hits         8998     8998           
  Misses       8069     8069           
Impacted Files Coverage Δ
databricks/sdk/runtime/__init__.py 0.00% <0.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@nfx nfx left a comment

Choose a reason for hiding this comment

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

Few comments

databricks/sdk/runtime/__init__.py Outdated Show resolved Hide resolved
dbutils = RemoteDbUtils()
# OSS implementation
is_oss_implementation = True
dbutils = _get_global_dbutils()
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you check if we can remove _get_global_dbutils function altogether? It’s meant to check if “dbutils” got injected into nonlocal namespace

Copy link
Contributor

Choose a reason for hiding this comment

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

+1. here you are explicitly injecting dbutils into the globals namespace. So we don't really need to see if dbutils are injected when is_oss_implementation = True

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nfx @kartikgupta-db Makes sense, may I know how to test whether it is OK to remove it though, is passing unit tests sufficient?

Copy link
Contributor

Choose a reason for hiding this comment

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

We don’t have unit tests for this module yet.

dbutils = _get_global_dbutils()

try:
from .stub import *
Copy link
Contributor

Choose a reason for hiding this comment

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

Stub is only there for VSCODE extension to show Autocompletion with documentation. It has no implementation, as you see.

@kartikgupta-db do you think we can remove stub and keep VSCode extension functioning properly?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not for now. We have started fully depending on the SDK for the stubs. So we need to keep them in.

Copy link
Contributor

Choose a reason for hiding this comment

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

@kartikgupta-db can we somehow separate the stubs even further within the SDK?

# this assumes that all environment variables are set
dbutils = RemoteDbUtils()
except NameError:
from databricks.sdk.dbutils import RemoteDbUtils
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to import remote dbutils implementation twice?…

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nfx This is the original OSS implementation, but the commit suggestion by @kartikgupta-db down seems to solve this issue.

@nfx nfx requested a review from kartikgupta-db May 6, 2023 09:09
dbutils = RemoteDbUtils()
# OSS implementation
is_oss_implementation = True
dbutils = _get_global_dbutils()
Copy link
Contributor

Choose a reason for hiding this comment

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

+1. here you are explicitly injecting dbutils into the globals namespace. So we don't really need to see if dbutils are injected when is_oss_implementation = True

databricks/sdk/runtime/__init__.py Outdated Show resolved Hide resolved
dby-tmwctw and others added 2 commits May 8, 2023 13:28
Co-authored-by: Kartik Gupta <88345179+kartikgupta-db@users.noreply.github.com>
Signed-off-by: Boyuan Deng <40481626+dby-tmwctw@users.noreply.github.com>
@dby-tmwctw dby-tmwctw requested review from nfx and kartikgupta-db May 8, 2023 17:43
Copy link
Contributor

@nfx nfx left a comment

Choose a reason for hiding this comment

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

Looks good to me, let’s wait for @kartikgupta-db to approve from VSCode part

@dby-tmwctw dby-tmwctw requested a review from xiaochen-db May 9, 2023 21:16
Copy link
Contributor

@nfx nfx left a comment

Choose a reason for hiding this comment

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

lgtm

@nfx nfx merged commit 606926a into databricks:main May 10, 2023
@nfx nfx mentioned this pull request May 10, 2023
nfx added a commit that referenced this pull request May 10, 2023
# Version changelog

## 0.1.6

* Preserve original `databricks.sdk.runtime` for internal purposes
([#96](#96)).
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.

5 participants