"""Validate the actual portable release with no processing-stack imports.""" from pathlib import Path import sys,json,hashlib,math,subprocess,argparse,zipfile sys.dont_write_bytecode=True import numpy as np import polars as pl parser=argparse.ArgumentParser(description=__doc__);parser.add_argument("root",type=Path);parser.add_argument("--write-report",action="store_true") args=parser.parse_args();root=args.root.resolve();sys.path.insert(0,str(root)) from observation_reader import ObservationDataset,camera_points from datasets import load_dataset,Video sample=ObservationDataset(root);report={"reader_environment":"isolated numpy/polars/opencv + Hugging Face Datasets", "episodes":[], "annotation_accuracy":"not_independently_measured", "robot_transfer":"not_evaluated"} assert len(sample.episodes)==3 for key,e in sample.episodes.items(): mapping=sample.table(key,"frame_mapping");display=mapping.filter(pl.col("rgb_decodable")) assert display.height==e["frame_count"] assert mapping["source_frame_index"].to_list()==list(range(mapping.height)) with zipfile.ZipFile(root/e["sensors"]) as archive: names=set(archive.namelist()) for source_idx in mapping["source_frame_index"]: assert all(f"{kind}/{source_idx:06d}.png" in names for kind in ("depth","confidence")) assert display["rgb_frame_index"].to_list()==list(range(e["frame_count"])) assert display["t_s"][0]==0 indices=[0,e["frame_count"]//4,e["frame_count"]//2,3*e["frame_count"]//4,e["frame_count"]-1] tests=[] for idx in indices: frame=sample.frame(key,idx) assert frame["rgb"].shape==(e["height"],e["width"],3) assert frame["confidence"].shape==frame["depth_m"].shape assert np.isfinite(frame["K_rgb"]).all() and frame["K_rgb"][0,0]>0 assert np.isfinite(frame["camera_pose_xyzw"]).all() assert abs(np.linalg.norm(frame["camera_pose_xyzw"][3:])-1)<1e-3 assert (frame["depth_m"][~frame["depth_valid"]]==0).all() points=camera_points(frame); assert np.isfinite(points).all() and len(points)>0 tests.append({"rgb_frame_index":idx,"source_frame_index":frame["source_frame_index"],"valid_depth_points":len(points)}) hand=sample.table(key,"hand_pose") assert all(hand[k].null_count()==hand.height for k in ("z","wx","wy","wz")) assert sample.annotations_near(key,"hand_pose",1e6).height==0 report["episodes"].append({"capture_id":key,"displayed_rgb_frames":e["frame_count"],"source_sensor_frames":mapping.height,"decoded_samples":tests,"hand_rows":hand.height,"handedness_rows":hand.group_by("handedness").len().sort("handedness").to_dicts()}) # Load the embedded preview catalog with the actual Hugging Face library. catalog=load_dataset("parquet",data_files={"sample":str(root/"data/episodes.parquet")})["sample"] assert isinstance(catalog.features["video"],Video) catalog=catalog.cast_column("video",Video(decode=False));assert len(catalog)==3 for row in catalog: assert row["video"]["bytes"] and row["instruction"] report["huggingface_preview"]={"rows":3,"video_feature":True,"embedded_video_bytes":True} checked=0 for line in (root/"checksums.sha256").read_text().splitlines(): expected,rel=line.split(" ",1);actual=hashlib.file_digest((root/rel).open("rb"),"sha256").hexdigest() assert actual==expected,rel checked+=1 report["verified_artifact_hashes"]=checked report["status"]="passed" if args.write_report: (root/"validation.json").write_text(json.dumps(report,indent=2),encoding="utf-8") print(json.dumps(report,indent=2))