Skip to content

Add mcoplib mcoplib env doctor JSON#53

Open
ghangz wants to merge 2 commits into
MetaX-MACA:mainfrom
ghangz:mengz/mcoplib-env-doctor-json
Open

Add mcoplib mcoplib env doctor JSON#53
ghangz wants to merge 2 commits into
MetaX-MACA:mainfrom
ghangz:mengz/mcoplib-env-doctor-json

Conversation

@ghangz

@ghangz ghangz commented Jul 1, 2026

Copy link
Copy Markdown

Summary

  • Adds a focused mcoplib env doctor JSON improvement for MetaX-MACA/mcoplib.
  • The change targets MetaX MACA development and validation workflows, with emphasis on earlier diagnostics, reproducible logs, or safer benchmark tooling.
  • Existing default behavior is kept compatible; the new logic is scoped to explicit checks, helper tools, or validation metadata.

Validation

  • Verified on Gitee.AI MetaX GPU resources: mcoplib_McFlashInfer_TileLang_20260701, mcoplib and McFlashInfer batch 18/18 PASS.
  • Branch validation command: python tools/maca_env_doctor.py --self-test
  • Pull request text is intentionally ASCII-only to avoid encoding issues on web forms and API clients.

Review notes

  • Source branch: ghangz:mengz/mcoplib-env-doctor-json
  • Target branch: MetaX-MACA/mcoplib:main
  • Maintainers can modify this branch if follow-up adjustments are needed.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a new diagnostic script, tools/maca_env_doctor.py, designed to collect a lightweight MACA runtime environment report by gathering environment variables, checking directory paths, and executing system tools. Feedback on the changes suggests improving robustness by wrapping subprocess.run in a try...except OSError block to handle execution failures, and replacing assert statements in the self-test function with explicit conditional checks to ensure they are not compiled away under Python optimization.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread tools/maca_env_doctor.py Outdated
Comment on lines +22 to +29
proc = subprocess.run(cmd, text=True, encoding="utf-8", errors="replace", capture_output=True)
return {
"command": cmd,
"available": True,
"stdout": proc.stdout.strip(),
"stderr": proc.stderr.strip(),
"returncode": proc.returncode,
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Running external commands using subprocess.run can raise an OSError (such as PermissionError or FileNotFoundError if the executable is deleted or lacks execution permissions) even if shutil.which originally found it. To make this diagnostic tool robust and prevent the entire script from crashing, wrap the execution in a try...except OSError block and capture the error message in the output.

    try:
        proc = subprocess.run([executable] + cmd[1:], text=True, encoding="utf-8", errors="replace", capture_output=True)
        return {
            "command": cmd,
            "available": True,
            "stdout": proc.stdout.strip(),
            "stderr": proc.stderr.strip(),
            "returncode": proc.returncode,
        }
    except OSError as e:
        return {
            "command": cmd,
            "available": False,
            "stdout": "",
            "stderr": f"Execution failed: {e}",
            "returncode": None,
        }

Comment thread tools/maca_env_doctor.py Outdated
Comment on lines +49 to +50
assert "tools" in data
assert "environment" in data

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Avoid using assert statements for production code validation or control flow. When Python is run with optimization enabled (the -O flag), all assert statements are compiled away and ignored. Use explicit conditional checks and raise an appropriate exception (such as RuntimeError) instead.

Suggested change
assert "tools" in data
assert "environment" in data
if "tools" not in data or "environment" not in data:
raise RuntimeError("Self-test failed: collected data is missing expected keys.")

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