Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #1383

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -7,20 +7,20 @@ files: |
)/.*\.py$
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.3
rev: v0.11.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --no-cache]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
rev: v1.15.0
hooks:
- id: mypy
additional_dependencies:
- types-requests
- types-python-dateutil
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.4
rev: 0.31.3
hooks:
- id: check-github-workflows
files: '^github/workflows/.*\.ya?ml$'
32 changes: 16 additions & 16 deletions openml/__init__.py
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions openml/config.py
Original file line number Diff line number Diff line change
@@ -254,8 +254,8 @@ def stop_using_configuration_for_example(cls) -> None:
global server # noqa: PLW0603
global apikey # noqa: PLW0603

server = cast(str, cls._last_used_server)
apikey = cast(str, cls._last_used_key)
server = cast("str", cls._last_used_server)
apikey = cast("str", cls._last_used_key)
cls._start_last_called = False


@@ -513,10 +513,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
@@ -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
@@ -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):
2 changes: 1 addition & 1 deletion openml/datasets/dataset.py
Original file line number Diff line number Diff line change
@@ -448,7 +448,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

4 changes: 2 additions & 2 deletions openml/datasets/functions.py
Original file line number Diff line number Diff line change
@@ -72,7 +72,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"]

@@ -177,7 +177,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]
2 changes: 1 addition & 1 deletion openml/evaluations/__init__.py
Original file line number Diff line number Diff line change
@@ -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
@@ -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",
14 changes: 7 additions & 7 deletions openml/evaluations/functions.py
Original file line number Diff line number Diff line change
@@ -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(
@@ -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"]


@@ -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 [
@@ -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
4 changes: 2 additions & 2 deletions openml/extensions/__init__.py
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@

__all__ = [
"Extension",
"register_extension",
"get_extension_by_model",
"get_extension_by_flow",
"get_extension_by_model",
"register_extension",
]
13 changes: 6 additions & 7 deletions openml/extensions/sklearn/extension.py
Original file line number Diff line number Diff line change
@@ -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:
@@ -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.",
)

################################################################################################
@@ -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
@@ -1780,10 +1779,10 @@ def _prediction_to_probabilities(
# to handle the case when dataset is numpy and categories are encoded
# however the class labels stored in task are still categories
if isinstance(y_train, np.ndarray) and isinstance(
cast(List, task.class_labels)[0],
cast("List", task.class_labels)[0],
str,
):
model_classes = [cast(List[str], task.class_labels)[i] for i in model_classes]
model_classes = [cast("List[str]", task.class_labels)[i] for i in model_classes]

modelpredict_start_cputime = time.process_time()
modelpredict_start_walltime = time.time()
@@ -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]
8 changes: 4 additions & 4 deletions openml/flows/__init__.py
Original file line number Diff line number Diff line change
@@ -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
@@ -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
@@ -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)
@@ -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
16 changes: 8 additions & 8 deletions openml/flows/functions.py
Original file line number Diff line number Diff line change
@@ -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
@@ -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]
@@ -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],
@@ -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,
@@ -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:
Loading