lyang84 commited on
Commit
83a42c8
·
verified ·
1 Parent(s): 97a7ddc

Align local validator with nested-field Croissant policy

Browse files
Files changed (1) hide show
  1. scripts/validate_artifact.py +16 -2
scripts/validate_artifact.py CHANGED
@@ -2,6 +2,7 @@
2
  """Local structural checks for the BehaviorBench NeurIPS artifact."""
3
  import json, re, sys
4
  from pathlib import Path
 
5
  import pyarrow.parquet as pq
6
 
7
  ROOT=Path(__file__).resolve().parents[1]
@@ -24,9 +25,22 @@ for rel,p in files.items():
24
  if rel not in dists: errors.append(f"no distribution for {rel}")
25
  if rel not in records: errors.append(f"no recordSet for {rel}")
26
  else:
27
- actual=set(pq.ParquetFile(p).schema_arrow.names)
 
28
  described={x.get("name") for x in records[rel].get("field",[])}
29
- if actual!=described: errors.append(f"schema mismatch for {rel}")
 
 
 
 
 
 
 
 
 
 
 
 
30
  for rel in dists:
31
  if rel not in files: errors.append(f"distribution path not found: {rel}")
32
 
 
2
  """Local structural checks for the BehaviorBench NeurIPS artifact."""
3
  import json, re, sys
4
  from pathlib import Path
5
+ import pyarrow as pa
6
  import pyarrow.parquet as pq
7
 
8
  ROOT=Path(__file__).resolve().parents[1]
 
25
  if rel not in dists: errors.append(f"no distribution for {rel}")
26
  if rel not in records: errors.append(f"no recordSet for {rel}")
27
  else:
28
+ schema=pq.ParquetFile(p).schema_arrow
29
+ actual=set(schema.names)
30
  described={x.get("name") for x in records[rel].get("field",[])}
31
+ if not described.issubset(actual):
32
+ errors.append(f"schema contains unknown fields for {rel}")
33
+ omitted=actual-described
34
+ for name in omitted:
35
+ t=schema.field(name).type
36
+ # Current mlcroissant record generation cannot reliably cast
37
+ # nested Parquet structs, including list<struct<...>> columns.
38
+ nested_struct = pa.types.is_struct(t) or (
39
+ (pa.types.is_list(t) or pa.types.is_large_list(t))
40
+ and pa.types.is_struct(t.value_type)
41
+ )
42
+ if not nested_struct:
43
+ errors.append(f"unexplained omitted field {name} for {rel}")
44
  for rel in dists:
45
  if rel not in files: errors.append(f"distribution path not found: {rel}")
46