[Docker] Accept the container profile before the command, and start from enter - #6961
[Docker] Accept the container profile before the command, and start from enter#6961hujc7 wants to merge 3 commits into
Conversation
Stepping a container through build, start, enter and stop repeats the profile every time, so the only word that changes sits in the middle of the line and the previous command cannot be reused by editing its tail. Accept '<profile> <command>' as well, and document that order. The command set comes from argparse's own subparser choices rather than a second hardcoded list, so adding a subcommand needs no change here. Every subcommand takes exactly one positional, the profile, which is what makes the swap unambiguous; a test pins that profile and command names stay disjoint. The original order keeps working. Also start the container from 'enter' when it is not already running. That path previously failed twice over: 'stop' deletes the .xauth file, so the refresh in 'enter' errored before the 'container is not running' check was even reached. Both are resolved by running the same setup 'start' does.
Greptile SummaryThe PR adds support for profile-first Docker CLI invocations while preserving command-first compatibility, and makes
Confidence Score: 5/5The PR appears safe to merge; the new argument order and enter-from-stopped lifecycle preserve the established command behavior. The argument rewrite is constrained to an unambiguous initial profile-command pair, while the new enter path performs the same X11 configuration and startup steps as the existing start path before refreshing credentials and entering. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Parse CLI arguments] --> B{Profile appears before command?}
B -- Yes --> C[Swap profile and command]
B -- No --> D[Keep arguments unchanged]
C --> E[argparse]
D --> E
E --> F{Command is enter?}
F -- No --> G[Run selected command]
F -- Yes --> H{Container running?}
H -- Yes --> K[Refresh X11 credentials]
H -- No --> I[Check and configure X11]
I --> J[Start container]
J --> K
K --> L[Enter container]
Reviews (1): Last reviewed commit: "Merge branch 'develop' into jichuanh/con..." | Re-trigger Greptile |
There was a problem hiding this comment.
Isaac Lab Review Bot
Reviewed the argv reordering, backward-compatible command-first syntax, and the new enter auto-start behavior. The changed parser, lifecycle branches, tests, documentation examples, and changelog are consistent with the intended CLI contract.
- Design and architecture: The argv pre-pass derives recognized commands from
subparsers.choices, keeping profile-first detection aligned with argparse’s registered subcommands. Theenterpath conditionally performs the same X11 setup required bystartbefore entering a stopped container; this introduces some duplicated setup logic but no demonstrated merge-blocking issue. - API: Existing
<command> [profile]forms remain unchanged, while<profile> <command>gains defined meaning when the first two tokens are unambiguous. The state-changing behavior ofenteron a stopped container is intentional and documented, including the possibility that startup may take time. - Implementation: The parser explicitly passes the reordered
sys.argv[1:]to argparse, and the running-state guard avoids restarting an active container. Tests cover both argument orders, flag handling, command/profile disjointness, and both running states forenter; documentation and the changelog reflect the changed behavior.
No blocking issues. No inline issue met the actionable-evidence threshold; the assessment above records the review feedback.
Automated review; human maintainers own approval decisions.
|
The new regression tests are not currently executed by CI. docker/test/test_container_cli.py covers both the profile-first parser and enter-from-stopped behavior, but the Kit-less Docker workflow runs only test_container_profiles.py and test_dockerfile_nonroot.py. The general test runner defaults to source/, so this new file is not collected elsewhere either. Please add test_container_cli.py to both the workflow change-detection patterns and its pytest command, so these regressions remain enforced and test-only changes trigger the job. |
AntoineRichard
left a comment
There was a problem hiding this comment.
🤖 AI-generated review (OpenAI Codex)
This review was generated by an AI coding agent and verified against commit 719e5e4c13992613de924d81e8dc33a21ffb1028.
Findings
-
Important — New regression tests are not run by CI.
docker/test/test_container_cli.pyis absent from both the change-detection patterns and pytest invocation in the Kit-less workflow. Consequently, neither new behavior is continuously enforced, and test-only changes would not trigger the job. Please add this file to both locations. This was also raised in the existing PR comment. -
Moderate — The X11 recovery behavior is not actually tested.
The stopped-container test forces
x11_check()to returnNone. Removing the new X11 setup would therefore leave this test green even thoughenterafterstopwould again terminate inx11_refresh()when X11 is enabled. Please add a stopped/X11-enabled case that returns the overlay and environment, then verifies they are applied beforestart(). -
Moderate — The
Changedfragment lacks required migration guidance.The repository guidelines require migration guidance for every
Changedentry, but the fragment only describes the new behavior. A concise addition could tell scripts that relied onenterfailing for stopped containers to check container state explicitly before invoking it.
I found no implementation-level correctness defect in the argument rewrite or auto-start control flow.
Verification
28 passedacrosstest_container_cli.pyandtest_container_profiles.py.- Full
./isaaclab.sh -fpassed. - With the base implementation temporarily restored, the new test file produced
12 failed, 3 passed; restoring the PR implementation produced15 passed. - No live Docker lifecycle test was run.
1. Summary
./docker/container.py <profile> <command>is now accepted, so stepping a container through its lifecycle only changes the last word:kitless build→kitless start→kitless enter. The existing<command> <profile>order keeps working.enternow starts the container when it is not running, instead of failing withThe container '<name>' is not running.2. Why
Repeating the profile on every command puts the only varying word in the middle of the line, so the previous command cannot be reused by editing its tail. This was invisible while
basewas the default and usually omitted; the kit-less profile is the first one typed on every invocation.The command set comes from argparse's own
subparsers.choicesrather than a second hardcoded list, so adding a subcommand needs no change here. Every subcommand takes exactly one positional — the profile — which is what makes the swap unambiguous; a test pins that profile names and command names stay disjoint.3.
enterbehaviour changestopdeletes the temporary.xauthfile, soenterafterwards failed twice over:x11_refresherrored withX11 forwarding is enabled but the temporary .xauth file does not existbefore the "container is not running" check was even reached. Running the same setupstartdoes resolves both.Note for reviewers: this means
entercan now trigger a build on a cold cache, so it is no longer guaranteed-fast. It prints[INFO] Container '<name>' is not running. Starting it first...so the pause is explained. A test pins both directions, so a running container is never restarted.4. Validation
5. Type of change
6. Checklist
pre-commitchecks with./isaaclab.sh --format