@@ -52,7 +52,7 @@ def setup(target):
5252 target_application = "cmsrunregistry-sso-proxy"
5353
5454
55- def _get_headers (token : str = None ):
55+ def _get_headers (token : str = "" ):
5656 headers = {"Content-type" : "application/json" }
5757 if not use_cookies :
5858 headers ["email" ] = email
@@ -199,7 +199,7 @@ def get_dataset(run_number, dataset_name="online", **kwargs):
199199 return dataset [0 ]
200200
201201
202- def get_datasets (limit = 40000 , compress_attributes = True , ** kwargs ):
202+ def get_datasets (limit = 40000 , compress_attributes = True , ** kwargs ) -> list :
203203 """
204204 Gets all datasets that match the filter given
205205 :param compress_attributes: Gets the attributes inside rr_attributes:* and the ones in the DatasetTripletCache (The lumisections insdie the run/dataset) and spreads them over the run object
@@ -226,7 +226,7 @@ def get_datasets(limit=40000, compress_attributes=True, **kwargs):
226226 print (
227227 "ERROR: For queries that retrieve more than 20,000 datasets, you must pass a filter into get_datasets, an empty filter get_datasets(filter={}) works"
228228 )
229- return None
229+ return []
230230 for page_number in range (1 , page_count ):
231231 additional_datasets = _get_page (
232232 page = page_number , url = url , data_type = "datasets" , ** kwargs
@@ -251,6 +251,14 @@ def get_datasets(limit=40000, compress_attributes=True, **kwargs):
251251 return datasets
252252
253253
254+ def get_cycles ():
255+ url = "{}/cycles/global" .format (api_url )
256+ headers = _get_headers (token = _get_token ())
257+ if os .getenv ("ENVIRONMENT" ) == "development" :
258+ print (url )
259+ return requests .get (url , headers = headers ).json ()
260+
261+
254262def _get_lumisection_helper (url , run_number , dataset_name = "online" , ** kwargs ):
255263 """
256264 Puts the headers for all other lumisection methods
@@ -307,7 +315,7 @@ def generate_json(json_logic, **kwargs):
307315 DO NOT USE, USE THE ONE BELOW (create_json)...
308316 It receives a json logic configuration and returns a json with lumisections which pass the filter
309317 """
310- if isinstance (json_logic , str ) == False :
318+ if not isinstance (json_logic , str ):
311319 json_logic = json .dumps (json_logic )
312320 url = "{}/json_creation/generate" .format (api_url )
313321 headers = _get_headers (token = _get_token ())
@@ -321,7 +329,7 @@ def create_json(json_logic, dataset_name_filter, **kwargs):
321329 """
322330 It adds a json to the queue and polls until json is either finished or an error occured
323331 """
324- if isinstance (json_logic , str ) == False :
332+ if not isinstance (json_logic , str ):
325333 json_logic = json .dumps (json_logic )
326334 url = "{}/json_portal/generate" .format (api_url )
327335
0 commit comments