Skip to content

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

Merged
nfx merged 6 commits intodatabricks:mainfrom
dby-tmwctw:original-runtime-boyuan
May 10, 2023
Merged

[PROD-37308] Preserve original databricks.sdk.runtime for internal purposes#96
nfx merged 6 commits intodatabricks:mainfrom
dby-tmwctw:original-runtime-boyuan

Conversation

@dby-tmwctw
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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

dbutils = RemoteDbUtils()
# OSS implementation
is_oss_implementation = True
dbutils = _get_global_dbutils()
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

dby-tmwctw and others added 2 commits May 8, 2023 13:28
@dby-tmwctw dby-tmwctw requested review from kartikgupta-db and nfx May 8, 2023 17:43
Copy link
Copy Markdown
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
Copy Markdown
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