Skip to content

Resolve relative python.venv_path against the bundle root - #8184

Open
denik wants to merge 2 commits into
mainfrom
denik/fix-python-venv-subdir
Open

denik wants to merge 2 commits into
mainfrom
denik/fix-python-venv-subdir

Conversation

@denik

@denik denik commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Changes

detectExecutable in the Python mutator now joins a relative venv_path with the bundle root before looking up the interpreter, and returns the interpreter as an absolute path: the subprocess runs with the bundle root as its working directory, so a path relative to the current directory would not resolve there (e.g. with DATABRICKS_BUNDLE_ROOT=..). An absolute path, an unset venv_path (Python from PATH), and on Windows a drive-relative (C:venv) or drive-rooted (\venv) path behave as before; the "can't find" error text is unchanged.

Why

With the pydabs template default venv_path: .venv, every bundle command run from a subdirectory of the bundle failed to find the venv (see the test PR #8181). The Python subprocess already runs in the bundle root, and the other relative paths in databricks.yml are relative to it as well.

Tests

  • acceptance/bundle/python/venv-path-subdir (from acc: record relative python.venv_path failing from a bundle subdirectory #8181): bundle summary from src/ now prints the same job as from the root; Badness removed. A new case runs it from src/ with a relative DATABRICKS_BUNDLE_ROOT=..; it fails without the absolute path (fork/exec ../.venv/bin/python3: no such file or directory).
  • TestIsRelativeToBundleRoot covers which paths are joined (the Windows cases run only in the Windows CI job).
  • TestPythonMutator_loadResources now puts the fake venv under the bundle root while the current directory is elsewhere. It fails without the fix (can't find ".venv/bin/python3").
  • The unit tests' process stub now checks the interpreter path on the command line: TestPythonMutator_applyMutators and TestPythonMutator_badOutput fail if the path isn't made absolute.
  • go test ./bundle/... ./libs/python/... and TestAccept/bundle/python and bundle/templates/pydabs pass locally.

This PR was created by analyzing coverage gaps. Coverage: http://go/cli/dashboard/coverage/file/bundle/config/mutator/python/python_mutator.go ((*pythonMutator).Apply, lines 231-369).

Gaps and risks

  • A user who relied on the old behavior (a relative venv_path that only worked from one particular subdirectory) now gets the path under the bundle root. That looks unlikely: such a config fails from the bundle root, where the templates and docs run commands.
  • Windows isn't run locally: filepath.IsAbs/Join handle both separators and CI covers the unit test there.
  • Judgment calls from the self-review, left as is: a relative venv_path is relative to the bundle root even when it is set in an included file in a subdirectory (before it was relative to the current directory, so neither matched the defining file); ../.venv under a symlinked bundle root resolves lexically. All look rare next to the template default .venv. The venv_path doc comment and schema description now say a relative path is relative to the bundle root.
  • Risk: low.

🤖 AI agent (opus5.5, isaac_claude)

This pull request and its description were written by Isaac.

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Regression test report ✅

Commit: 75ed01212 | Workflow run

Selected 1 changed tests (limit=20, 0 not selected)

2 tests: regression=2 unreleased=0 coverage=0 failing=0
test branch main (9e5ad79) latest (v1.28.0)
TestAccept/bundle/python/venv-path-subdir/DMS=/PYDAB_VERSION=current ✅ ❌ ❌
TestAccept/bundle/python/venv-path-subdir/DMS=true/PYDAB_VERSION=current ✅ ❌ ❌
TestAccept/bundle/python/venv-path-subdir/DMS=/PYDAB_VERSION=current: branch ✅ | main (9e5ad79) ❌ | latest (v1.28.0) ❌

main (9e5ad79):

acceptance_test.go:1402: 
        	Error Trace:	/home/runner/work/cli/cli/libs/testdiff/testdiff.go:22
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:1402
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:1143
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:704
        	Error:      	Not equal: 
        	            	expected: "\n=== from the bundle root\n\n>>> [CLI] bundle summary\nName: my_project\nTarget: default\nWorkspace:\n  User: [USERNAME]\n  Path: /Workspace/Users/[USERNAME]/.bundle/my_project/default\nResources:\n  Jobs:\n    my_job:\n      Name: My Job\n      URL:  (not deployed)\n\n=== from a subdirectory\n\n>>> withdir src [CLI] bundle summary\nName: my_project\nTarget: default\nWorkspace:\n  User: [USERNAME]\n  Path: /Workspace/Users/[USERNAME]/.bundle/my_project/default\nResources:\n  Jobs:\n    my_job:\n      Name: My Job\n      URL:  (not deployed)\n\n=== from a subdirectory with a relative DATABRICKS_BUNDLE_ROOT\n\n>>> withdir src [CLI] bundle summary\nName: my_project\nTarget: default\nWorkspace:\n  User: [USERNAME]\n  Path: /Workspace/Users/[USERNAME]/.bundle/my_project/default\nResources:\n  Jobs:\n    my_job:\n      Name: My Job\n      URL:  (not deployed)\n"
        	            	actual  : "\n=== from the bundle root\n\n>>> [CLI] bundle summary\nName: my_project\nTarget: default\nWorkspace:\n  User: [USERNAME]\n  Path: /Workspace/Users/[USERNAME]/.bundle/my_project/default\nResources:\n  Jobs:\n    my_job:\n      Name: My Job\n      URL:  (not deployed)\n\n=== from a subdirectory\n\n>>> withdir src [CLI] bundle summary\nError: failed to get Python interpreter path: can't find \".venv/bin/python3\", check if virtualenv is created\n\n\nExit code: 1\n"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -18,26 +18,6 @@
        	            	 >>> withdir src [CLI] bundle summary
        	            	-Name: my_project
        	            	-Target: default
        	            	-Workspace:
        	            	-  User: [USERNAME]
        	            	-  Path: /Workspace/Users/[USERNAME]/.bundle/my_project/default
        	            	-Resources:
        	            	-  Jobs:
        	            	-    my_job:
        	            	-      Name: My Job
        	            	-      URL:  (not deployed)
        	            	+Error: failed to get Python interpreter path: can't find ".venv/bin/python3", check if virtualenv is created
        	            	 
        	            	-=== from a subdirectory with a relative DATABRICKS_BUNDLE_ROOT
        	            	 
        	            	->>> withdir src [CLI] bundle summary
        	            	-Name: my_project
        	            	-Target: default
        	            	-Workspace:
        	            	-  User: [USERNAME]
        	            	-  Path: /Workspace/Users/[USERNAME]/.bundle/my_project/default
        	            	-Resources:
        	            	-  Jobs:
        	            	-    my_job:
        	            	-      Name: My Job
        	            	-      URL:  (not deployed)
        	            	+Exit code: 1
        	            	 
        	Test:       	TestAccept/bundle/python/venv-path-subdir/DMS=/PYDAB_VERSION=current
        	Messages:   	bundle/python/venv-path-subdir/output.txt vs /tmp/TestAcceptbundlepythonvenv-path-subdirDMS=PYDAB_VERSION=cur1911474501/002/output.txt
    acceptance_test.go:1192: Test produced unexpected files:
        .venv/.gitignore
        .venv/.lock
        .venv/CACHEDIR.TAG
        .venv/bin/activate
        .venv/bin/activate.bat
        .venv/bin/activate.csh
        .venv/bin/activate.fish
        .venv/bin/activate.nu
        .venv/bin/activate.ps1
        .venv/bin/activate_this.py
        .venv/bin/deactivate.bat
        .venv/bin/pydoc.bat
        .venv/bin/python
        .venv/bin/python3
        .venv/bin/python3.10
        .venv/lib/python3.10/site-packages/_virtualenv.pth
        .venv/lib/python3.10/site-packages/_virtualenv.py
        .venv/lib/python3.10/site-packages/databricks/__init__.py
        .venv/lib/python3.10/site-packages/databricks/bundles/.gitattributes
        .venv/lib/python3.10/site-packages/databricks/bundles/__init__.py
        .venv/lib/python3.10/site-packages/databricks/bundles/_bitmap/__init__.py
        .venv/lib/python3.10/site-packages/databricks/bundles/_bitmap/__main__.py
        .venv/lib/python3.10/site-packages/databricks/bundles/_bitmap/schema.deflate
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/__init__.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/aggregation.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/alert.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/alert_evaluation_state.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/alert_statement_parameter.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/alert_v2_evaluation.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/alert_v2_notification.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/alert_v2_operand.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/alert_v2_operand_column.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/alert_v2_operand_value.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/alert_v2_run_as.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/alert_v2_subscription.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/comparison_operator.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/cron_schedule.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/custom_template_format.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/depends_on.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/lifecycle.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/permission_level.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/schedule_pause_status.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/__init__.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_config.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_env_var.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_permission_level.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_app.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_app_app_permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_database.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_database_database_permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_experiment.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_experiment_experiment_permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_genie_space.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_genie_space_genie_space_permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_job.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_job_job_permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_postgres.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_postgres_postgres_permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_secret.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_secret_secret_permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_serving_endpoint.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_serving_endpoint_serving_endpoint_permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_sql_warehouse.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_sql_warehouse_sql_warehouse_permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_uc_securable.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_uc_securable_uc_securable_permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_uc_securable_uc_securable_type.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/compute_size.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/depends_on.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/git_repository.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/git_source.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/lifecycle_with_started.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/telemetry_export_destination.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/unity_catalog.py
        .venv/lib/python3.10/site-packages/databricks/bundles/build.py
        .venv/lib/python3.10/site-packages/databricks/bundles/catalogs/__init__.py
        .venv/lib/python3.10/site-packages/databricks/bundles/catalogs/_models/azure_encryption_settings.py
        .venv/lib/python3.10/site-packages/databricks/bundles/catalogs/_models/catalog.py
        .venv/lib/python3.10/site-packages/databricks/bundles/catalogs/_models/catalog_isolation_mode.py
        .venv/lib/python3.10/site-packages/databricks/bundles/catalogs/_models/depends_on.py
        .venv/lib/python3.10/site-packages/databricks/bundles/catalogs/_models/encryption_settings.py
        .venv/lib/python3.10/site-packages/databricks/bundles/catalogs/_models/lifecycle.py
        .venv/lib/python3.10/site-packages/databricks/bundles/catalogs/_models/privilege.py
        .venv/lib/python3.10/site-packages/databricks/bundles/catalogs/_models/privilege_assignment.py
        .venv/lib/python3.10/site-packages/databricks/bundles/cluster_policies/__init__.py
        .venv/lib/python3.10/site-packages/databricks/bundles/cluster_policies/_models/cluster_policy.py
        .venv/lib/python3.10/site-packages/databricks/bundles/cluster_policies/_models/cluster_policy_permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/cluster_policies/_models/cluster_policy_permission_level.py
        .venv/lib/python3.10/site-packages/databricks/bundles/cluster_policies/_models/depends_on.py
        .venv/lib/python3.10/site-packages/databricks/bundles/cluster_policies/_models/library.py
        .venv/lib/python3.10/site-packages/databricks/bundles/cluster_policies/_models/lifecycle.py
        .venv/lib/python3.10/site-packages/databricks/bundles/cluster_policies/_models/maven_library.py
        .venv/lib/python3.10/site-packages/databricks/bundles/cluster_policies/_models/python_py_pi_library.py
        .venv/lib/python3.10/site-packages/databricks/bundles/cluster_policies/_models/r_cran_library.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/__init__.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/adlsgen2_info.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/auto_scale.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/aws_attributes.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/aws_availability.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/azure_attributes.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/azure_availability.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/clients_types.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/cluster.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/cluster_log_conf.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/cluster_permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/cluster_permission_level.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/confidential_compute_type.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/data_security_mode.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/dbfs_storage_info.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/dependency_mode.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/depends_on.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/docker_basic_auth.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/docker_image.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/ebs_volume_type.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/gcp_attributes.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/gcp_availability.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/gcs_storage_info.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/init_script_info.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/kind.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/library.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/lifecycle_with_started.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/local_file_info.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/log_analytics_info.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/maven_library.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/node_type_flexibility.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/python_py_pi_library.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/r_cran_library.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/runtime_engine.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/s3_storage_info.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/volumes_storage_info.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/workload_type.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/workspace_storage_info.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/__init__.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_bundle.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_diagnostics.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/__init__.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/alerts.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/apps.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/catalogs.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/cluster_policies.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/clusters.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/dashboards.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/data_quality_monitors.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/database_catalogs.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/database_instances.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/experiments.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/external_locations.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/feature_specs.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/features.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/genie_spaces.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/instance_pools.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/job_runs.py
... (677 more lines truncated, raise DATABRICKS_CLI_TEST_MAX_LOG to see more)

latest (v1.28.0):

acceptance_test.go:1402: 
        	Error Trace:	/home/runner/work/cli/cli/libs/testdiff/testdiff.go:22
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:1402
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:1143
        	            				/home/runner/work/cli/cli/acceptance/acceptance_test.go:704
        	Error:      	Not equal: 
        	            	expected: "\n=== from the bundle root\n\n>>> [CLI] bundle summary\nName: my_project\nTarget: default\nWorkspace:\n  User: [USERNAME]\n  Path: /Workspace/Users/[USERNAME]/.bundle/my_project/default\nResources:\n  Jobs:\n    my_job:\n      Name: My Job\n      URL:  (not deployed)\n\n=== from a subdirectory\n\n>>> withdir src [CLI] bundle summary\nName: my_project\nTarget: default\nWorkspace:\n  User: [USERNAME]\n  Path: /Workspace/Users/[USERNAME]/.bundle/my_project/default\nResources:\n  Jobs:\n    my_job:\n      Name: My Job\n      URL:  (not deployed)\n\n=== from a subdirectory with a relative DATABRICKS_BUNDLE_ROOT\n\n>>> withdir src [CLI] bundle summary\nName: my_project\nTarget: default\nWorkspace:\n  User: [USERNAME]\n  Path: /Workspace/Users/[USERNAME]/.bundle/my_project/default\nResources:\n  Jobs:\n    my_job:\n      Name: My Job\n      URL:  (not deployed)\n"
        	            	actual  : "\n=== from the bundle root\n\n>>> [CLI] bundle summary\nName: my_project\nTarget: default\nWorkspace:\n  User: [USERNAME]\n  Path: /Workspace/Users/[USERNAME]/.bundle/my_project/default\nResources:\n  Jobs:\n    my_job:\n      Name: My Job\n      URL:  (not deployed)\n\n=== from a subdirectory\n\n>>> withdir src [CLI] bundle summary\nError: failed to get Python interpreter path: can't find \".venv/bin/python3\", check if virtualenv is created\n\n\nExit code: 1\n"
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -18,26 +18,6 @@
        	            	 >>> withdir src [CLI] bundle summary
        	            	-Name: my_project
        	            	-Target: default
        	            	-Workspace:
        	            	-  User: [USERNAME]
        	            	-  Path: /Workspace/Users/[USERNAME]/.bundle/my_project/default
        	            	-Resources:
        	            	-  Jobs:
        	            	-    my_job:
        	            	-      Name: My Job
        	            	-      URL:  (not deployed)
        	            	+Error: failed to get Python interpreter path: can't find ".venv/bin/python3", check if virtualenv is created
        	            	 
        	            	-=== from a subdirectory with a relative DATABRICKS_BUNDLE_ROOT
        	            	 
        	            	->>> withdir src [CLI] bundle summary
        	            	-Name: my_project
        	            	-Target: default
        	            	-Workspace:
        	            	-  User: [USERNAME]
        	            	-  Path: /Workspace/Users/[USERNAME]/.bundle/my_project/default
        	            	-Resources:
        	            	-  Jobs:
        	            	-    my_job:
        	            	-      Name: My Job
        	            	-      URL:  (not deployed)
        	            	+Exit code: 1
        	            	 
        	Test:       	TestAccept/bundle/python/venv-path-subdir/DMS=/PYDAB_VERSION=current
        	Messages:   	bundle/python/venv-path-subdir/output.txt vs /tmp/TestAcceptbundlepythonvenv-path-subdirDMS=PYDAB_VERSION=cur1041164133/002/output.txt
    acceptance_test.go:1192: Test produced unexpected files:
        .venv/.gitignore
        .venv/.lock
        .venv/CACHEDIR.TAG
        .venv/bin/activate
        .venv/bin/activate.bat
        .venv/bin/activate.csh
        .venv/bin/activate.fish
        .venv/bin/activate.nu
        .venv/bin/activate.ps1
        .venv/bin/activate_this.py
        .venv/bin/deactivate.bat
        .venv/bin/pydoc.bat
        .venv/bin/python
        .venv/bin/python3
        .venv/bin/python3.10
        .venv/lib/python3.10/site-packages/_virtualenv.pth
        .venv/lib/python3.10/site-packages/_virtualenv.py
        .venv/lib/python3.10/site-packages/databricks/__init__.py
        .venv/lib/python3.10/site-packages/databricks/bundles/.gitattributes
        .venv/lib/python3.10/site-packages/databricks/bundles/__init__.py
        .venv/lib/python3.10/site-packages/databricks/bundles/_bitmap/__init__.py
        .venv/lib/python3.10/site-packages/databricks/bundles/_bitmap/__main__.py
        .venv/lib/python3.10/site-packages/databricks/bundles/_bitmap/schema.deflate
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/__init__.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/aggregation.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/alert.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/alert_evaluation_state.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/alert_statement_parameter.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/alert_v2_evaluation.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/alert_v2_notification.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/alert_v2_operand.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/alert_v2_operand_column.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/alert_v2_operand_value.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/alert_v2_run_as.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/alert_v2_subscription.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/comparison_operator.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/cron_schedule.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/custom_template_format.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/depends_on.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/lifecycle.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/permission_level.py
        .venv/lib/python3.10/site-packages/databricks/bundles/alerts/_models/schedule_pause_status.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/__init__.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_config.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_env_var.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_permission_level.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_app.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_app_app_permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_database.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_database_database_permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_experiment.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_experiment_experiment_permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_genie_space.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_genie_space_genie_space_permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_job.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_job_job_permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_postgres.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_postgres_postgres_permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_secret.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_secret_secret_permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_serving_endpoint.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_serving_endpoint_serving_endpoint_permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_sql_warehouse.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_sql_warehouse_sql_warehouse_permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_uc_securable.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_uc_securable_uc_securable_permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/app_resource_uc_securable_uc_securable_type.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/compute_size.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/depends_on.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/git_repository.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/git_source.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/lifecycle_with_started.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/telemetry_export_destination.py
        .venv/lib/python3.10/site-packages/databricks/bundles/apps/_models/unity_catalog.py
        .venv/lib/python3.10/site-packages/databricks/bundles/build.py
        .venv/lib/python3.10/site-packages/databricks/bundles/catalogs/__init__.py
        .venv/lib/python3.10/site-packages/databricks/bundles/catalogs/_models/azure_encryption_settings.py
        .venv/lib/python3.10/site-packages/databricks/bundles/catalogs/_models/catalog.py
        .venv/lib/python3.10/site-packages/databricks/bundles/catalogs/_models/catalog_isolation_mode.py
        .venv/lib/python3.10/site-packages/databricks/bundles/catalogs/_models/depends_on.py
        .venv/lib/python3.10/site-packages/databricks/bundles/catalogs/_models/encryption_settings.py
        .venv/lib/python3.10/site-packages/databricks/bundles/catalogs/_models/lifecycle.py
        .venv/lib/python3.10/site-packages/databricks/bundles/catalogs/_models/privilege.py
        .venv/lib/python3.10/site-packages/databricks/bundles/catalogs/_models/privilege_assignment.py
        .venv/lib/python3.10/site-packages/databricks/bundles/cluster_policies/__init__.py
        .venv/lib/python3.10/site-packages/databricks/bundles/cluster_policies/_models/cluster_policy.py
        .venv/lib/python3.10/site-packages/databricks/bundles/cluster_policies/_models/cluster_policy_permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/cluster_policies/_models/cluster_policy_permission_level.py
        .venv/lib/python3.10/site-packages/databricks/bundles/cluster_policies/_models/depends_on.py
        .venv/lib/python3.10/site-packages/databricks/bundles/cluster_policies/_models/library.py
        .venv/lib/python3.10/site-packages/databricks/bundles/cluster_policies/_models/lifecycle.py
        .venv/lib/python3.10/site-packages/databricks/bundles/cluster_policies/_models/maven_library.py
        .venv/lib/python3.10/site-packages/databricks/bundles/cluster_policies/_models/python_py_pi_library.py
        .venv/lib/python3.10/site-packages/databricks/bundles/cluster_policies/_models/r_cran_library.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/__init__.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/adlsgen2_info.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/auto_scale.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/aws_attributes.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/aws_availability.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/azure_attributes.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/azure_availability.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/clients_types.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/cluster.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/cluster_log_conf.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/cluster_permission.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/cluster_permission_level.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/confidential_compute_type.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/data_security_mode.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/dbfs_storage_info.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/dependency_mode.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/depends_on.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/docker_basic_auth.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/docker_image.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/ebs_volume_type.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/gcp_attributes.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/gcp_availability.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/gcs_storage_info.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/init_script_info.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/kind.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/library.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/lifecycle_with_started.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/local_file_info.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/log_analytics_info.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/maven_library.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/node_type_flexibility.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/python_py_pi_library.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/r_cran_library.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/runtime_engine.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/s3_storage_info.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/volumes_storage_info.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/workload_type.py
        .venv/lib/python3.10/site-packages/databricks/bundles/clusters/_models/workspace_storage_info.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/__init__.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_bundle.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_diagnostics.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/__init__.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/alerts.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/apps.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/catalogs.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/cluster_policies.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/clusters.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/dashboards.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/data_quality_monitors.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/database_catalogs.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/database_instances.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/experiments.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/external_locations.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/feature_specs.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/features.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/genie_spaces.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/instance_pools.py
        .venv/lib/python3.10/site-packages/databricks/bundles/core/_generated/job_runs.py
... (678 more lines truncated, raise DATABRICKS_CLI_TEST_MAX_LOG to see more)

1 more failure details omitted, see the full report in the run.

@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Integration test report

Commit: 75ed012

Run: 46448437301

Env 💚​RECOVERED ✅​pass 🙈​skip Time
💚​ aws linux-2core-8gb 1 88 7 1:39
💚​ aws-windows-latest-4core-16gb 1 88 7 3:10
💚​ azure linux-2core-8gb 1 88 7 1:44
💚​ azure-windows-latest-4core-16gb 1 88 7 3:19
💚​ gcp linux-2core-8gb 1 88 7 2:02
💚​ gcp-windows-latest-4core-16gb 1 88 7 3:49
Test Name aws linux-2core-8gb aws-windows-latest-4core-16gb azure linux-2core-8gb azure-windows-latest-4core-16gb gcp linux-2core-8gb gcp-windows-latest-4core-16gb
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
Top 3 slowest tests (at least 2 minutes):
duration env testname
3:47 gcp-windows-latest-4core-16gb TestAccept
3:17 azure-windows-latest-4core-16gb TestAccept
3:08 aws-windows-latest-4core-16gb TestAccept

@denik
denik force-pushed the denik/fix-python-venv-subdir branch from 66aaff2 to 7fdc45f Compare November 30, 2026 00:59
@denik
denik marked this pull request as ready for review November 30, 2026 01:20
@denik
denik requested review from a team as code owners November 30, 2026 01:20

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated review at 7fdc45f. Each finding was verified against the code.

No blocking issues found. 2 non-blocking comment(s) and 1 question(s) below.

This PR resolves a relative python.venv_path against the bundle root and passes an absolute interpreter path to the subprocess, so bundle commands work from a subdirectory, including with a relative DATABRICKS_BUNDLE_ROOT. The fix works for the template default .venv, and the new acceptance and unit cases cover it. I have one open question: should relative paths be resolved against the bundle root or against the file that defines them? I also have two small doc fixes.

Questions

  1. Should a relative venv_path resolve against the directory of the file that defines it, as RewriteSyncPaths (bundle/config/mutator/rewrite_sync_paths.go) and translate_paths do through the value's dyn location, rather than against the bundle root? As written, venv_path: .venv in sub/python.yml resolves to <root>/.venv, while sync.paths in the same file resolves under <root>/sub/. Switching later would be a second behavior change. Options: resolve via the dyn location now, or keep bundle-root-relative and document it. (non-blocking)

Comments outside the changed lines

  • [nice to have] bundle/config/experimental.go: This PR decides that a relative venv_path is resolved against the bundle root, but the VEnvPath doc comment still only says "path to the virtual environment". Users who read the schema won't learn this, and they can't tell why venv_path: .venv in resources/python.yml points at <root>/.venv. Can the comment say that relative paths resolve against the bundle root, with bundle/schema/jsonschema.json regenerated?

@denik
denik force-pushed the denik/fix-python-venv-subdir branch from 7fdc45f to de1c5a8 Compare November 30, 2026 02:17
@denik

denik commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Thanks for the review. Answers to the review body:

Bundle root vs. the defining file. I kept bundle-root-relative and documented it (de1c5a8), rather than resolving through the dyn location:

  • venv_path is one bundle-wide setting for the Python subprocess, not a resource path. The subprocess already runs with the bundle root as its working directory, and python -m puts it on sys.path, so the python.resources / python.mutators module paths are resolved from the bundle root as well. A file-relative venv_path would be the only file-relative piece of that section.
  • The template and docs set it in the root databricks.yml, where both rules give the same path.
  • Before this PR a relative value was resolved against the current directory, so no working config depended on file-relative behavior. Making it bundle-root-relative is the smallest change that fixes running from a subdirectory. If you prefer file-relative, I can switch to the dyn location in this PR before it merges, so there is only one behavior change.

Docs. Done in de1c5a8: the VEnvPath doc comment and annotations.yml now say "A relative path is relative to the bundle root.", and bundle/schema/jsonschema.json is regenerated.

AI agent (opus5.5, isaac_claude)

@denik

denik commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Heads-up: #7975 removed the errcode acceptance helper, so the errcode calls this PR adds will fail with errcode: command not found once it's tested against current main.

To fix: use musterr CMD for a command that must fail, and run commands expected to succeed without a wrapper. When the exact exit code is what the test checks, print it after musterr with printf '\nExit code: %s\n' "$MUSTERR_EXIT_CODE". cmd || true is only for best-effort cleanup. Details are in .agents/rules/testing.md.

@denik
denik requested a review from andrewnester November 30, 2026 12:57
@denik

denik commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Thanks, fixed in 7b6ce93: a merge of the test branch (no force-push). With the fix all three bundle summary calls succeed, so they all run without a wrapper; the golden is unchanged. It passes on this branch and merged with current main, and it still fails at the src/ run when the fix is reverted.

AI agent (opus5.5, isaac_claude)

Base automatically changed from denik/acc-python-venv-subdir to main November 30, 2026 14:28
@denik denik closed this in #8181 Nov 30, 2026
@denik denik reopened this Nov 30, 2026
@github-actions github-actions Bot added DABs DABs related issues PyDABs labels Nov 30, 2026
A relative venv_path was resolved against the current directory, so every
bundle command run from a subdirectory of a bundle with the pydabs template
default venv_path: .venv failed with can't find ".venv/bin/python3".

Join a relative venv_path with the bundle root and return an absolute
interpreter path (the subprocess runs in the bundle root, so a path relative
to the current directory fails there, e.g. with DATABRICKS_BUNDLE_ROOT=..).
Windows drive-relative (C:venv) and drive-rooted (\venv) values keep their
meaning. Document the rule on venv_path and regenerate the schema.

Co-authored-by: Isaac <no-reply@databricks.com>

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated review at 7b6ce93. Each finding was verified against the code.

No blocking issues found. 2 non-blocking comment(s) and 1 question(s) below.

This PR resolves a relative python.venv_path against the bundle root and passes an absolute interpreter path to the Python subprocess, so bundle commands now work from a subdirectory. The fix works for the template default set in the root databricks.yml. Two test-side gaps remain: the unit stub never checks the interpreter it is given, and one acceptance replacement never matches anything. Also, the "can't find" error now shows the path joined with the bundle root, so the description's claim that the error text is unchanged only holds in the unit test, where the bundle root is empty.

Questions

  1. Other relative paths in bundle config resolve against the directory of the file that defines them (rewrite_sync_paths.go uses filepath.Dir(v.Location().File), and translate_paths does the same). This PR resolves venv_path against the bundle root instead, so venv_path: .venv in an included sub/python.yml points to <root>/.venv, and the schema description now documents that rule publicly. Should getOpts use the directory of venv_path's dyn.Location instead? For the template default in the root databricks.yml that gives the same result. Or is root-relative deliberate, to match the subprocess working directory, in which case is it worth committing to in the schema? (non-blocking)

@denik
denik force-pushed the denik/fix-python-venv-subdir branch from 7b6ce93 to cbba414 Compare November 30, 2026 14:53
@denik
denik requested a review from andrewnester November 30, 2026 14:54
@denik

denik commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Rebased onto main after #8181 merged: now one fix-only commit, cbba414. Its diff is the same as the previous head 7b6ce93 minus the test-PR commits; the test it updates is now on main. Unit tests, TestAccept/bundle/python and bundle/templates/pydabs pass locally, and the venv-path-subdir test still fails at the src/ run without the fix.

AI agent (opus5.5, isaac_claude)

…unused Repl

withProcessStub now compares the command line with the expected arguments,
and withFakeVEnv returns the absolute interpreter path, so the unit tests pin
both the bundle-root join and the absolute path. The venv-path-subdir output
no longer has an interpreter path, so its Repl never matched.

Co-authored-by: Isaac <no-reply@databricks.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants