Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 13, 2025
1 parent cc4c10c commit b9a2e80
Show file tree
Hide file tree
Showing 25 changed files with 96 additions and 102 deletions.
32 changes: 16 additions & 16 deletions openml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,35 +91,35 @@ def populate_cache(


__all__ = [
"OpenMLDataset",
"OpenMLBenchmarkSuite",
"OpenMLClassificationTask",
"OpenMLClusteringTask",
"OpenMLDataFeature",
"OpenMLRun",
"OpenMLSplit",
"OpenMLDataset",
"OpenMLEvaluation",
"OpenMLSetup",
"OpenMLParameter",
"OpenMLTask",
"OpenMLSupervisedTask",
"OpenMLClusteringTask",
"OpenMLFlow",
"OpenMLLearningCurveTask",
"OpenMLParameter",
"OpenMLRegressionTask",
"OpenMLClassificationTask",
"OpenMLFlow",
"OpenMLRun",
"OpenMLSetup",
"OpenMLSplit",
"OpenMLStudy",
"OpenMLBenchmarkSuite",
"OpenMLSupervisedTask",
"OpenMLTask",
"__version__",
"_api_calls",
"config",
"datasets",
"evaluations",
"exceptions",
"extensions",
"config",
"runs",
"flows",
"tasks",
"runs",
"setups",
"study",
"tasks",
"utils",
"_api_calls",
"__version__",
]

# Load the scikit-learn extension by default
Expand Down
2 changes: 1 addition & 1 deletion openml/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,10 +512,10 @@ def overwrite_config_context(config: dict[str, Any]) -> Iterator[_Config]:

__all__ = [
"get_cache_directory",
"get_config_as_dict",
"set_root_cache_directory",
"start_using_configuration_for_example",
"stop_using_configuration_for_example",
"get_config_as_dict",
]

_setup()
12 changes: 6 additions & 6 deletions openml/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
)

__all__ = [
"OpenMLDataFeature",
"OpenMLDataset",
"attributes_arff_from_df",
"check_datasets_active",
"create_dataset",
"delete_dataset",
"edit_dataset",
"fork_dataset",
"get_dataset",
"get_datasets",
"list_datasets",
"OpenMLDataset",
"OpenMLDataFeature",
"status_update",
"list_qualities",
"edit_dataset",
"fork_dataset",
"delete_dataset",
"status_update",
]
3 changes: 1 addition & 2 deletions openml/datasets/data_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ def __init__( # noqa: PLR0913
if data_type == "nominal":
if nominal_values is None:
raise TypeError(
"Dataset features require attribute `nominal_values` for nominal "
"feature type.",
"Dataset features require attribute `nominal_values` for nominal feature type.",
)

if not isinstance(nominal_values, list):
Expand Down
2 changes: 1 addition & 1 deletion openml/datasets/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def _parse_data_from_arff( # noqa: C901, PLR0912, PLR0915
data = self._get_arff(self.format)
except OSError as e:
logger.critical(
f"Please check that the data file {arff_file_path} is " "there and can be read.",
f"Please check that the data file {arff_file_path} is there and can be read.",
)
raise e

Expand Down
4 changes: 2 additions & 2 deletions openml/datasets/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def list_qualities() -> list[str]:
raise ValueError('Error in return XML, does not contain "oml:data_qualities_list"')

if not isinstance(qualities["oml:data_qualities_list"]["oml:quality"], list):
raise TypeError("Error in return XML, does not contain " '"oml:quality" as a list')
raise TypeError('Error in return XML, does not contain "oml:quality" as a list')

return qualities["oml:data_qualities_list"]["oml:quality"]

Expand Down Expand Up @@ -175,7 +175,7 @@ def list_datasets(
"""
if output_format not in ["dataframe", "dict"]:
raise ValueError(
"Invalid output format selected. " "Only 'dict' or 'dataframe' applicable.",
"Invalid output format selected. Only 'dict' or 'dataframe' applicable.",
)

# TODO: [0.15]
Expand Down
2 changes: 1 addition & 1 deletion openml/evaluations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

__all__ = [
"OpenMLEvaluation",
"list_evaluations",
"list_evaluation_measures",
"list_evaluations",
"list_evaluations_setups",
]
2 changes: 1 addition & 1 deletion openml/evaluations/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def __repr__(self) -> str:
"Run ID",
"OpenML Run URL",
"Task ID",
"OpenML Task URL" "Flow ID",
"OpenML Task URLFlow ID",
"OpenML Flow URL",
"Setup ID",
"Data ID",
Expand Down
14 changes: 7 additions & 7 deletions openml/evaluations/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def __list_evaluations(
# Minimalistic check if the XML is useful
if "oml:evaluations" not in evals_dict:
raise ValueError(
"Error in return XML, does not contain " f'"oml:evaluations": {evals_dict!s}',
f'Error in return XML, does not contain "oml:evaluations": {evals_dict!s}',
)

assert isinstance(evals_dict["oml:evaluations"]["oml:evaluation"], list), type(
Expand Down Expand Up @@ -321,9 +321,9 @@ def list_evaluation_measures() -> list[str]:
qualities = xmltodict.parse(xml_string, force_list=("oml:measures"))
# Minimalistic check if the XML is useful
if "oml:evaluation_measures" not in qualities:
raise ValueError("Error in return XML, does not contain " '"oml:evaluation_measures"')
raise ValueError('Error in return XML, does not contain "oml:evaluation_measures"')
if not isinstance(qualities["oml:evaluation_measures"]["oml:measures"][0]["oml:measure"], list):
raise TypeError("Error in return XML, does not contain " '"oml:measure" as a list')
raise TypeError('Error in return XML, does not contain "oml:measure" as a list')
return qualities["oml:evaluation_measures"]["oml:measures"][0]["oml:measure"]


Expand All @@ -343,13 +343,13 @@ def list_estimation_procedures() -> list[str]:

# Minimalistic check if the XML is useful
if "oml:estimationprocedures" not in api_results:
raise ValueError("Error in return XML, does not contain " '"oml:estimationprocedures"')
raise ValueError('Error in return XML, does not contain "oml:estimationprocedures"')
if "oml:estimationprocedure" not in api_results["oml:estimationprocedures"]:
raise ValueError("Error in return XML, does not contain " '"oml:estimationprocedure"')
raise ValueError('Error in return XML, does not contain "oml:estimationprocedure"')

if not isinstance(api_results["oml:estimationprocedures"]["oml:estimationprocedure"], list):
raise TypeError(
"Error in return XML, does not contain " '"oml:estimationprocedure" as a list',
'Error in return XML, does not contain "oml:estimationprocedure" as a list',
)

return [
Expand Down Expand Up @@ -415,7 +415,7 @@ def list_evaluations_setups(
"""
if parameters_in_separate_columns and (flows is None or len(flows) != 1):
raise ValueError(
"Can set parameters_in_separate_columns to true " "only for single flow_id",
"Can set parameters_in_separate_columns to true only for single flow_id",
)

# List evaluations
Expand Down
4 changes: 2 additions & 2 deletions openml/extensions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

__all__ = [
"Extension",
"register_extension",
"get_extension_by_model",
"get_extension_by_flow",
"get_extension_by_model",
"register_extension",
]
9 changes: 4 additions & 5 deletions openml/extensions/sklearn/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -1254,8 +1254,7 @@ def _check_dependencies(
else:
raise NotImplementedError(f"operation '{operation}' is not supported")
message = (
"Trying to deserialize a model with dependency "
f"{dependency_string} not satisfied."
f"Trying to deserialize a model with dependency {dependency_string} not satisfied."
)
if not check:
if strict_version:
Expand Down Expand Up @@ -1497,7 +1496,7 @@ def _prevent_optimize_n_jobs(self, model):
)
if len(n_jobs_vals) > 0:
raise PyOpenMLError(
"openml-python should not be used to " "optimize the n_jobs parameter.",
"openml-python should not be used to optimize the n_jobs parameter.",
)

################################################################################################
Expand Down Expand Up @@ -1555,7 +1554,7 @@ def _seed_current_object(current_value):

if current_value is not None:
raise ValueError(
"Models should be seeded with int or None (this should never " "happen). ",
"Models should be seeded with int or None (this should never happen). ",
)

return True
Expand Down Expand Up @@ -2006,7 +2005,7 @@ def is_subcomponent_specification(values):
# (mixed)). OpenML replaces the subcomponent by an
# OpenMLFlow object.
if len(subcomponent) < 2 or len(subcomponent) > 3:
raise ValueError("Component reference should be " "size {2,3}. ")
raise ValueError("Component reference should be size {2,3}. ")

subcomponent_identifier = subcomponent[0]
subcomponent_flow = subcomponent[1]
Expand Down
8 changes: 4 additions & 4 deletions openml/flows/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

__all__ = [
"OpenMLFlow",
"get_flow",
"list_flows",
"get_flow_id",
"flow_exists",
"assert_flows_equal",
"delete_flow",
"flow_exists",
"get_flow",
"get_flow_id",
"list_flows",
]
6 changes: 3 additions & 3 deletions openml/flows/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ def publish(self, raise_error_if_exists: bool = False) -> OpenMLFlow: # noqa: F
if not flow_id:
if self.flow_id:
raise openml.exceptions.PyOpenMLError(
"Flow does not exist on the server, " "but 'flow.flow_id' is not None.",
"Flow does not exist on the server, but 'flow.flow_id' is not None.",
)
super().publish()
assert self.flow_id is not None # for mypy
Expand All @@ -448,7 +448,7 @@ def publish(self, raise_error_if_exists: bool = False) -> OpenMLFlow: # noqa: F
raise openml.exceptions.PyOpenMLError(error_message)
elif self.flow_id is not None and self.flow_id != flow_id:
raise openml.exceptions.PyOpenMLError(
"Local flow_id does not match server flow_id: " f"'{self.flow_id}' vs '{flow_id}'",
f"Local flow_id does not match server flow_id: '{self.flow_id}' vs '{flow_id}'",
)

flow = openml.flows.functions.get_flow(flow_id)
Expand Down Expand Up @@ -520,7 +520,7 @@ def get_subflow(self, structure: list[str]) -> OpenMLFlow:
sub_identifier = structure[0]
if sub_identifier not in self.components:
raise ValueError(
f"Flow {self.name} does not contain component with " f"identifier {sub_identifier}",
f"Flow {self.name} does not contain component with identifier {sub_identifier}",
)
if len(structure) == 1:
return self.components[sub_identifier] # type: ignore
Expand Down
16 changes: 8 additions & 8 deletions openml/flows/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def _get_cached_flow(fid: int) -> OpenMLFlow:
return _create_flow_from_xml(fh.read())
except OSError as e:
openml.utils._remove_cache_dir_for_id(FLOWS_CACHE_DIR_NAME, fid_cache_dir)
raise OpenMLCacheException("Flow file for fid %d not " "cached" % fid) from e
raise OpenMLCacheException("Flow file for fid %d not cached" % fid) from e


@openml.utils.thread_safe_if_oslo_installed
Expand Down Expand Up @@ -217,7 +217,7 @@ def list_flows(
"""
if output_format not in ["dataframe", "dict"]:
raise ValueError(
"Invalid output format selected. " "Only 'dict' or 'dataframe' applicable.",
"Invalid output format selected. Only 'dict' or 'dataframe' applicable.",
)

# TODO: [0.15]
Expand Down Expand Up @@ -514,11 +514,11 @@ def assert_flows_equal( # noqa: C901, PLR0912, PLR0913, PLR0915
for name in set(attr1.keys()).union(attr2.keys()):
if name not in attr1:
raise ValueError(
f"Component {name} only available in " "argument2, but not in argument1.",
f"Component {name} only available in argument2, but not in argument1.",
)
if name not in attr2:
raise ValueError(
f"Component {name} only available in " "argument2, but not in argument1.",
f"Component {name} only available in argument2, but not in argument1.",
)
assert_flows_equal(
attr1[name],
Expand Down Expand Up @@ -547,9 +547,9 @@ def assert_flows_equal( # noqa: C901, PLR0912, PLR0913, PLR0915
)

if ignore_parameter_values_on_older_children:
assert (
flow1.upload_date is not None
), "Flow1 has no upload date that allows us to compare age of children."
assert flow1.upload_date is not None, (
"Flow1 has no upload date that allows us to compare age of children."
)
upload_date_current_flow = dateutil.parser.parse(flow1.upload_date)
upload_date_parent_flow = dateutil.parser.parse(
ignore_parameter_values_on_older_children,
Expand Down Expand Up @@ -579,7 +579,7 @@ def assert_flows_equal( # noqa: C901, PLR0912, PLR0913, PLR0915
params2 = set(flow2.parameters_meta_info)
if params1 != params2:
raise ValueError(
"Parameter list in meta info for parameters differ " "in the two flows.",
"Parameter list in meta info for parameters differ in the two flows.",
)
# iterating over the parameter's meta info list
for param in params1:
Expand Down
12 changes: 6 additions & 6 deletions openml/runs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
"OpenMLRun",
"OpenMLRunTrace",
"OpenMLTraceIteration",
"run_model_on_task",
"run_flow_on_task",
"delete_run",
"get_run",
"list_runs",
"get_runs",
"get_run_trace",
"run_exists",
"get_runs",
"initialize_model_from_run",
"initialize_model_from_trace",
"delete_run",
"list_runs",
"run_exists",
"run_flow_on_task",
"run_model_on_task",
]
Loading

0 comments on commit b9a2e80

Please sign in to comment.