Skip to content

Commit 3be2f7f

Browse files
committed
Always run pip/npm install in transform sandboxes
Previously installs were skipped when the sandbox already existed (node_modules present, or venv present without a Python version change). This caused stale sandboxes to silently miss updated dependencies. Now pip/npm install always runs; it is idempotent and fast when nothing has changed. Venv recreation is still gated on a Python version change.
1 parent cac9e2f commit 3be2f7f

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

ogc/bblocks/transform.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ def _ensure_transform_sandboxes(sandbox_dir: Path, bblock: BuildingBlock) -> dic
111111
"""Set up isolated per-transform sandboxes for python/node transforms.
112112
113113
Returns a dict mapping transform id → per-transform sandbox directory.
114-
Installs deps on first use; skips if the environment already exists.
114+
Always runs pip/npm install (idempotent); only recreates the venv when the
115+
Python version changes.
115116
"""
116117
sandboxes: dict[str, Path] = {}
117118

@@ -132,27 +133,25 @@ def _ensure_transform_sandboxes(sandbox_dir: Path, bblock: BuildingBlock) -> dic
132133
pip_deps = [pip_deps]
133134
if pip_deps:
134135
venv_dir = transform_sandbox / 'venv'
135-
if venv_needs_recreate(venv_dir):
136-
logger.info("Installing pip dependencies for transform '%s' in '%s': %s",
136+
with log_indent():
137+
ensure_venv(venv_dir)
138+
pip_bin = venv_dir / 'bin' / 'pip'
139+
logger.info("Ensuring pip dependencies for transform '%s' in '%s': %s",
137140
t_id, bblock.identifier, pip_deps)
138-
with log_indent():
139-
ensure_venv(venv_dir)
140-
pip_bin = venv_dir / 'bin' / 'pip'
141-
run_logged([str(pip_bin), 'install', '--disable-pip-version-check', *pip_deps],
142-
label='pip')
141+
run_logged([str(pip_bin), 'install', '--disable-pip-version-check', *pip_deps],
142+
label='pip')
143143

144144
elif t_type == 'node':
145145
npm_deps = deps.get('npm', [])
146146
if isinstance(npm_deps, str):
147147
npm_deps = [npm_deps]
148148
if npm_deps:
149149
node_dir = transform_sandbox / 'node'
150-
if not (node_dir / 'node_modules').exists():
151-
node_dir.mkdir(parents=True, exist_ok=True)
152-
logger.info("Installing npm dependencies for transform '%s' in '%s': %s",
153-
t_id, bblock.identifier, npm_deps)
154-
with log_indent():
155-
run_logged(['npm', 'install', '--prefix', str(node_dir), *npm_deps], label='npm')
150+
node_dir.mkdir(parents=True, exist_ok=True)
151+
logger.info("Ensuring npm dependencies for transform '%s' in '%s': %s",
152+
t_id, bblock.identifier, npm_deps)
153+
with log_indent():
154+
run_logged(['npm', 'install', '--prefix', str(node_dir), *npm_deps], label='npm')
156155

157156
return sandboxes
158157

0 commit comments

Comments
 (0)