Installables: submodules fix#872
Conversation
📝 WalkthroughWalkthroughCentralizes Git submodule handling by adding Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~40 minutes Poem
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/cloudai/_core/installables.py`:
- Around line 139-143: The current submodule-status check using
submodules_initialized = (line.startswith(" ") for line in output) misses '+'
and 'U' prefixes; update the logic so when self.init_submodules is False you
verify all submodules are uninitialized (i.e., lines start with '-'), and when
self.init_submodules is True you detect initialized states (space, '+', or 'U')
as initialized; change the generator/conditions around submodules_initialized
and the two checks that call all(...) / any(...) (referencing
submodules_initialized and the branches using self.init_submodules) to
explicitly test for the correct set of prefixes (e.g., startswith one of (' ',
'+', 'U') for initialized and startswith('-') for uninitialized).
In `@tests/test_installables.py`:
- Around line 43-56: Add test cases to the pytest.mark.parametrize matrices in
tests/test_installables.py to cover git submodule status prefixes '+' (and
optionally 'U') which indicate populated checkouts; treat '+' like the space
prefix (initialized) in the expected outcomes. Concretely, add tuples where
stdout starts with "+0123456789abcdef path/to/submodule\n" mirroring the
existing space-prefixed cases in both parametrize blocks so that when
init_submodules=False the '+' case yields the same
expected_result/expected_message as the space case, and when
init_submodules=True the '+' case yields the same result as the space case;
update both parameter lists that currently only include " " and "-" to include
"+" (and "U" if desired).
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: e7515511-fe63-4bff-9eda-bbf8a67ec4d0
📒 Files selected for processing (5)
src/cloudai/_core/installables.pysrc/cloudai/systems/kubernetes/kubernetes_installer.pysrc/cloudai/systems/slurm/slurm_installer.pytests/test_git_repo_installer.pytests/test_installables.py
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/cloudai/_core/installables.py`:
- Around line 149-157: The check_submodules_state call can fail with a non-empty
error message but the code currently ignores that and proceeds to mutate
submodules; update the logic around check_submodules_state in the installables
code so that after calling check_submodules_state(repo_path) you immediately
return False with the provided error string when the second value is non-empty
(or when submodules_are_ok is False and an error message exists) instead of
falling through to run git submodule update/deinit; reference the
check_submodules_state return tuple, the init_submodules flag, repo_path, and
the existing subprocess.run(["git", "submodule", *cmd], ...) invocation to
locate where to add this early-return.
In `@tests/test_installables.py`:
- Around line 121-160: Add a regression case to tests/test_installables.py for
ensure_submodules_state() where the initial subprocess.run (the status query)
returns a non-zero code: extend the parametrized inputs in
test_ensure_submodules_state_reconcile_failure (or add a new test) to include a
scenario like (init_submodules value, stdout value, expected_message "Failed to
get submodule status: err"), set mock_run.side_effect so the first
CompletedProcess has returncode=1 and stderr="err" (no further calls), assert
result is False, message equals the expected_message, and assert
mock_run.call_count == 1; reference ensure_submodules_state and the use of
subprocess.run/mock_run to locate where to change.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 2a840992-54dc-46b7-ade2-7d2d4d5c2bf7
📒 Files selected for processing (2)
src/cloudai/_core/installables.pytests/test_installables.py
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/test_installables.py`:
- Around line 96-119: Add two more parametrized cases to
test_ensure_submodules_state_reconciles for init_submodules=True that use stdout
lines starting with '+' and 'U' (e.g. "+0123456789abcdef path/to/submodule\n"
and "U0123456789abcdef path/to/submodule\n") and assert the same
expected_command ["git", "submodule", "update", "--init", "--recursive"]; this
keeps coverage symmetric with the existing '-' case and uses the same
git.init_submodules path and mock_run behavior to verify the reconciliation
command.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: d82530f6-d3bb-4f1d-85c5-e1388688dc35
📒 Files selected for processing (2)
src/cloudai/_core/installables.pytests/test_installables.py
Summary
Issue:
init_submodules = falseinit_submodulestotrueTest Plan
cloudai install/runruns on EOSAdditional Notes