Skip to content

Add mcoplib mcoplib profiler bool env#55

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

Add mcoplib mcoplib profiler bool env#55
ghangz wants to merge 2 commits into
MetaX-MACA:mainfrom
ghangz:mengz/mcoplib-profiler-bool-env

Conversation

@ghangz

@ghangz ghangz commented Jul 1, 2026

Copy link
Copy Markdown

Summary

  • Adds a focused mcoplib profiler bool env 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 -m pytest unit_test/test_profiler_env.py
  • Pull request text is intentionally ASCII-only to avoid encoding issues on web forms and API clients.

Review notes

  • Source branch: ghangz:mengz/mcoplib-profiler-bool-env
  • 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 updates the _is_profiler_enabled function in mcoplib/profiler.py to support a wider range of falsy environment variable values (such as 'false', 'off', and 'no') and adds corresponding unit tests. The feedback suggests simplifying the implementation by removing the redundant try-except block and str() conversion, since the environment variable is guaranteed to be a string.

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 mcoplib/profiler.py Outdated
Comment on lines 11 to 15
v = os.getenv("PROFILER_ENABLED", "1")
try:
return not (str(v).strip() == "0")
return str(v).strip().lower() not in {"0", "false", "off", "no"}
except Exception:
return True

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

The try-except block and the str(v) conversion are redundant here. Since os.getenv is called with a default string value of "1", v is guaranteed to be a string. String operations like .strip() and .lower() as well as the set membership check will not raise any exceptions under normal execution. Removing the redundant try-except block and str() conversion simplifies the code and improves readability.

    v = os.getenv("PROFILER_ENABLED", "1")
    return v.strip().lower() not in {"0", "false", "off", "no"}

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