From 49e0e61df70d6b50a0c7b959bc4725db107c4cbb Mon Sep 17 00:00:00 2001 From: aIbrahiim Date: Fri, 3 Apr 2026 12:26:32 +0200 Subject: [PATCH] Avoid cloning live dev venv for yaml expansion in CI --- sdks/python/apache_beam/yaml/yaml_provider.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sdks/python/apache_beam/yaml/yaml_provider.py b/sdks/python/apache_beam/yaml/yaml_provider.py index 5a3ccf6b0c2e..f1408b5b0d1c 100755 --- a/sdks/python/apache_beam/yaml/yaml_provider.py +++ b/sdks/python/apache_beam/yaml/yaml_provider.py @@ -1412,7 +1412,13 @@ def _create_venv_from_clone( @classmethod def _create_venv_to_clone(cls, base_python: str) -> str: - if '.dev' in beam_version: + # For '.dev', the default clone source is the venv that owns base_python. + # In CI that is often the active tox/sandbox tree; clonevirtualenv can + # race with ephemeral paths (tmp/, caches) under that tree. Use the + # scratch clonable venv in CI instead. Locally, keep cloning the dev venv + # for speed. + _ci = os.environ.get('CI', '').lower() in ('true', '1', 'yes') + if '.dev' in beam_version and not _ci: base_venv = os.path.dirname(os.path.dirname(base_python)) print('Cloning dev environment from', base_venv) return base_venv