Repository navigation
feat(dev): select env mode and job layer in datahub-dev Docker mode - #21823
devashish2203 wants to merge 6 commits into
Conversation
_dev_env() now exports DATAHUB_ENV_MODE (same rule as the Docker-free launcher) and, after start --job, DATAHUB_ENV_JOB_DIR as an absolute path. --job and --mode are recorded per worktree and reused by rebuild, env restart, reset and nuke. env list shows the env files compose reads, lowest precedence first. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
PR SummaryOverview
Docs in Reviewed by Cursor Bugbot for commit c073d74. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
…v layer handling Remote start now forwards --job and --mode. _dev_env() drops an inherited DATAHUB_ENV_JOB_DIR when no job is recorded. --job/--mode choices come from the launcher. env list layers include the extension folder when DATAHUB_ENV_EXTENSION_DIR is set. Docs note that compose environment: entries override env_file. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Compose lists these env folders as required: false, so a mistyped DATAHUB_ENV_EXTENSION_DIR or job folder was skipped without an error. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c073d74. Configure here.
| f"{extension_dir} does not exist. Fix or unset it." | ||
| ) | ||
| if job_dir is not None and not job_dir.is_dir(): | ||
| raise RuntimeError(f"Job env folder {job_dir} does not exist.") |
There was a problem hiding this comment.
Missing job folder bricks Docker commands
High Severity
_dev_env() raises when the recorded job folder is not a directory, but job layers are optional and e2e-test/ui/playwright/env does not exist. start --job playwright writes docker_options first, then every later _run call — including stop, nuke, rebuild, and reset — fails until the registry is edited by hand.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit c073d74. Configure here.
There was a problem hiding this comment.
2 issues found across 2 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="scripts/dev/tests/test_datahub_dev.py">
<violation number="1" location="scripts/dev/tests/test_datahub_dev.py:628">
P2: Custom agent: **Enforce Pragmatic Test Coverage**
`_dev_env()` now fails fast on both a missing extension dir and a missing job env folder, but only the extension case is tested. The new test registers a job via `_register_docker_instance({"job": ...})` with a `REPO_ROOT` whose `smoke-test/env` does not exist and asserts `pytest.raises(RuntimeError, match="Job env folder")`, so a regression in the job-dir guard would be caught.
Suggestion:
```python
def test_dev_env_rejects_missing_job_env_folder(tmp_path, monkeypatch):
monkeypatch.setattr(datahub_dev, "REPO_ROOT", tmp_path)
_register_docker_instance({"job": "smoke-test"})
with pytest.raises(RuntimeError, match="Job env folder"):
datahub_dev._dev_env()
```</violation>
</file>
<file name="scripts/dev/datahub_dev.py">
<violation number="1" location="scripts/dev/datahub_dev.py:1123">
P1: `start --job playwright` fails here because `e2e-test/ui/playwright/env` does not exist, but `cmd_start` has already saved `docker_options.job` to the registry. Every later `_run()` path (`stop`, `nuke`, `status`) re-reads that job and raises the same error, so teardown is blocked until a valid `--job` is started again. Validate the job folder before the registry write in `cmd_start`, or skip this check for teardown commands.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| f"DATAHUB_ENV_EXTENSION_DIR={os.environ['DATAHUB_ENV_EXTENSION_DIR']}: " | ||
| f"{extension_dir} does not exist. Fix or unset it." | ||
| ) | ||
| if job_dir is not None and not job_dir.is_dir(): |
There was a problem hiding this comment.
P1: start --job playwright fails here because e2e-test/ui/playwright/env does not exist, but cmd_start has already saved docker_options.job to the registry. Every later _run() path (stop, nuke, status) re-reads that job and raises the same error, so teardown is blocked until a valid --job is started again. Validate the job folder before the registry write in cmd_start, or skip this check for teardown commands.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At scripts/dev/datahub_dev.py, line 1123:
<comment>`start --job playwright` fails here because `e2e-test/ui/playwright/env` does not exist, but `cmd_start` has already saved `docker_options.job` to the registry. Every later `_run()` path (`stop`, `nuke`, `status`) re-reads that job and raises the same error, so teardown is blocked until a valid `--job` is started again. Validate the job folder before the registry write in `cmd_start`, or skip this check for teardown commands.</comment>
<file context>
@@ -1104,6 +1113,15 @@ def _dev_env() -> Dict[str, str]:
+ f"DATAHUB_ENV_EXTENSION_DIR={os.environ['DATAHUB_ENV_EXTENSION_DIR']}: "
+ f"{extension_dir} does not exist. Fix or unset it."
+ )
+ if job_dir is not None and not job_dir.is_dir():
+ raise RuntimeError(f"Job env folder {job_dir} does not exist.")
env["DATAHUB_ENV_MODE"] = mode
</file context>
| assert "DATAHUB_ENV_JOB_DIR" not in datahub_dev._dev_env() | ||
|
|
||
|
|
||
| def test_dev_env_rejects_missing_extension_dir(monkeypatch): |
There was a problem hiding this comment.
P2: Custom agent: Enforce Pragmatic Test Coverage
_dev_env() now fails fast on both a missing extension dir and a missing job env folder, but only the extension case is tested. The new test registers a job via _register_docker_instance({"job": ...}) with a REPO_ROOT whose smoke-test/env does not exist and asserts pytest.raises(RuntimeError, match="Job env folder"), so a regression in the job-dir guard would be caught.
Suggestion:
def test_dev_env_rejects_missing_job_env_folder(tmp_path, monkeypatch):
monkeypatch.setattr(datahub_dev, "REPO_ROOT", tmp_path)
_register_docker_instance({"job": "smoke-test"})
with pytest.raises(RuntimeError, match="Job env folder"):
datahub_dev._dev_env()Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At scripts/dev/tests/test_datahub_dev.py, line 628:
<comment>`_dev_env()` now fails fast on both a missing extension dir and a missing job env folder, but only the extension case is tested. The new test registers a job via `_register_docker_instance({"job": ...})` with a `REPO_ROOT` whose `smoke-test/env` does not exist and asserts `pytest.raises(RuntimeError, match="Job env folder")`, so a regression in the job-dir guard would be caught.
Suggestion:
```python
def test_dev_env_rejects_missing_job_env_folder(tmp_path, monkeypatch):
monkeypatch.setattr(datahub_dev, "REPO_ROOT", tmp_path)
_register_docker_instance({"job": "smoke-test"})
with pytest.raises(RuntimeError, match="Job env folder"):
datahub_dev._dev_env()
```</comment>
<file context>
@@ -625,6 +625,12 @@ def test_dev_env_drops_inherited_job_dir_without_recorded_job(monkeypatch):
assert "DATAHUB_ENV_JOB_DIR" not in datahub_dev._dev_env()
+def test_dev_env_rejects_missing_extension_dir(monkeypatch):
+ monkeypatch.setenv("DATAHUB_ENV_EXTENSION_DIR", "no-such-extension")
+ with pytest.raises(RuntimeError, match="DATAHUB_ENV_EXTENSION_DIR"):
</file context>


Stacked on #21821.
datahub-devDocker mode now selects the env mode and job layer that the optional compose slots read._dev_env()exportsDATAHUB_ENV_MODE(ciwhenCIis set, elselocal), using the same rule as the Docker-free launcher.start --job smoke-test|playwrightand--mode local|cinow work in Docker mode. They are recorded per worktree, and_dev_env()exportsDATAHUB_ENV_JOB_DIRas an absolute path, sorebuild,env restart,resetandnukereuse them. When no job is recorded,_dev_env()drops aDATAHUB_ENV_JOB_DIRinherited from the shell, so it cannot select a job layer by accident. The job folders and mode names come from the Docker-free launcher.startforwards--joband--modeto the remote runner.env listin Docker mode printslayers: the env files that exist and that compose reads for GMS, lowest precedence first.scripts/dev/README.mdandscripts/dev/AGENTS.md.A plain
startrenders the same config as before:docker compose configis byte-identical withDATAHUB_ENV_MODEunset and set tolocal.Job values that compose
environment:already sets do not take effect until they move to layer files, becauseenvironment:beatsenv_file.Verification
./gradlew :scripts:dev:test: 191 passed, 1 skipped.gms.envrenders into the GMS service environment.Checklist
🤖 Generated with Claude Code
Summary by cubic
datahub-devDocker mode now selects the env mode and job layer for the optional compose slots, matching the Docker-free launcher.start --job smoke-test|playwrightand--mode local|cinow work in Docker mode and on remote start, recorded per worktree sorebuild,env restart,resetandnukereuse them._dev_env()exportsDATAHUB_ENV_MODE(defaults tociwhenCIis set, elselocal; an explicit--modeoverrides it) andDATAHUB_ENV_JOB_DIRas an absolute path, dropping any stale inherited value when no job is recorded._dev_env()fails when the extension or job env folder does not exist, because compose lists them asrequired: falseand would skip a typo silently.--job/--modechoices come from the Docker-free launcher so the two modes stay in sync.env listprintslayers: the env files compose reads for GMS, lowest precedence first, including the extension folder whenDATAHUB_ENV_EXTENSION_DIRis set.startkeeps rendering the same config as before.environment:keys do not apply until they move to layer files, becauseenvironment:overridesenv_file.Written for commit c073d74. Summary will update on new commits.