Skip to content

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

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Expand Up @@ -7,20 +7,20 @@ files: |
)/.*\.py$
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.3
rev: v0.12.1
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.16.1
hooks:
- id: mypy
additional_dependencies:
- types-requests
- types-python-dateutil
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.4
rev: 0.33.1
hooks:
- id: check-github-workflows
files: '^github/workflows/.*\.ya?ml$'
Expand Down
32 changes: 16 additions & 16 deletions openml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,33 +91,33 @@ 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__",
]
6 changes: 3 additions & 3 deletions openml/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,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


Expand Down Expand Up @@ -514,10 +514,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/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 @@ -123,7 +123,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
2 changes: 1 addition & 1 deletion openml/evaluations/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def __list_evaluations(api_call: str) -> list[OpenMLEvaluation]:
# 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
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",
]
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",
]
8 changes: 4 additions & 4 deletions openml/flows/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def extension(self) -> Extension:
"""The extension of the flow (e.g., sklearn)."""
if self._extension is None:
self._extension = cast(
Extension, get_extension_by_flow(self, raise_if_no_extension=True)
"Extension", get_extension_by_flow(self, raise_if_no_extension=True)
)

return self._extension
Expand Down Expand Up @@ -435,7 +435,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 @@ -445,7 +445,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 @@ -517,7 +517,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
6 changes: 3 additions & 3 deletions openml/flows/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,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
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",
]
12 changes: 6 additions & 6 deletions openml/runs/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def to_filesystem(
model.
"""
if self.data_content is None or self.model is None:
raise ValueError("Run should have been executed (and contain " "model / predictions)")
raise ValueError("Run should have been executed (and contain model / predictions)")
directory = Path(directory)
directory.mkdir(exist_ok=True, parents=True)

Expand Down Expand Up @@ -517,7 +517,7 @@ def get_metric_fn(self, sklearn_fn: Callable, kwargs: dict | None = None) -> np.
# TODO: make this a stream reader
else:
raise ValueError(
"Run should have been locally executed or " "contain outputfile reference.",
"Run should have been locally executed or contain outputfile reference.",
)

# Need to know more about the task to compute scores correctly
Expand All @@ -528,11 +528,11 @@ def get_metric_fn(self, sklearn_fn: Callable, kwargs: dict | None = None) -> np.
task.task_type_id in [TaskType.SUPERVISED_CLASSIFICATION, TaskType.LEARNING_CURVE]
and "correct" not in attribute_names
):
raise ValueError('Attribute "correct" should be set for ' "classification task runs")
raise ValueError('Attribute "correct" should be set for classification task runs')
if task.task_type_id == TaskType.SUPERVISED_REGRESSION and "truth" not in attribute_names:
raise ValueError('Attribute "truth" should be set for ' "regression task runs")
raise ValueError('Attribute "truth" should be set for regression task runs')
if task.task_type_id != TaskType.CLUSTERING and "prediction" not in attribute_names:
raise ValueError('Attribute "predict" should be set for ' "supervised task runs")
raise ValueError('Attribute "predict" should be set for supervised task runs')

def _attribute_list_to_dict(attribute_list): # type: ignore
# convenience function: Creates a mapping to map from the name of
Expand Down Expand Up @@ -566,7 +566,7 @@ def _attribute_list_to_dict(attribute_list): # type: ignore
pred = predictions_arff["attributes"][predicted_idx][1]
corr = predictions_arff["attributes"][correct_idx][1]
raise ValueError(
"Predicted and Correct do not have equal values:" f" {pred!s} Vs. {corr!s}",
f"Predicted and Correct do not have equal values: {pred!s} Vs. {corr!s}",
)

# TODO: these could be cached
Expand Down
3 changes: 1 addition & 2 deletions openml/runs/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,7 @@ def generate(
raise ValueError("Trace content is empty.")
if len(attributes) != len(content[0]):
raise ValueError(
"Trace_attributes and trace_content not compatible:"
f" {attributes} vs {content[0]}",
f"Trace_attributes and trace_content not compatible: {attributes} vs {content[0]}",
)

return cls._trace_from_arff_struct(
Expand Down
4 changes: 2 additions & 2 deletions openml/setups/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from .setup import OpenMLParameter, OpenMLSetup

__all__ = [
"OpenMLSetup",
"OpenMLParameter",
"OpenMLSetup",
"get_setup",
"initialize_model",
"list_setups",
"setup_exists",
"initialize_model",
]
4 changes: 2 additions & 2 deletions openml/study/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
from .study import OpenMLBenchmarkSuite, OpenMLStudy

__all__ = [
"OpenMLStudy",
"OpenMLBenchmarkSuite",
"OpenMLStudy",
"attach_to_study",
"attach_to_suite",
"create_benchmark_suite",
Expand All @@ -33,6 +33,6 @@
"get_suite",
"list_studies",
"list_suites",
"update_suite_status",
"update_study_status",
"update_suite_status",
]
1 change: 0 additions & 1 deletion openml/study/functions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# License: BSD 3-Clause
# ruff: noqa: PLR0913
from __future__ import annotations

import warnings
Expand Down
14 changes: 7 additions & 7 deletions openml/tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
)

__all__ = [
"OpenMLTask",
"OpenMLSupervisedTask",
"OpenMLClusteringTask",
"OpenMLRegressionTask",
"OpenMLClassificationTask",
"OpenMLClusteringTask",
"OpenMLLearningCurveTask",
"OpenMLRegressionTask",
"OpenMLSplit",
"OpenMLSupervisedTask",
"OpenMLTask",
"TaskType",
"create_task",
"delete_task",
"get_task",
"get_tasks",
"list_tasks",
"OpenMLSplit",
"TaskType",
"delete_task",
]
4 changes: 2 additions & 2 deletions openml/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,9 @@ def create_request_response(


__all__ = [
"TestBase",
"SimpleImputer",
"CustomImputer",
"SimpleImputer",
"TestBase",
"check_task_existence",
"create_request_response",
]