@@ -282,7 +282,9 @@ def run_flow_on_task( # noqa: C901, PLR0912, PLR0915, PLR0913
282282 setup_id = setup_exists (flow_from_server )
283283 ids = run_exists (task .task_id , setup_id )
284284 if ids :
285- error_message = "One or more runs of this setup were already performed on the task."
285+ error_message = (
286+ "One or more runs of this setup were already performed on the task."
287+ )
286288 raise OpenMLRunsExistError (ids , error_message )
287289 else :
288290 # Flow does not exist on server and we do not want to upload it.
@@ -512,15 +514,11 @@ def _run_task_get_arffcontent( # noqa: PLR0915, PLR0912, C901
512514 # this information is multiple times overwritten, but due to the ordering
513515 # of tne loops, eventually it contains the information based on the full
514516 # dataset size
515- user_defined_measures_per_fold = (
516- OrderedDict ()
517- ) # type: 'OrderedDict[str, OrderedDict]'
517+ user_defined_measures_per_fold = OrderedDict () # type: 'OrderedDict[str, OrderedDict]'
518518 # stores sample-based evaluation measures (sublevel of fold-based)
519519 # will also be filled on a non sample-based task, but the information
520520 # is the same as the fold-based measures, and disregarded in that case
521- user_defined_measures_per_sample = (
522- OrderedDict ()
523- ) # type: 'OrderedDict[str, OrderedDict]'
521+ user_defined_measures_per_sample = OrderedDict () # type: 'OrderedDict[str, OrderedDict]'
524522
525523 # TODO use different iterator to only provide a single iterator (less
526524 # methods, less maintenance, less confusion)
@@ -614,11 +612,7 @@ def _calculate_local_measure( # type: ignore
614612 if isinstance (test_y [i ], (int , np .integer ))
615613 else test_y [i ]
616614 )
617- pred_prob = (
618- proba_y .iloc [i ]
619- if isinstance (proba_y , pd .DataFrame )
620- else proba_y [i ]
621- )
615+ pred_prob = proba_y .iloc [i ] if isinstance (proba_y , pd .DataFrame ) else proba_y [i ]
622616
623617 arff_line = format_prediction (
624618 task = task ,
@@ -681,13 +675,11 @@ def _calculate_local_measure( # type: ignore
681675 if rep_no not in user_defined_measures_per_sample [measure ]:
682676 user_defined_measures_per_sample [measure ][rep_no ] = OrderedDict ()
683677 if fold_no not in user_defined_measures_per_sample [measure ][rep_no ]:
684- user_defined_measures_per_sample [measure ][rep_no ][
685- fold_no
686- ] = OrderedDict ()
678+ user_defined_measures_per_sample [measure ][rep_no ][fold_no ] = OrderedDict ()
687679
688- user_defined_measures_per_fold [measure ][rep_no ][fold_no ] = (
689- user_defined_measures_fold [ measure ]
690- )
680+ user_defined_measures_per_fold [measure ][rep_no ][fold_no ] = user_defined_measures_fold [
681+ measure
682+ ]
691683 user_defined_measures_per_sample [measure ][rep_no ][fold_no ][sample_no ] = (
692684 user_defined_measures_fold [measure ]
693685 )
@@ -843,9 +835,7 @@ def get_run(run_id: int, ignore_cache: bool = False) -> OpenMLRun: # noqa: FBT0
843835 run : OpenMLRun
844836 Run corresponding to ID, fetched from the server.
845837 """
846- run_dir = Path (
847- openml .utils ._create_cache_directory_for_id (RUNS_CACHE_DIR_NAME , run_id )
848- )
838+ run_dir = Path (openml .utils ._create_cache_directory_for_id (RUNS_CACHE_DIR_NAME , run_id ))
849839 run_file = run_dir / "description.xml"
850840
851841 run_dir .mkdir (parents = True , exist_ok = True )
@@ -864,9 +854,10 @@ def get_run(run_id: int, ignore_cache: bool = False) -> OpenMLRun: # noqa: FBT0
864854 return _create_run_from_xml (run_xml )
865855
866856
867- def _create_run_from_xml (
868- xml : str , from_server : bool = True
869- ) -> OpenMLRun : # noqa: PLR0915, PLR0912, C901, FBT002
857+ def _create_run_from_xml ( # noqa: PLR0915, PLR0912, C901
858+ xml : str ,
859+ from_server : bool = True , # noqa: FBT002
860+ ) -> OpenMLRun :
870861 """Create a run object from xml returned from server.
871862
872863 Parameters
@@ -896,13 +887,11 @@ def obtain_field(xml_obj, fieldname, from_server, cast=None): # type: ignore
896887 if not from_server :
897888 return None
898889
899- raise AttributeError (
900- "Run XML does not contain required (server) field: " , fieldname
901- )
890+ raise AttributeError ("Run XML does not contain required (server) field: " , fieldname )
902891
903- run = xmltodict .parse (
904- xml , force_list = [ "oml:file" , "oml:evaluation" , "oml:parameter_setting" ]
905- )[ "oml:run" ]
892+ run = xmltodict .parse (xml , force_list = [ "oml:file" , "oml:evaluation" , "oml:parameter_setting" ])[
893+ "oml:run"
894+ ]
906895 run_id = obtain_field (run , "oml:run_id" , from_server , cast = int )
907896 uploader = obtain_field (run , "oml:uploader" , from_server , cast = int )
908897 uploader_name = obtain_field (run , "oml:uploader_name" , from_server )
@@ -1057,9 +1046,7 @@ def obtain_field(xml_obj, fieldname, from_server, cast=None): # type: ignore
10571046
10581047def _get_cached_run (run_id : int ) -> OpenMLRun :
10591048 """Load a run from the cache."""
1060- run_cache_dir = openml .utils ._create_cache_directory_for_id (
1061- RUNS_CACHE_DIR_NAME , run_id
1062- )
1049+ run_cache_dir = openml .utils ._create_cache_directory_for_id (RUNS_CACHE_DIR_NAME , run_id )
10631050 run_file = run_cache_dir / "description.xml"
10641051 try :
10651052 with run_file .open (encoding = "utf8" ) as fh :
@@ -1229,9 +1216,7 @@ def __list_runs(api_call: str) -> pd.DataFrame:
12291216 runs_dict = xmltodict .parse (xml_string , force_list = ("oml:run" ,))
12301217 # Minimalistic check if the XML is useful
12311218 if "oml:runs" not in runs_dict :
1232- raise ValueError (
1233- f'Error in return XML, does not contain "oml:runs": { runs_dict } '
1234- )
1219+ raise ValueError (f'Error in return XML, does not contain "oml:runs": { runs_dict } ' )
12351220
12361221 if "@xmlns:oml" not in runs_dict ["oml:runs" ]:
12371222 raise ValueError (
@@ -1245,9 +1230,7 @@ def __list_runs(api_call: str) -> pd.DataFrame:
12451230 f'"http://openml.org/openml": { runs_dict } ' ,
12461231 )
12471232
1248- assert isinstance (runs_dict ["oml:runs" ]["oml:run" ], list ), type (
1249- runs_dict ["oml:runs" ]
1250- )
1233+ assert isinstance (runs_dict ["oml:runs" ]["oml:run" ], list ), type (runs_dict ["oml:runs" ])
12511234
12521235 runs = {
12531236 int (r ["oml:run_id" ]): {
0 commit comments