Skip to content

Commit aba0730

Browse files
authored
Remove deprecated PyDABs support (#3102)
## Changes Remove deprecated `experimental/pydabs` support. Leave a minimal amount of code to generate errors if deprecated properties are used. Otherwise, it's possible that resources are going to be unexpectedly deleted. ## Why `experimental/pydabs` was replaced with `experimental/python`
1 parent 915e224 commit aba0730

File tree

9 files changed

+14
-126
lines changed

9 files changed

+14
-126
lines changed

NEXT_CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@
99
### CLI
1010

1111
### Bundles
12+
* Remove support for deprecated `experimental/pydabs` config, use `experimental/python` instead. See [Configuration in Python
13+
](https://docs.databricks.com/dev-tools/bundles/python). ([#3102](https://github.com/databricks/cli/pull/3102))
1214

1315
### API Changes

acceptance/bundle/debug/out.stderr.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@
4545
10:07:59 Debug: Apply pid=12345 mutator=ProcessStaticResources mutator=ResolveVariableReferences(resources)
4646
10:07:59 Debug: Apply pid=12345 mutator=ProcessStaticResources mutator=NormalizePaths
4747
10:07:59 Debug: Apply pid=12345 mutator=ProcessStaticResources mutator=TranslatePathsDashboards
48-
10:07:59 Debug: Apply pid=12345 mutator=PythonMutator(load)
49-
10:07:59 Debug: Apply pid=12345 mutator=PythonMutator(init)
5048
10:07:59 Debug: Apply pid=12345 mutator=PythonMutator(load_resources)
5149
10:07:59 Debug: Apply pid=12345 mutator=PythonMutator(apply_mutators)
5250
10:07:59 Debug: Apply pid=12345 mutator=CheckPermissions

bundle/config/experimental.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ type Experimental struct {
2424
// as a top-level permission in the DAB.
2525
UseLegacyRunAs bool `json:"use_legacy_run_as,omitempty"`
2626

27-
// PyDABs determines whether to load the 'databricks-pydabs' package.
28-
//
29-
// PyDABs allows to define bundle configuration using Python.
3027
// PyDABs is deprecated use Python instead.
3128
PyDABs PyDABs `json:"pydabs,omitempty"`
3229

@@ -70,18 +67,6 @@ type Python struct {
7067
type PyDABs struct {
7168
// Enabled is a flag to enable the feature.
7269
Enabled bool `json:"enabled,omitempty"`
73-
74-
// VEnvPath is path to the virtual environment.
75-
//
76-
// If enabled, PyDABs will execute code within this environment. If disabled,
77-
// it defaults to using the Python interpreter available in the current shell.
78-
VEnvPath string `json:"venv_path,omitempty"`
79-
80-
// Import contains a list Python packages with PyDABs code.
81-
//
82-
// These packages are imported to discover resources, resource generators, and mutators.
83-
// This list can include namespace packages, which causes the import of nested packages.
84-
Import []string `json:"import,omitempty"`
8570
}
8671

8772
type (

bundle/config/mutator/python/python_mutator.go

Lines changed: 7 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -36,39 +36,6 @@ import (
3636
type phase string
3737

3838
const (
39-
// PythonMutatorPhaseLoad is the phase in which bundle configuration is loaded.
40-
//
41-
// At this stage, PyDABs adds statically defined resources to the bundle configuration.
42-
// Which resources are added should be deterministic and not depend on the bundle configuration.
43-
//
44-
// We also open for possibility of appending other sections of bundle configuration,
45-
// for example, adding new variables. However, this is not supported yet, and CLI rejects
46-
// such changes.
47-
//
48-
// Deprecated, left for backward-compatibility with PyDABs.
49-
PythonMutatorPhaseLoad phase = "load"
50-
51-
// PythonMutatorPhaseInit is the phase after bundle configuration was loaded, and
52-
// the list of statically declared resources is known.
53-
//
54-
// At this stage, PyDABs adds resources defined using generators, or mutates existing resources,
55-
// including the ones defined using YAML.
56-
//
57-
// During this process, within generator and mutators, PyDABs can access:
58-
// - selected deployment target
59-
// - bundle variables values
60-
// - variables provided through CLI arguments or environment variables
61-
//
62-
// The following is not available:
63-
// - variables referencing other variables are in unresolved format
64-
//
65-
// PyDABs can output YAML containing references to variables, and CLI should resolve them.
66-
//
67-
// Existing resources can't be removed, and CLI rejects such changes.
68-
//
69-
// Deprecated, left for backward-compatibility with PyDABs.
70-
PythonMutatorPhaseInit phase = "init"
71-
7239
// PythonMutatorPhaseLoadResources is the phase in which YAML configuration was loaded.
7340
//
7441
// At this stage, we execute Python code to load resources defined in Python.
@@ -150,24 +117,11 @@ func getOpts(b *bundle.Bundle, phase phase) (opts, error) {
150117
pydabsEnabled := !reflect.DeepEqual(experimental.PyDABs, config.PyDABs{})
151118
pythonEnabled := !reflect.DeepEqual(experimental.Python, config.Python{})
152119

153-
if pydabsEnabled && pythonEnabled {
154-
return opts{}, errors.New("both experimental/pydabs and experimental/python are enabled, only one can be enabled")
155-
} else if pydabsEnabled {
156-
if !experimental.PyDABs.Enabled {
157-
return opts{}, nil
158-
}
120+
if pydabsEnabled {
121+
return opts{}, errors.New("experimental/pydabs is deprecated, use experimental/python instead (https://docs.databricks.com/dev-tools/bundles/python)")
122+
}
159123

160-
// don't execute for phases for 'python' section
161-
if phase == PythonMutatorPhaseInit || phase == PythonMutatorPhaseLoad {
162-
return opts{
163-
enabled: true,
164-
venvPath: experimental.PyDABs.VEnvPath,
165-
loadLocations: false, // not supported in PyDABs
166-
}, nil
167-
} else {
168-
return opts{}, nil
169-
}
170-
} else if pythonEnabled {
124+
if pythonEnabled {
171125
// don't execute for phases for 'pydabs' section
172126
if phase == PythonMutatorPhaseLoadResources || phase == PythonMutatorPhaseApplyMutators {
173127
return opts{
@@ -258,14 +212,9 @@ func (m *pythonMutator) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagno
258212
return newRoot, nil
259213
})
260214

261-
// don't instrument deprecated phases
262-
if m.phase == PythonMutatorPhaseLoadResources || m.phase == PythonMutatorPhaseApplyMutators {
263-
// we can precisely track resources that are added/updated, so sum doesn't double-count
264-
b.Metrics.PythonUpdatedResourcesCount += int64(result.UpdatedResources.Size())
265-
b.Metrics.PythonAddedResourcesCount += int64(result.AddedResources.Size())
266-
} else {
267-
mutateDiags = mutateDiags.Extend(diag.Warningf("experimental/pydabs is deprecated and will be removed in future versions, use experimental/python instead"))
268-
}
215+
// we can precisely track resources that are added/updated, so sum doesn't double-count
216+
b.Metrics.PythonUpdatedResourcesCount += int64(result.UpdatedResources.Size())
217+
b.Metrics.PythonAddedResourcesCount += int64(result.AddedResources.Size())
269218

270219
if err == mutateDiagsHasError {
271220
if !mutateDiags.HasError() {

bundle/config/mutator/python/python_mutator_test.go

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,6 @@ import (
2424
"github.com/databricks/cli/libs/process"
2525
)
2626

27-
func TestPythonMutator_Name_load(t *testing.T) {
28-
mutator := PythonMutator(PythonMutatorPhaseLoad)
29-
30-
assert.Equal(t, "PythonMutator(load)", mutator.Name())
31-
}
32-
33-
func TestPythonMutator_Name_init(t *testing.T) {
34-
mutator := PythonMutator(PythonMutatorPhaseInit)
35-
36-
assert.Equal(t, "PythonMutator(init)", mutator.Name())
37-
}
38-
3927
func TestPythonMutator_Name_loadResources(t *testing.T) {
4028
mutator := PythonMutator(PythonMutatorPhaseLoadResources)
4129

@@ -293,7 +281,7 @@ func TestPythonMutator_disabled(t *testing.T) {
293281
b := loadYaml("databricks.yml", ``)
294282

295283
ctx := context.Background()
296-
mutator := PythonMutator(PythonMutatorPhaseLoad)
284+
mutator := PythonMutator(PythonMutatorPhaseLoadResources)
297285
diag := bundle.Apply(ctx, b, mutator)
298286

299287
assert.NoError(t, diag.Error())
@@ -334,19 +322,17 @@ func TestGetOps_Python(t *testing.T) {
334322
}
335323

336324
func TestGetOps_PyDABs(t *testing.T) {
337-
actual, err := getOpts(&bundle.Bundle{
325+
_, err := getOpts(&bundle.Bundle{
338326
Config: config.Root{
339327
Experimental: &config.Experimental{
340328
PyDABs: config.PyDABs{
341-
VEnvPath: ".venv",
342-
Enabled: true,
329+
Enabled: true,
343330
},
344331
},
345332
},
346-
}, PythonMutatorPhaseInit)
333+
}, PythonMutatorPhaseLoadResources)
347334

348-
assert.NoError(t, err)
349-
assert.Equal(t, opts{venvPath: ".venv", enabled: true, loadLocations: false}, actual)
335+
assert.Error(t, err, "experimental/pydabs is deprecated, use experimental/python instead (https://docs.databricks.com/dev-tools/bundles/python)")
350336
}
351337

352338
func TestGetOps_empty(t *testing.T) {

bundle/deploy/terraform/init.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,6 @@ func setUserAgentExtraEnvVar(environ map[string]string, b *bundle.Bundle) error
269269

270270
if hasPython {
271271
products = append(products, "databricks-pydabs/0.7.0")
272-
} else if experimental.PyDABs.Enabled {
273-
products = append(products, "databricks-pydabs/0.0.0")
274272
}
275273
}
276274

bundle/deploy/terraform/init_test.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -250,26 +250,6 @@ func TestSetProxyEnvVars(t *testing.T) {
250250
assert.ElementsMatch(t, []string{"HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY"}, maps.Keys(env))
251251
}
252252

253-
func TestSetUserAgentExtra_PyDABs(t *testing.T) {
254-
b := &bundle.Bundle{
255-
BundleRootPath: t.TempDir(),
256-
Config: config.Root{
257-
Experimental: &config.Experimental{
258-
PyDABs: config.PyDABs{
259-
Enabled: true,
260-
},
261-
},
262-
},
263-
}
264-
265-
env := make(map[string]string, 0)
266-
err := setUserAgentExtraEnvVar(env, b)
267-
require.NoError(t, err)
268-
assert.Equal(t, map[string]string{
269-
"DATABRICKS_USER_AGENT_EXTRA": "cli/0.0.0-dev databricks-pydabs/0.0.0",
270-
}, env)
271-
}
272-
273253
func TestSetUserAgentExtra_Python(t *testing.T) {
274254
b := &bundle.Bundle{
275255
BundleRootPath: t.TempDir(),

bundle/phases/initialize.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ func Initialize(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
130130
// Static resources (e.g. YAML) are already loaded, we initialize and normalize them before Python
131131
resourcemutator.ProcessStaticResources(),
132132

133-
pythonmutator.PythonMutator(pythonmutator.PythonMutatorPhaseLoad),
134-
pythonmutator.PythonMutator(pythonmutator.PythonMutatorPhaseInit),
135133
pythonmutator.PythonMutator(pythonmutator.PythonMutatorPhaseLoadResources),
136134
pythonmutator.PythonMutator(pythonmutator.PythonMutatorPhaseApplyMutators),
137135
// This is the last mutator that can change bundle resources.

bundle/schema/jsonschema.json

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)