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

Framework for creating and using the Unity Catalog connections API #647

Merged
merged 4 commits into from
Aug 8, 2023

Conversation

jamesd-db
Copy link

@jamesd-db jamesd-db commented Jun 5, 2023

Creating a framework for creating and using the Unity Catalog connections API with the Databricks CLI.

@jamesd-db jamesd-db requested a review from andrewli81 June 5, 2023 23:53
@jamesd-db jamesd-db changed the title First changes to create a connections CLI Framework for creating and using the Unity Catalog connections API Jun 5, 2023

# These two options are shared among create and updates, so they are very common
def create_update_common_options(f):
@click.option('--read-only/--no-read-only', is_flag=True, default=None,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: 'Whether the connection is read-only'

@eat_exceptions
@profile_option
@provide_api_client
def create_online_catalog_cli(api_client, name, host, port, user,
Copy link
Contributor

@andrewli81 andrewli81 Jun 9, 2023

Choose a reason for hiding this comment

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

Ah I forgot to say this is not user creatable! Let's remove this.

Create new connection with an inline JSON or JSON file input.
'''
if (json is None) and (json_file is None):
raise ValueError('Must either provide inline JSON or JSON file.')
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: "Must either provide inline JSON or JSON file path."

@profile_option
@eat_exceptions
@provide_api_client
def list_connections_cli(api_client, ):
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't need the extra comma?

@profile_option
@eat_exceptions
@provide_api_client
def delete_connection_cli(api_client, name):
Copy link
Contributor

Choose a reason for hiding this comment

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

Did we omit the update_connection_cli?

COMMENT = 'some_comment'

TESTHOST = "test_postgresql.fakedb.com"
TESTHOST2 = "postgresql.fakedb2.lan"
Copy link
Contributor

@andrewli81 andrewli81 Jun 9, 2023

Choose a reason for hiding this comment

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

TESTHOST2 and TESTPORT2 are unused?



@provide_conf
def test_create_connection_cli(api_mock):
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add tests for get, update, delete list as well?

@andrewli81
Copy link
Contributor

@jamesd-db Good news - @pietern is working on a new Databricks CLI that automatically generates client code based on open api spec - so we will have coverage automatically. Looks like it's already showing on the SDK: https://github.com/databricks/databricks-sdk-go/blob/1504930d8c20337f353f13d4934700d85e0b6ed5/service/catalog/interface.go#L177-L220

We can stop polishing this PR or adding tests and just use this as a test environment for our OAuth work!

@jamesd-db jamesd-db changed the base branch from main to uc-connections June 26, 2023 21:00
@jamesd-db jamesd-db force-pushed the main branch 2 times, most recently from 472e043 to 4f34d99 Compare June 27, 2023 19:06
@codecov-commenter
Copy link

codecov-commenter commented Jun 27, 2023

Codecov Report

Patch coverage: 59.88% and project coverage change: -1.13% ⚠️

Comparison is base (dd47ce4) 76.56% compared to head (3be4a4f) 75.44%.
Report is 1 commits behind head on uc-connections.

Additional details and impacted files
@@                Coverage Diff                 @@
##           uc-connections     #647      +/-   ##
==================================================
- Coverage           76.56%   75.44%   -1.13%     
==================================================
  Files                  55       56       +1     
  Lines                5048     5387     +339     
==================================================
+ Hits                 3865     4064     +199     
- Misses               1183     1323     +140     
Files Changed Coverage Δ
databricks_cli/unity_catalog/cli.py 0.00% <0.00%> (ø)
databricks_cli/unity_catalog/uc_service.py 27.85% <33.33%> (+0.30%) ⬆️
databricks_cli/unity_catalog/api.py 48.14% <50.00%> (+0.12%) ⬆️
databricks_cli/unity_catalog/connection_cli.py 61.85% <61.85%> (ø)

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jamesd-db jamesd-db changed the title Framework for creating and using the Unity Catalog connections API [SC-133066][SC-134677] Framework for creating and using the Unity Catalog connections API Jun 27, 2023
@alexott
Copy link
Contributor

alexott commented Jun 28, 2023

I think that it's better to switch to the new Databricks CLI and Python SDKs that are automatically generated from OpenAPI specs

@andrewli81
Copy link
Contributor

@alexott we chatted with @pietern - we just want to archive this code (it is mainly used for testing oauth support for query federation connections) in its dedicated branch since it was worked on by our intern before the new cli was live and also we might not have time to convert it into the new cli during the internship. We eventually will move this to the new cli but likely after @jamesd-db's internship ends. So @pietern created this branch for us.

@pietern
Copy link
Contributor

pietern commented Jul 6, 2023

By merging we archive the work on a branch for future reference. No intention of merging this into main.

@pietern
Copy link
Contributor

pietern commented Jul 6, 2023

@andrewli81 Is this PR otherwise done?

@andrewli81
Copy link
Contributor

@pietern Yes this PR is otherwise done, @jamesd-db uploaded the OAuth client changes and pointed this PR to the branch you created, we should be good to merge.

@jamesd-db jamesd-db marked this pull request as ready for review July 6, 2023 22:11
@pietern pietern changed the title [SC-133066][SC-134677] Framework for creating and using the Unity Catalog connections API Framework for creating and using the Unity Catalog connections API Aug 8, 2023
@pietern
Copy link
Contributor

pietern commented Aug 8, 2023

References to JIRA: SC-133066 and SC-134677

@pietern pietern merged commit 716f762 into databricks:uc-connections Aug 8, 2023
7 checks passed
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