Skip to content

fix(docker): set sampleworks workspace home#253

Merged
xraymemory merged 5 commits into
mainfrom
fix/sampleworks-home-env
Jun 3, 2026
Merged

fix(docker): set sampleworks workspace home#253
xraymemory merged 5 commits into
mainfrom
fix/sampleworks-home-env

Conversation

@xraymemory

@xraymemory xraymemory commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

Summary\n- set HOME/XDG/SHELL in the public Sampleworks runtime image\n- create /home/dev state directories and make /home/dev the image WORKDIR\n- explicitly keep the Astera overlay WORKDIR aligned with ACTL workspace images\n\n## Testing\n- Not run locally: Docker image build requires checkpoint/image inputs not available in this environment.\n\n## Acceptance notes\n- After publish, verify actl pod up --image sampleworks reports pwd=/home/dev and HOME=/home/dev.\n- Once the image ships, the temporary homePath: /home/dev catalog override can be dropped from asteractl.

Summary by CodeRabbit

  • Chores

    • Updated container runtime environment to establish a dedicated user workspace, set standardized shell and XDG home paths, and ensure the workspace is used as the default working directory; startup shell initialization now applies to both root and the dev user.
  • Tests

    • Improved test reliability by making environment handling deterministic across runs, expanding environment-variable cleanup, and isolating runtime script references to a temporary workspace.

Copilot AI review requested due to automatic review settings June 2, 2026 15:37
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cb859e6b-832c-41bf-94ea-c5e9d2b7eb2f

📥 Commits

Reviewing files that changed from the base of the PR and between 08bad74 and ef36b68.

📒 Files selected for processing (1)
  • Dockerfile

📝 Walkthrough

Walkthrough

Adds HOME and XDG environment variables and sets WORKDIR to /home/dev in runtime images (including Dockerfile.astera), creates XDG/workspace directories, appends the interactive auto-cd snippet to both root and dev bashrcs, and updates tests to use a tmp_path-based runner script for deterministic workspace detection.

Changes

Container Workspace and Test Environment Setup

Layer / File(s) Summary
Container workspace environment setup
Dockerfile, Dockerfile.astera
Public runtime stage ENV adds HOME=/home/dev, XDG_CONFIG_HOME, XDG_CACHE_HOME, XDG_DATA_HOME, and SHELL=/bin/bash. Creates XDG and /home/dev/workspace directories and sets WORKDIR /home/dev. The scientist-workflow auto-cd snippet is appended into both /root/.bashrc and /home/dev/.bashrc. Dockerfile.astera adds matching WORKDIR /home/dev.
Test fixture determinism alignment
tests/runs/conftest.py
force_pixi_argv accepts tmp_path, sets sampleworks.runs.runner.WORKSPACE_GRID_SEARCH_SCRIPT to a non-existent temp path for deterministic missing-workspace behavior, expands removal of SAMPLEWORKS_* env vars (including several named flags and any *_PYTHON entries), and still sets SAMPLEWORKS_FORCE_PIXI="1".

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested reviewers

  • manzuoni-astera
  • marcuscollins

Poem

🐰 In a burrow of code where the devs like to delve,
/home/dev blooms tidy with XDG on the shelf,
Tests hop through temp paths, no surprises to find,
Deterministic fixtures, a calm in the mind. 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(docker): set sampleworks workspace home' directly corresponds to the main changes: setting HOME and XDG environment variables, creating workspace directories, and changing WORKDIR to /home/dev in the Dockerfile.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/sampleworks-home-env

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI 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.

Pull request overview

Updates the public Sampleworks runtime image (and the Astera overlay) to treat /home/dev as the runtime “home/workspace root”, aligning container defaults (HOME/XDG/workdir) with ACTL workspace pod expectations.

Changes:

  • Set HOME, XDG base dirs, and SHELL in the public runtime image and create the corresponding state directories under /home/dev.
  • Change the public runtime image WORKDIR to /home/dev.
  • Explicitly set WORKDIR /home/dev in the Astera overlay to stay aligned with ACTL workspace images.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
Dockerfile Sets HOME/XDG/SHELL, creates /home/dev state dirs, and changes runtime WORKDIR to /home/dev.
Dockerfile.astera Sets overlay WORKDIR to /home/dev to match the workspace home convention.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Dockerfile
XDG_DATA_HOME=/home/dev/.local/share \
SHELL=/bin/bash

RUN mkdir -p /home/dev/.config /home/dev/.cache /home/dev/.local/share /home/dev/workspace

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.

Addressed in 77ea7c7 by installing the ACTL auto-cd snippet into both /root/.bashrc and /home/dev/.bashrc. Keeping /root/.bashrc preserves the prior root-user behavior, and /home/dev/.bashrc matches the new HOME=/home/dev runtime environment.

@marcuscollins marcuscollins left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this is fine but please take a look at the Copilot comment about whether the .bashrc file also needs to be moved to /home/dev/. I honestly don't know the sequence of steps that leads to /root/.bashrc being executed, and whether/how changing HOME would alter that.

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/runs/conftest.py (1)

13-32: ⚡ Quick win

Document the fixture's side effects in a NumPy-style docstring.

This fixture now mutates both process environment variables and runner.WORKSPACE_GRID_SEARCH_SCRIPT, but the docstring does not spell that out and is not in the repo's required NumPy style.

Suggested docstring shape
 def force_pixi_argv(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
-    """Keep argv assertions deterministic across dev and ACTL image environments."""
+    """Keep argv assertions deterministic across dev and ACTL image environments.
+
+    Parameters
+    ----------
+    monkeypatch : pytest.MonkeyPatch
+        Isolates environment and module state for each test.
+    tmp_path : Path
+        Temporary directory used to point workspace script discovery at a
+        guaranteed-missing path.
+
+    Notes
+    -----
+    Deletes several ``SAMPLEWORKS_*`` environment variables, sets
+    ``SAMPLEWORKS_FORCE_PIXI=1``, and monkeypatches
+    ``sampleworks.runs.runner.WORKSPACE_GRID_SEARCH_SCRIPT``.
+    """

As per coding guidelines, "Always include NumPy-style docstrings for every function and class." and "Always annotate complex array shapes and note side effects."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/runs/conftest.py` around lines 13 - 32, Update the docstring for the
fixture force_pixi_argv to a NumPy-style docstring that clearly documents its
behavior and side effects: describe that it mutates process environment
variables (clears SAMPLEWORKS_GRID_SEARCH_SCRIPT, SAMPLEWORKS_PIXI_PROJECT_DIR,
unsets vars starting with "SAMPLEWORKS_" and ending with "_PYTHON", and
removes/sets RUNTIME_PIXI, SAMPLEWORKS_ALLOW_RUNTIME_PIXI,
SAMPLEWORKS_REQUIRE_PREBUILT_PIXI, SAMPLEWORKS_SKIP_ENV_PREPARE, and sets
SAMPLEWORKS_FORCE_PIXI="1") and that it overwrites
runner.WORKSPACE_GRID_SEARCH_SCRIPT to point at a tmp_path missing-workspace
run_grid_search.py; include parameter descriptions for monkeypatch and tmp_path
and a brief “Side effects” section listing the mutated environment variables and
the modified runner.WORKSPACE_GRID_SEARCH_SCRIPT.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Dockerfile`:
- Around line 138-146: The interactive-shell auto-cd hook was written to root's
bashrc before HOME was changed to /home/dev, so after setting HOME the hook is
no longer sourced; modify the earlier step that installs the hook to
write/append it to $HOME/.bashrc (or use the HOME env when creating the file)
and ensure ownership/permissions match the dev user (chown $HOME and set
readable). In practice, update the command that previously targeted root's
.bashrc to target $HOME/.bashrc (or use the HOME variable) so the hook is
present for the new HOME and persists in both the public image and overlays.

---

Nitpick comments:
In `@tests/runs/conftest.py`:
- Around line 13-32: Update the docstring for the fixture force_pixi_argv to a
NumPy-style docstring that clearly documents its behavior and side effects:
describe that it mutates process environment variables (clears
SAMPLEWORKS_GRID_SEARCH_SCRIPT, SAMPLEWORKS_PIXI_PROJECT_DIR, unsets vars
starting with "SAMPLEWORKS_" and ending with "_PYTHON", and removes/sets
RUNTIME_PIXI, SAMPLEWORKS_ALLOW_RUNTIME_PIXI, SAMPLEWORKS_REQUIRE_PREBUILT_PIXI,
SAMPLEWORKS_SKIP_ENV_PREPARE, and sets SAMPLEWORKS_FORCE_PIXI="1") and that it
overwrites runner.WORKSPACE_GRID_SEARCH_SCRIPT to point at a tmp_path
missing-workspace run_grid_search.py; include parameter descriptions for
monkeypatch and tmp_path and a brief “Side effects” section listing the mutated
environment variables and the modified runner.WORKSPACE_GRID_SEARCH_SCRIPT.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 759929c6-8491-4c25-ac72-b807b62ea0fe

📥 Commits

Reviewing files that changed from the base of the PR and between f25844f and 08bad74.

📒 Files selected for processing (3)
  • Dockerfile
  • Dockerfile.astera
  • tests/runs/conftest.py

Comment thread Dockerfile
@xraymemory xraymemory merged commit 4052603 into main Jun 3, 2026
8 checks passed
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.

4 participants