-
Notifications
You must be signed in to change notification settings - Fork 167
Propagate auth env to experimental.python subprocess #5074
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
Changes from all commits
7f73e73
c43d713
105f706
6d93859
a749a42
a83763f
9f0f669
7b688b4
fbcdbd6
63d947a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| [my-profile] | ||
| host = $DATABRICKS_HOST | ||
| token = $DATABRICKS_TOKEN | ||
|
|
||
| [other-profile] | ||
| host = $DATABRICKS_HOST | ||
| token = other-token |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| bundle: | ||
| name: my_project | ||
|
|
||
| sync: {paths: []} # don't need to copy files | ||
|
|
||
| python: | ||
| mutators: | ||
| - "mutators:capture_profile_env" | ||
|
|
||
| workspace: | ||
| profile: my-profile | ||
|
|
||
| resources: | ||
| jobs: | ||
| my_job: | ||
| name: "Job" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| from databricks.bundles.jobs import Job | ||
| from databricks.bundles.core import job_mutator, Bundle | ||
| import os | ||
|
|
||
|
|
||
| @job_mutator | ||
| def capture_profile_env(bundle: Bundle, job: Job) -> Job: | ||
| # The CLI must propagate DATABRICKS_CONFIG_PROFILE to the python subprocess | ||
| # so the Databricks SDK can disambiguate when multiple profiles share a host. | ||
| value = os.getenv("DATABRICKS_CONFIG_PROFILE", "<unset>") | ||
| with open("captured_env.txt", "w") as f: | ||
| f.write(value) | ||
| return job |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
|
|
||
| >>> uv run [UV_ARGS] -q [CLI] bundle summary -o json | ||
| { | ||
| "profile": "my-profile" | ||
| } | ||
|
|
||
| >>> cat captured_env.txt | ||
| my-profile |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
|
|
||
| # Two workspace profiles share the same host so picking one is meaningful. | ||
| envsubst < .databrickscfg > out && mv out .databrickscfg | ||
| export DATABRICKS_CONFIG_FILE=.databrickscfg | ||
| unset DATABRICKS_HOST | ||
| unset DATABRICKS_TOKEN | ||
| unset DATABRICKS_CONFIG_PROFILE | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can use a comment why they need to be cleared. |
||
|
|
||
| trace uv run $UV_ARGS -q $CLI bundle summary -o json | jq '{profile: .workspace.profile}' | ||
|
|
||
| # The python mutator captures DATABRICKS_CONFIG_PROFILE from its subprocess env. | ||
| # Without the fix, the CLI does not propagate the bundle's resolved profile, | ||
| # so the SDK inside python re-invokes the CLI without a profile and fails on | ||
| # multi-profile ambiguity. | ||
| trace cat captured_env.txt | ||
| echo "" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: let Python write the newline. I was confused as to why this was necessary. |
||
|
|
||
| rm -fr .databricks __pycache__ captured_env.txt | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"to Python subprocesses" -- the Python support is no longer experimental.