@@ -37,23 +37,6 @@ def get_source_id_result(
3737 # print(f"Pinging {url=} with {params=}")
3838 r_source_id = session .get (url , params = params )
3939
40- # Workaround https://github.com/esgf2-us/esgf-1.5-design/issues/86
41- def fix_timestamp (v : str | list | None ) -> str | None :
42- if isinstance (v , str ) or v is None :
43- return v
44-
45- if isinstance (v , list ) and len (v ) == 1 :
46- return v [0 ]
47-
48- raise AssertionError (v )
49-
50- if "_timestamp" in r_source_id and isinstance (r_source_id ["_timestamp" ], list ):
51- if len (r_source_id ["_timestamp" ] != 1 ):
52- msg = f"Unexpected value for { source_id = } for { source_id ['_timestamp' ]} "
53- raise AssertionError (msg )
54-
55- r_source_id ["timestamp" ] = r_source_id ["timestamp" ][0 ]
56-
5740 return r_source_id
5841
5942
@@ -162,6 +145,24 @@ def get_esgf_info(n_threads: int) -> dict[str, Any]:
162145 msg = f"Detail:\n { detail_lines } \n There were { len (failures )} failures, { failure_status_counts = } "
163146 raise AssertionError (msg )
164147
148+ # Workaround https://github.com/esgf2-us/esgf-1.5-design/issues/86
149+ def fix_timestamp (v : str | list | None ) -> str | None :
150+ if isinstance (v , str ) or v is None :
151+ return v
152+
153+ if isinstance (v , list ) and len (v ) == 1 :
154+ return v [0 ]
155+
156+ raise AssertionError (v )
157+
158+ for k in res :
159+ if "_timestamp" in res [k ] and isinstance (res [k ]["_timestamp" ], list ):
160+ if len (res [k ]["_timestamp" ] != 1 ):
161+ msg = f"Unexpected value for { source_id = } for { source_id ['_timestamp' ]} "
162+ raise AssertionError (msg )
163+
164+ res [k ]["timestamp" ] = res [k ]["timestamp" ][0 ]
165+
165166 return res
166167
167168
0 commit comments