-
Notifications
You must be signed in to change notification settings - Fork 42
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
Consolidate environment variable interaction #747
Conversation
There are a couple places throughout the code base where interaction with environment variables takes place. Moreover, more than one of these would try to read a value from more than one environment variable as fallback (for backwards compatibility). This change consolidates those accesses. The majority of diffs in this change are mechanical (i.e. add an argument or replace a call). This change: * Moves common environment variable lookups for bundles to `bundles/env`. * Adds a `libs/env` package that wraps `os.LookupEnv` and `os.Getenv` and allows for overrides to take place in a `context.Context`. By scoping overrides to a `context.Context` we can avoid `t.Setenv` in testing and unlock parallel test execution. * Updates call sites to pass through a `context.Context` where needed. * For bundles, introduces `DATABRICKS_BUNDLE_ROOT` as new primary variable instead of `BUNDLE_ROOT`. This was the last environment variable that did not use the `DATABRICKS_` prefix.
|
||
// format is <DATABRICKS_BUNDLE_TMP>/<target> | ||
assert.NoError(t, err) | ||
assert.Equal(t, filepath.Join(bundleTmpDir, "default"), cacheDir) | ||
} | ||
|
||
func TestBundleMustLoadSuccess(t *testing.T) { | ||
t.Setenv(envBundleRoot, "./tests/basic") | ||
t.Setenv(env.RootVariable, "./tests/basic") |
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.
shall we use envlib.Set(ctx, env.RootVariable, "./tests/basic") here instead already? Or in general what is our plan to get rid of t.Setenv?
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.
We have (and will have) a couple of long running tests that should be parallelized. We don't have to parallelise all tests IMO, for example tests that don't make any/very few network calls.
For example, the sync integration tests can take minutes if run serially and thus are important to parallelise.
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.
Indeed, we can do this incrementally. I'd like this change to be as small and mechanical as possible.
Bundles: * Fix conversion of job parameters ([#744](#744)). * Add schema and config validation to jsonschema package ([#740](#740)). * Support Model Serving Endpoints in bundles ([#682](#682)). * Do not include empty output in job run output ([#749](#749)). * Fixed marking libraries from DBFS as remote ([#750](#750)). * Process only Python wheel tasks which have local libraries used ([#751](#751)). * Add enum support for bundle templates ([#668](#668)). * Apply Python wheel trampoline if workspace library is used ([#755](#755)). * List available targets when incorrect target passed ([#756](#756)). * Make bundle and sync fields optional ([#757](#757)). * Consolidate environment variable interaction ([#747](#747)). Internal: * Update Go SDK to v0.19.1 ([#759](#759)).
Bundles: * Fix conversion of job parameters ([#744](#744)). * Add schema and config validation to jsonschema package ([#740](#740)). * Support Model Serving Endpoints in bundles ([#682](#682)). * Do not include empty output in job run output ([#749](#749)). * Fixed marking libraries from DBFS as remote ([#750](#750)). * Process only Python wheel tasks which have local libraries used ([#751](#751)). * Add enum support for bundle templates ([#668](#668)). * Apply Python wheel trampoline if workspace library is used ([#755](#755)). * List available targets when incorrect target passed ([#756](#756)). * Make bundle and sync fields optional ([#757](#757)). * Consolidate environment variable interaction ([#747](#747)). Internal: * Update Go SDK to v0.19.1 ([#759](#759)).
## Changes There are a couple places throughout the code base where interaction with environment variables takes place. Moreover, more than one of these would try to read a value from more than one environment variable as fallback (for backwards compatibility). This change consolidates those accesses. The majority of diffs in this change are mechanical (i.e. add an argument or replace a call). This change: * Moves common environment variable lookups for bundles to `bundles/env`. * Adds a `libs/env` package that wraps `os.LookupEnv` and `os.Getenv` and allows for overrides to take place in a `context.Context`. By scoping overrides to a `context.Context` we can avoid `t.Setenv` in testing and unlock parallel test execution for integration tests. * Updates call sites to pass through a `context.Context` where needed. * For bundles, introduces `DATABRICKS_BUNDLE_ROOT` as new primary variable instead of `BUNDLE_ROOT`. This was the last environment variable that did not use the `DATABRICKS_` prefix. ## Tests Unit tests pass.
Bundles: * Fix conversion of job parameters ([#744](#744)). * Add schema and config validation to jsonschema package ([#740](#740)). * Support Model Serving Endpoints in bundles ([#682](#682)). * Do not include empty output in job run output ([#749](#749)). * Fixed marking libraries from DBFS as remote ([#750](#750)). * Process only Python wheel tasks which have local libraries used ([#751](#751)). * Add enum support for bundle templates ([#668](#668)). * Apply Python wheel trampoline if workspace library is used ([#755](#755)). * List available targets when incorrect target passed ([#756](#756)). * Make bundle and sync fields optional ([#757](#757)). * Consolidate environment variable interaction ([#747](#747)). Internal: * Update Go SDK to v0.19.1 ([#759](#759)).
Changes
There are a couple places throughout the code base where interaction with environment variables takes place. Moreover, more than one of these would try to read a value from more than one environment variable as fallback (for backwards compatibility). This change consolidates those accesses.
The majority of diffs in this change are mechanical (i.e. add an argument or replace a call).
This change:
bundles/env
.libs/env
package that wrapsos.LookupEnv
andos.Getenv
and allows for overrides to take place in acontext.Context
. By scoping overrides to acontext.Context
we can avoidt.Setenv
in testing and unlock parallel test execution for integration tests.context.Context
where needed.DATABRICKS_BUNDLE_ROOT
as new primary variable instead ofBUNDLE_ROOT
. This was the last environment variable that did not use theDATABRICKS_
prefix.Tests
Unit tests pass.