视觉审核完成30%
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
"""Verify generated assets declared in a manifest v2 file."""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from asset_quality import analyze_asset
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("manifest", type=Path)
|
||||
parser.add_argument("--workspace", type=Path, required=True)
|
||||
parser.add_argument("--report", type=Path, required=True)
|
||||
args = parser.parse_args()
|
||||
|
||||
manifest = json.loads(args.manifest.read_text(encoding="utf-8"))
|
||||
reports = []
|
||||
failed = False
|
||||
for asset in manifest["assets"]:
|
||||
output = args.workspace / asset["output"]
|
||||
if not output.is_file():
|
||||
report = {
|
||||
"id": asset["id"],
|
||||
"path": str(output),
|
||||
"errors": ["output file is missing"],
|
||||
"warnings": [],
|
||||
"metrics": {},
|
||||
}
|
||||
else:
|
||||
report = analyze_asset(output, asset)
|
||||
reports.append(report)
|
||||
if report["errors"]:
|
||||
failed = True
|
||||
print(f"ASSET-QUALITY FAIL {asset['id']}: {'; '.join(report['errors'])}")
|
||||
else:
|
||||
print(f"ASSET-QUALITY PASS {asset['id']}")
|
||||
|
||||
args.report.parent.mkdir(parents=True, exist_ok=True)
|
||||
args.report.write_text(json.dumps(reports, ensure_ascii=False, indent=2), encoding="utf-8")
|
||||
if failed:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user