Initialize portable humanoid RL framework with licenses, locks and CI
Core and layout checks / core (push) Has been cancelled
Core and layout checks / core (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Ensure a built wheel contains exact backend sources, robot assets and licence resources."""
|
||||
|
||||
import argparse
|
||||
import email
|
||||
import json
|
||||
import tomllib
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("wheel", type=Path)
|
||||
args = parser.parse_args()
|
||||
missing, changed = [], []
|
||||
checked = 0
|
||||
license_files = 0
|
||||
with zipfile.ZipFile(args.wheel) as archive:
|
||||
names = set(archive.namelist())
|
||||
for source_root, package in (
|
||||
(ROOT / "src", "universal_humanoid"),
|
||||
(ROOT / "rl", "mjlab"),
|
||||
(ROOT / "rl", "rsl_rl"),
|
||||
):
|
||||
for source in sorted((source_root / package).rglob("*")):
|
||||
if not source.is_file() or "__pycache__" in source.parts:
|
||||
continue
|
||||
name = source.relative_to(source_root).as_posix()
|
||||
checked += 1
|
||||
if name not in names:
|
||||
missing.append(name)
|
||||
elif archive.read(name) != source.read_bytes():
|
||||
changed.append(name)
|
||||
metadata_names = [name for name in names if name.endswith(".dist-info/METADATA")]
|
||||
if len(metadata_names) != 1:
|
||||
raise ValueError("Expected exactly one wheel distribution metadata record")
|
||||
metadata_name = metadata_names[0]
|
||||
metadata = email.message_from_bytes(archive.read(metadata_name))
|
||||
project = tomllib.loads((ROOT / "pyproject.toml").read_text())["project"]
|
||||
if metadata.get("License-Expression") != project["license"]:
|
||||
changed.append(metadata_name + ":License-Expression")
|
||||
prefix = metadata_name.removesuffix("METADATA") + "licenses/"
|
||||
for pattern in project["license-files"]:
|
||||
for source in sorted(ROOT.glob(pattern)):
|
||||
name = prefix + source.relative_to(ROOT).as_posix()
|
||||
license_files += 1
|
||||
if name not in names:
|
||||
missing.append(name)
|
||||
elif archive.read(name) != source.read_bytes():
|
||||
changed.append(name)
|
||||
report = {
|
||||
"ready": not missing and not changed,
|
||||
"checked": checked,
|
||||
"license_files": license_files,
|
||||
"missing": missing,
|
||||
"changed": changed,
|
||||
"wheel": str(args.wheel),
|
||||
}
|
||||
print(json.dumps(report, indent=2))
|
||||
raise SystemExit(0 if report["ready"] else 1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Record or verify the repository vendor inventory (stdlib only, no simulator imports)."""
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def inventory(root):
|
||||
return {
|
||||
str(p.relative_to(root)): hashlib.sha256(p.read_bytes()).hexdigest()
|
||||
for p in sorted((root / "rl").rglob("*"))
|
||||
if p.is_file() and "__pycache__" not in p.parts and p.name != "VENDOR.json"
|
||||
}
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument(
|
||||
"--record", action="store_true", help="Explicitly accept the current vendor inventory"
|
||||
)
|
||||
args = parser.parse_args()
|
||||
path = ROOT / "rl/VENDOR.json"
|
||||
files = inventory(ROOT)
|
||||
imported = json.loads((ROOT / "rl/upstream/import.json").read_text())
|
||||
if args.record:
|
||||
original = imported["imported_files"]
|
||||
modified = sorted(p for p in original if files.get(p) != original[p])
|
||||
data = {
|
||||
"schema_version": 1,
|
||||
"files": files,
|
||||
"changed_since_import": modified,
|
||||
"added_since_import": sorted(set(files) - set(original)),
|
||||
"upstream": {key: imported[key] for key in ("mjlab", "rsl_rl", "booster_assets")},
|
||||
}
|
||||
path.write_text(json.dumps(data, sort_keys=True, indent=2) + "\n")
|
||||
print(
|
||||
f"Recorded {len(files)} files. Review docs/VENDOR.md and the changes before committing."
|
||||
)
|
||||
else:
|
||||
expected = json.loads(path.read_text())["files"]
|
||||
changed = sorted(
|
||||
p for p in files.keys() | expected.keys() if files.get(p) != expected.get(p)
|
||||
)
|
||||
print(
|
||||
json.dumps({"ready": not changed, "files": len(files), "mismatches": changed}, indent=2)
|
||||
)
|
||||
raise SystemExit(bool(changed))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user