Skip to content

Add mcoplib mcoplib artifact manifest#49

Open
ghangz wants to merge 2 commits into
MetaX-MACA:mainfrom
ghangz:mengz/mcoplib-artifact-manifest
Open

Add mcoplib mcoplib artifact manifest#49
ghangz wants to merge 2 commits into
MetaX-MACA:mainfrom
ghangz:mengz/mcoplib-artifact-manifest

Conversation

@ghangz

@ghangz ghangz commented Jul 1, 2026

Copy link
Copy Markdown

Summary

  • Adds a focused mcoplib artifact manifest 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/artifact_manifest.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-artifact-manifest
  • 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 Python script, tools/artifact_manifest.py, designed to generate a reproducible artifact manifest with file sizes and SHA-256 hashes. The feedback suggests two key improvements: first, replacing the assert statement and hardcoded filename in self_test() with tempfile.NamedTemporaryFile and an explicit RuntimeError to prevent silent optimization bypasses and file overwrites; second, validating that the --root path exists and is a directory to avoid silent failures when an invalid path is provided.

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/artifact_manifest.py Outdated
Comment on lines +37 to +45
def self_test() -> None:
sample = Path("_artifact_manifest_sample.txt")
sample.write_text("maca artifact\n", encoding="utf-8")
try:
data = collect(Path.cwd())
assert any(item["path"] == sample.name for item in data["artifacts"])
print(json.dumps({"ok": True, "count": data["count"]}, ensure_ascii=False))
finally:
sample.unlink(missing_ok=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.

high

Using assert statements for runtime validation or test assertions in executable scripts is risky because they are completely stripped out when Python is run with optimization flags (e.g., python -O). If that happens, the self-test will silently pass even if the sample artifact is missing.

Additionally, writing directly to a hardcoded filename like _artifact_manifest_sample.txt in the current working directory can accidentally overwrite an existing user file.

Using tempfile.NamedTemporaryFile with dir=Path.cwd() and a .txt suffix is a much safer approach. It guarantees a unique filename to prevent overwriting, and raising an explicit RuntimeError ensures the validation is never optimized away.

Suggested change
def self_test() -> None:
sample = Path("_artifact_manifest_sample.txt")
sample.write_text("maca artifact\n", encoding="utf-8")
try:
data = collect(Path.cwd())
assert any(item["path"] == sample.name for item in data["artifacts"])
print(json.dumps({"ok": True, "count": data["count"]}, ensure_ascii=False))
finally:
sample.unlink(missing_ok=True)
def self_test() -> None:
import tempfile
with tempfile.NamedTemporaryFile(dir=Path.cwd(), suffix=".txt", delete=False) as f:
temp_path = Path(f.name)
f.write(b"maca artifact\n")
try:
data = collect(Path.cwd())
if not any(item["path"] == temp_path.name for item in data["artifacts"]):
raise RuntimeError(f"Self-test failed: {temp_path.name} not found in artifacts")
print(json.dumps({"ok": True, "count": data["count"]}, ensure_ascii=False))
finally:
temp_path.unlink(missing_ok=True)

Comment on lines +52 to +57
args = parser.parse_args()
if args.self_test:
self_test()
return 0
print(json.dumps(collect(Path(args.root)), ensure_ascii=False, indent=2))
return 0

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

If the directory specified by --root does not exist or is not a directory, collect will silently return an empty list of artifacts with a success exit code (0). This can be highly misleading to users who might have misspelled the path.

Validating that the path exists and is a directory using parser.error() provides immediate, clear feedback and prevents silent failures.

Suggested change
args = parser.parse_args()
if args.self_test:
self_test()
return 0
print(json.dumps(collect(Path(args.root)), ensure_ascii=False, indent=2))
return 0
args = parser.parse_args()
if args.self_test:
self_test()
return 0
root_path = Path(args.root)
if not root_path.is_dir():
parser.error(f"Root path '{root_path}' is not a directory or does not exist.")
print(json.dumps(collect(root_path), ensure_ascii=False, indent=2))
return 0

@ghangz ghangz force-pushed the mengz/mcoplib-artifact-manifest branch from a607647 to 76d76c0 Compare July 1, 2026 07:43
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