Skip to content

Commit

Permalink
Support dev and staging workspaces (#514)
Browse files Browse the repository at this point in the history
## Changes
Copies the DatabricksEnvironment abstraction from the Go SDK to the
Python SDK. This enables using the SDK for Azure development and staging
workspaces, which use an alternate Azure login application ID.

Additionally, this PR changes `azure_environment` to accept the same
values as the Go SDK and Terraform providers for both Databricks and
Azure, i.e. `PUBLIC`, `USGOVERNMENT`, and `CHINA`.

The first commit of this PR is a refactor moving config & credentials
provider code to separate files, as core.py is getting quite big and
difficult to maintain. The second one is much smaller and has just the
net new bits.

## Tests
- [x] Unit test for the new environment lookup code.
- [x] Manual test Azure CLI auth against a staging Azure workspace.
  • Loading branch information
mgyucht authored Jan 22, 2024
1 parent 26d9eaa commit f0b23a5
Show file tree
Hide file tree
Showing 14 changed files with 1,216 additions and 1,050 deletions.
5 changes: 3 additions & 2 deletions .codegen/__init__.py.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import databricks.sdk.core as client
import databricks.sdk.dbutils as dbutils
from databricks.sdk.credentials_provider import CredentialsProvider

from databricks.sdk.mixins.files import DbfsExt
from databricks.sdk.mixins.compute import ClustersExt
Expand Down Expand Up @@ -43,7 +44,7 @@ class WorkspaceClient:
debug_headers: bool = None,
product="unknown",
product_version="0.0.0",
credentials_provider: client.CredentialsProvider = None,
credentials_provider: CredentialsProvider = None,
config: client.Config = None):
if not config:
config = client.Config({{range $args}}{{.}}={{.}}, {{end}}
Expand Down Expand Up @@ -91,7 +92,7 @@ class AccountClient:
debug_headers: bool = None,
product="unknown",
product_version="0.0.0",
credentials_provider: client.CredentialsProvider = None,
credentials_provider: CredentialsProvider = None,
config: client.Config = None):
if not config:
config = client.Config({{range $args}}{{.}}={{.}}, {{end}}
Expand Down
5 changes: 3 additions & 2 deletions databricks/sdk/__init__.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions databricks/sdk/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,15 @@ class AzureEnvironment:
ARM_DATABRICKS_RESOURCE_ID = "2ff814a6-3304-4ab8-85cb-cd0e6f879c1d"

ENVIRONMENTS = dict(
PUBLIC=AzureEnvironment(name="AzurePublicCloud",
PUBLIC=AzureEnvironment(name="PUBLIC",
service_management_endpoint="https://management.core.windows.net/",
resource_manager_endpoint="https://management.azure.com/",
active_directory_endpoint="https://login.microsoftonline.com/"),
GERMAN=AzureEnvironment(name="AzureGermanCloud",
service_management_endpoint="https://management.core.cloudapi.de/",
resource_manager_endpoint="https://management.microsoftazure.de/",
active_directory_endpoint="https://login.microsoftonline.de/"),
USGOVERNMENT=AzureEnvironment(name="AzureUSGovernmentCloud",
USGOVERNMENT=AzureEnvironment(name="USGOVERNMENT",
service_management_endpoint="https://management.core.usgovcloudapi.net/",
resource_manager_endpoint="https://management.usgovcloudapi.net/",
active_directory_endpoint="https://login.microsoftonline.us/"),
CHINA=AzureEnvironment(name="AzureChinaCloud",
CHINA=AzureEnvironment(name="CHINA",
service_management_endpoint="https://management.core.chinacloudapi.cn/",
resource_manager_endpoint="https://management.chinacloudapi.cn/",
active_directory_endpoint="https://login.chinacloudapi.cn/"),
Expand Down
Loading

0 comments on commit f0b23a5

Please sign in to comment.