Skip to content

feat(dev): select env mode and job layer in datahub-dev Docker mode - #21823

Open
devashish2203 wants to merge 6 commits into
pfp-8940-env-layer-slotsfrom
pfp-8944-dev-env-mode
Open

devashish2203 wants to merge 6 commits into
pfp-8940-env-layer-slotsfrom
pfp-8944-dev-env-mode

Conversation

@devashish2203

@devashish2203 devashish2203 commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #21821.

datahub-dev Docker mode now selects the env mode and job layer that the optional compose slots read.

  • _dev_env() exports DATAHUB_ENV_MODE (ci when CI is set, else local), using the same rule as the Docker-free launcher.
  • start --job smoke-test|playwright and --mode local|ci now work in Docker mode. They are recorded per worktree, and _dev_env() exports DATAHUB_ENV_JOB_DIR as an absolute path, so rebuild, env restart, reset and nuke reuse them. When no job is recorded, _dev_env() drops a DATAHUB_ENV_JOB_DIR inherited from the shell, so it cannot select a job layer by accident. The job folders and mode names come from the Docker-free launcher.
  • A remote start forwards --job and --mode to the remote runner.
  • env list in Docker mode prints layers: the env files that exist and that compose reads for GMS, lowest precedence first.
  • Docs in scripts/dev/README.md and scripts/dev/AGENTS.md.

A plain start renders the same config as before: docker compose config is byte-identical with DATAHUB_ENV_MODE unset and set to local.

Job values that compose environment: already sets do not take effect until they move to layer files, because environment: beats env_file.

Verification

  • ./gradlew :scripts:dev:test: 191 passed, 1 skipped.
  • A scratch job folder with an extra key in gms.env renders into the GMS service environment.

Checklist

  • Conforms to the Contributing Guideline and PR title format
  • Tests added
  • Docs updated
  • No breaking changes

🤖 Generated with Claude Code


Summary by cubic

datahub-dev Docker mode now selects the env mode and job layer for the optional compose slots, matching the Docker-free launcher.

  • start --job smoke-test|playwright and --mode local|ci now work in Docker mode and on remote start, recorded per worktree so rebuild, env restart, reset and nuke reuse them.
  • _dev_env() exports DATAHUB_ENV_MODE (defaults to ci when CI is set, else local; an explicit --mode overrides it) and DATAHUB_ENV_JOB_DIR as 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 as required: false and would skip a typo silently.
  • --job/--mode choices come from the Docker-free launcher so the two modes stay in sync.
  • env list prints layers: the env files compose reads for GMS, lowest precedence first, including the extension folder when DATAHUB_ENV_EXTENSION_DIR is set.
  • A plain start keeps rendering the same config as before.
  • Job values already set by compose environment: keys do not apply until they move to layer files, because environment: overrides env_file.

Written for commit c073d74. Summary will update on new commits.

View guided diff Turn on auto-fix

_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>
@cursor

cursor Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

PR Summary

Overview
Docker-mode datahub-dev now picks the same env job and CI/local layers as the Docker-free launcher, so compose stacks can run with smoke-test or playwright overlays without duplicating launcher logic.

start --job and --mode apply in Docker and on remote start; choices come from gms-lite-stack.py via a new _launcher() import. Selections are stored per worktree in docker_options so later rebuild, env restart, reset, and nuke reuse them.

_dev_env() now sets DATAHUB_ENV_MODE (CI when CI is set, else local, with explicit --mode overriding) and DATAHUB_ENV_JOB_DIR as an absolute path when a job is recorded; it clears a stale inherited job dir when none is set and fails fast on bad extension or job folders. env list adds a layers field (existing GMS env files, lowest precedence first) for Docker instances.

Docs in scripts/dev/README.md and AGENTS.md were updated; unit tests cover env export, layers, registry recording, and remote forwarding.

Reviewed by Cursor Bugbot for commit c073d74. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor 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.

Stale Bugbot comment from a previous run.

Comment thread scripts/dev/datahub_dev.py Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Comment thread scripts/dev/README.md Resolved
Comment thread scripts/dev/datahub_dev.py Resolved
Comment thread scripts/dev/datahub_dev.py Resolved
Comment thread scripts/dev/datahub_dev.py Resolved
Comment thread scripts/dev/tests/test_datahub_dev.py Resolved
Comment thread scripts/dev/datahub_dev.py Resolved
Comment thread scripts/dev/AGENTS.md Resolved
Comment thread scripts/dev/README.md Resolved
devashish2203 and others added 2 commits December 3, 2026 15:02
…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>

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ 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.")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c073d74. Configure here.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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>

This branch was successfully deployed

1 active deployment
Preview — c073d74b Deployed Dec 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant