@@ -2043,6 +2043,72 @@ def _run_pilot_preregistration_check(args: argparse.Namespace) -> int:
20432043 print (json .dumps ({"status" : "error" , "error" : "--entry-json must be a JSON object" }))
20442044 return 2
20452045
2046+ string_fields = (
2047+ "record_id" , "version" , "frozen_at" , "pipeline_version" , "git_sha" ,
2048+ "primary_hypothesis" , "positive_control" , "negative_control" ,
2049+ "outcome_metric" , "notes" , "freeze_sha256" ,
2050+ )
2051+ for field_name in string_fields :
2052+ if field_name in entry_dict and not isinstance (entry_dict [field_name ], str ):
2053+ print (json .dumps ({
2054+ "status" : "error" ,
2055+ "error" : f"Malformed PRR JSON: { field_name } must be a string" ,
2056+ }))
2057+ return 2
2058+ list_fields = ("selection_criteria" , "amendment_reasons" , "score_thresholds" )
2059+ for field_name in list_fields :
2060+ if field_name in entry_dict and not isinstance (entry_dict [field_name ], list ):
2061+ print (json .dumps ({
2062+ "status" : "error" ,
2063+ "error" : f"Malformed PRR JSON: { field_name } must be a list" ,
2064+ }))
2065+ return 2
2066+ for field_name in ("dry_lab_only_declaration" , "is_locked" ):
2067+ if field_name in entry_dict and not isinstance (entry_dict [field_name ], bool ):
2068+ print (json .dumps ({
2069+ "status" : "error" ,
2070+ "error" : f"Malformed PRR JSON: { field_name } must be a boolean" ,
2071+ }))
2072+ return 2
2073+ for field_name in ("n_candidates_planned" , "amendment_count" ):
2074+ if field_name in entry_dict and (
2075+ not isinstance (entry_dict [field_name ], int )
2076+ or isinstance (entry_dict [field_name ], bool )
2077+ ):
2078+ print (json .dumps ({
2079+ "status" : "error" ,
2080+ "error" : f"Malformed PRR JSON: { field_name } must be an integer" ,
2081+ }))
2082+ return 2
2083+ for threshold in entry_dict .get ("score_thresholds" , []):
2084+ if not isinstance (threshold , dict ):
2085+ print (json .dumps ({
2086+ "status" : "error" ,
2087+ "error" : "Malformed PRR JSON: score_thresholds entries must be objects" ,
2088+ }))
2089+ return 2
2090+ if not isinstance (threshold .get ("score_name" ), str ):
2091+ print (json .dumps ({
2092+ "status" : "error" ,
2093+ "error" : "Malformed PRR JSON: score_thresholds.score_name must be a string" ,
2094+ }))
2095+ return 2
2096+ if (
2097+ not isinstance (threshold .get ("threshold_value" ), (int , float ))
2098+ or isinstance (threshold .get ("threshold_value" ), bool )
2099+ ):
2100+ print (json .dumps ({
2101+ "status" : "error" ,
2102+ "error" : "Malformed PRR JSON: score_thresholds.threshold_value must be numeric" ,
2103+ }))
2104+ return 2
2105+ if not isinstance (threshold .get ("direction" ), str ):
2106+ print (json .dumps ({
2107+ "status" : "error" ,
2108+ "error" : "Malformed PRR JSON: score_thresholds.direction must be a string" ,
2109+ }))
2110+ return 2
2111+
20462112 try :
20472113 thresholds = [
20482114 ScoreThreshold (** threshold )
0 commit comments