Skip to content

Parsing: fix system config detection#881

Merged
podkidyshev merged 5 commits into
mainfrom
ipod/fix-system-conf-detect
Apr 23, 2026
Merged

Parsing: fix system config detection#881
podkidyshev merged 5 commits into
mainfrom
ipod/fix-system-conf-detect

Conversation

@podkidyshev
Copy link
Copy Markdown
Contributor

Summary

scheduler = pattern was detected in a config with something_scheduler = being part of cmd args

Test Plan

  • Automated CI
  • Manual run of verify-configs on CloudAIx repo

Additional Notes

@podkidyshev podkidyshev self-assigned this Apr 22, 2026
@podkidyshev podkidyshev added the bug Something isn't working label Apr 22, 2026
@podkidyshev podkidyshev requested a review from jeffnvidia as a code owner April 22, 2026 19:27
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 22, 2026

📝 Walkthrough

Walkthrough

Replaces substring-based TOML heuristic in load_tomls_by_type() with toml.loads parsing; TOML decode errors or non-dict top-level values are classified as unknown. Parsed dict-shaped TOMLs containing the "scheduler" key are classified as system. Tests updated to use a parsed ALL_SYSTEMS.

Changes

Cohort / File(s) Summary
TOML classification logic
src/cloudai/cli/handlers.py
Replaced raw-text "scheduler =" substring check with structured toml.loads parsing; files with decode errors or non-dict top-level values classified as unknown; parsed dicts containing "scheduler" classified as system.
Tests — system discovery
tests/test_toml_files.py
Added get_all_systems() which parses conf/**/*.toml via toml.loads, ignores decode errors, and returns only files whose parsed top-level is a dict containing "scheduler"; ALL_SYSTEMS updated to use this helper.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I nibble keys and parse the night,
Through dotted files I take a flight,
If scheduler greets me in the nest,
I stamp it system, then take a rest,
Hopping onward — code feels light.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: fixing system config detection by improving the parsing logic from substring matching to structured TOML parsing.
Description check ✅ Passed The description explains the bug being fixed (false positive detection of 'scheduler =' pattern) and provides context about testing and the internal ticket reference.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ipod/fix-system-conf-detect

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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 `@src/cloudai/cli/handlers.py`:
- Around line 554-555: The current check if "\nscheduler =" in content can miss
files where a "scheduler =" key appears at the start or is indented; replace
that substring test with a line-anchored check that iterates
content.splitlines() and treats a line as a match when
line.lstrip().startswith("scheduler =") (so the branch that calls
files["system"].append(toml_file) triggers for leading-byte or indented keys).
Update the same matcher logic in tests/test_toml_files.py so production and
tests use identical line-anchored detection.
🪄 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: b23ab1c0-e001-478c-a971-4b3e52e4d563

📥 Commits

Reviewing files that changed from the base of the PR and between 941ad55 and a8886b8.

📒 Files selected for processing (1)
  • src/cloudai/cli/handlers.py

Comment thread src/cloudai/cli/handlers.py Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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 `@src/cloudai/cli/handlers.py`:
- Around line 554-561: When toml.loads(content) raises TomlDecodeError the file
is currently skipped; change the except block to record the path into the files
mapping (e.g. files["unknown"] or a new files["invalid_toml"]) instead of
continuing, so malformed TOML files are surfaced by handle_verify_all_configs;
update any downstream logic in handle_verify_all_configs that aggregates counts
to include this new category (or unknown) so these errors are reported as
failures. Ensure you reference the toml.loads call and the files dict
(files["unknown"] or files["invalid_toml"]) when making the 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: bc49d04a-5b27-4aec-8d7f-a85052848a0b

📥 Commits

Reviewing files that changed from the base of the PR and between a8886b8 and 0eb030a.

📒 Files selected for processing (1)
  • src/cloudai/cli/handlers.py

Comment thread src/cloudai/cli/handlers.py
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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_toml_files.py`:
- Around line 29-41: get_all_systems currently classifies files as system TOMLs
purely by presence of a top-level "scheduler" key, but runtime code in
src/cloudai/cli/handlers.py filters out hook-root TOMLs before scheduler
detection; update get_all_systems (which iterates TOML_FILES) to first apply the
same hook-root detection used in handlers.py (or import/reuse that predicate if
exposed) and skip those files, then perform the existing "scheduler" key check
so test classification matches runtime behavior.
🪄 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: 93a0a579-944e-4e6a-aa1c-e002116bbab6

📥 Commits

Reviewing files that changed from the base of the PR and between 82550d0 and 692ee00.

📒 Files selected for processing (1)
  • tests/test_toml_files.py

Comment thread tests/test_toml_files.py
@podkidyshev podkidyshev requested a review from amaslenn April 22, 2026 20:22
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
tests/test_toml_files.py (1)

29-41: 🛠️ Refactor suggestion | 🟠 Major

Keep system test-file selection sourced from runtime classifier.

Line 29 re-implements a subset of system classification logic, and Line 56 depends on it. This can drift from src/cloudai/cli/handlers.py::load_tomls_by_type(...) again as classification rules evolve.

Proposed change
+from cloudai.cli.handlers import load_tomls_by_type
+
 def get_all_systems() -> list[Path]:
-    result = []
-
-    for p in TOML_FILES:
-        try:
-            toml_content = toml.loads(p.read_text())
-        except toml.TomlDecodeError:
-            continue
-
-        if isinstance(toml_content, dict) and "scheduler" in toml_content:
-            result.append(p)
-
-    return result
+    return load_tomls_by_type(TOML_FILES)["system"]

Also applies to: 56-56

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/test_toml_files.py` around lines 29 - 41, The test reimplements system
classification in get_all_systems; instead import and call the runtime
classifier used in production (load_tomls_by_type from src.cloudai.cli.handlers)
so test selection stays in sync: replace get_all_systems logic with a call to
load_tomls_by_type(...) (or a thin wrapper that returns the same list[Path]) and
adjust any callers (including the code around line 56) to use that result,
ensuring the returned type matches list[Path].
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@tests/test_toml_files.py`:
- Around line 29-41: The test reimplements system classification in
get_all_systems; instead import and call the runtime classifier used in
production (load_tomls_by_type from src.cloudai.cli.handlers) so test selection
stays in sync: replace get_all_systems logic with a call to
load_tomls_by_type(...) (or a thin wrapper that returns the same list[Path]) and
adjust any callers (including the code around line 56) to use that result,
ensuring the returned type matches list[Path].

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8087fbc5-a689-4ed0-aca5-80abe4225084

📥 Commits

Reviewing files that changed from the base of the PR and between 82550d0 and 692ee00.

📒 Files selected for processing (1)
  • tests/test_toml_files.py

@podkidyshev podkidyshev merged commit ea1c516 into main Apr 23, 2026
5 checks passed
@podkidyshev podkidyshev deleted the ipod/fix-system-conf-detect branch April 23, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants