Skip to content

Commit d6f8dc6

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent eee088c commit d6f8dc6

4 files changed

Lines changed: 22 additions & 9 deletions

File tree

src/core/parquet.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@
1212

1313
def map_arrow_type(arrow_type: pa.DataType) -> FeatureType:
1414
"""Map a PyArrow DataType to an OpenML FeatureType."""
15-
if pa.types.is_floating(arrow_type) or pa.types.is_integer(arrow_type) or pa.types.is_decimal(
16-
arrow_type
15+
if (
16+
pa.types.is_floating(arrow_type)
17+
or pa.types.is_integer(arrow_type)
18+
or pa.types.is_decimal(
19+
arrow_type,
20+
)
1721
):
1822
return FeatureType.NUMERIC
1923
if pa.types.is_boolean(arrow_type) or pa.types.is_dictionary(arrow_type):
@@ -51,7 +55,7 @@ def read_parquet_metadata(file_bytes: bytes) -> ParquetMeta:
5155

5256
schema = pf.schema_arrow
5357
num_rows = pf.metadata.num_rows
54-
md5 = hashlib.md5(file_bytes, usedforsecurity=False).hexdigest() # noqa: S324
58+
md5 = hashlib.md5(file_bytes, usedforsecurity=False).hexdigest()
5559

5660
# Read full table once to count per-column nulls
5761
table = pf.read()
@@ -66,7 +70,7 @@ def read_parquet_metadata(file_bytes: bytes) -> ParquetMeta:
6670
name=col_name,
6771
data_type=map_arrow_type(schema.field(col_name).type),
6872
number_of_missing_values=null_count,
69-
)
73+
),
7074
)
7175

7276
return ParquetMeta(

src/core/storage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import boto3
99
from botocore.exceptions import BotoCoreError, ClientError
1010

11-
from config import _load_configuration, _config_file
11+
from config import _config_file, _load_configuration
1212

1313
if TYPE_CHECKING:
1414
from pathlib import Path

src/schemas/datasets/upload.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
class DatasetUploadMetadata(BaseModel):
99
"""Metadata provided alongside the uploaded Parquet file."""
1010

11-
name: str = Field(description="Human-readable name of the dataset.", min_length=1, max_length=256)
11+
name: str = Field(
12+
description="Human-readable name of the dataset.", min_length=1, max_length=256
13+
)
1214
description: str = Field(description="Description of the dataset.", min_length=1)
1315
default_target_attribute: str = Field(
1416
default="",

tests/routers/openml/dataset_upload_test.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ def test_upload_unauthenticated(api_client_unauthenticated: TestClient) -> None:
8888

8989

9090
def test_upload_non_parquet_file(api_client_authenticated: TestClient) -> None:
91-
response = _upload(api_client_authenticated, file_bytes=b"col1,col2\n1,2\n", filename="data.csv")
91+
response = _upload(
92+
api_client_authenticated, file_bytes=b"col1,col2\n1,2\n", filename="data.csv"
93+
)
9294
assert response.status_code == HTTPStatus.BAD_REQUEST
9395
assert response.json()["detail"]["code"] == "110"
9496

@@ -100,7 +102,9 @@ def test_upload_invalid_parquet_bytes(api_client_authenticated: TestClient) -> N
100102

101103

102104
def test_upload_invalid_metadata_json(api_client_authenticated: TestClient) -> None:
103-
files = {"file": ("iris.parquet", io.BytesIO(_make_parquet_bytes()), "application/octet-stream")}
105+
files = {
106+
"file": ("iris.parquet", io.BytesIO(_make_parquet_bytes()), "application/octet-stream")
107+
}
104108
data = {"metadata": "NOT VALID JSON {{{"}
105109
response = api_client_authenticated.post("/datasets/upload", files=files, data=data)
106110
assert response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY
@@ -129,7 +133,10 @@ def test_upload_minio_failure_returns_500(api_client_authenticated: TestClient)
129133
file_bytes = _make_parquet_bytes()
130134

131135
with (
132-
patch("routers.openml.datasets.upload_to_minio", side_effect=RuntimeError("connection refused")),
136+
patch(
137+
"routers.openml.datasets.upload_to_minio",
138+
side_effect=RuntimeError("connection refused"),
139+
),
133140
patch("database.datasets.insert_file", return_value=99),
134141
patch("database.datasets.insert_dataset", return_value=42),
135142
):

0 commit comments

Comments
 (0)