Skip to content

Commit b175f85

Browse files
committed
remove redundant webserver schemas
1 parent 2f2cbb6 commit b175f85

File tree

3 files changed

+5
-64
lines changed

3 files changed

+5
-64
lines changed
Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
11
from pathlib import Path
2-
from typing import Annotated, Any
2+
from typing import Annotated
33

44
from pydantic import BaseModel, Field
55

6-
from ..api_schemas_rpc_async_jobs.async_jobs import (
7-
AsyncJobGet,
8-
AsyncJobId,
9-
AsyncJobResult,
10-
AsyncJobStatus,
11-
)
126
from ..api_schemas_storage.data_export_async_jobs import DataExportTaskStartInput
137
from ..api_schemas_storage.storage_schemas import (
148
DEFAULT_NUMBER_OF_PATHS_PER_PAGE,
159
MAX_NUMBER_OF_PATHS_PER_PAGE,
1610
)
17-
from ..progress_bar import ProgressReport
1811
from ..projects_nodes_io import LocationID, StorageFileID
1912
from ..rest_pagination import (
2013
CursorQueryParameters,
2114
)
22-
from ._base import InputSchema, OutputSchema
15+
from ._base import InputSchema
2316

2417

2518
class StorageLocationPathParams(BaseModel):
@@ -51,48 +44,3 @@ def to_rpc_schema(self, location_id: LocationID) -> DataExportTaskStartInput:
5144
file_and_folder_ids=self.paths,
5245
location_id=location_id,
5346
)
54-
55-
56-
class AsyncJobLinks(OutputSchema):
57-
status_href: str
58-
abort_href: str
59-
result_href: str
60-
61-
62-
class StorageAsyncJobGet(OutputSchema):
63-
job_id: AsyncJobId
64-
links: AsyncJobLinks
65-
66-
@classmethod
67-
def from_rpc_schema(
68-
cls, *, async_job_rpc_get: AsyncJobGet, links: AsyncJobLinks
69-
) -> "StorageAsyncJobGet":
70-
return StorageAsyncJobGet(job_id=async_job_rpc_get.job_id, links=links)
71-
72-
73-
class StorageAsyncJobStatus(OutputSchema):
74-
job_id: AsyncJobId
75-
progress: ProgressReport
76-
done: bool
77-
links: AsyncJobLinks
78-
79-
@classmethod
80-
def from_rpc_schema(
81-
cls, *, async_job_rpc_status: AsyncJobStatus, links: AsyncJobLinks
82-
) -> "StorageAsyncJobStatus":
83-
return StorageAsyncJobStatus(
84-
job_id=async_job_rpc_status.job_id,
85-
progress=async_job_rpc_status.progress,
86-
done=async_job_rpc_status.done,
87-
links=links,
88-
)
89-
90-
91-
class StorageAsyncJobResult(OutputSchema):
92-
result: Any | None
93-
94-
@classmethod
95-
def from_rpc_schema(
96-
cls, async_job_rpc_result: AsyncJobResult
97-
) -> "StorageAsyncJobResult":
98-
return StorageAsyncJobResult(result=async_job_rpc_result.result)

services/web/server/tests/unit/with_dbs/01/storage/test_storage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from aiohttp.test_utils import TestClient
1212
from faker import Faker
1313
from fastapi_pagination.cursor import CursorPage
14+
from models_library.api_schemas_long_running_tasks.tasks import TaskGet
1415
from models_library.api_schemas_rpc_async_jobs.async_jobs import AsyncJobGet, AsyncJobId
1516
from models_library.api_schemas_storage.storage_schemas import (
1617
DatasetMetaDataGet,
@@ -19,7 +20,6 @@
1920
FileUploadSchema,
2021
PathMetaDataGet,
2122
)
22-
from models_library.api_schemas_webserver.storage import StorageAsyncJobGet
2323
from models_library.projects_nodes_io import LocationID, StorageFileID
2424
from pydantic import TypeAdapter
2525
from pytest_mock import MockerFixture
@@ -146,7 +146,7 @@ async def test_compute_path_size(
146146
resp = await client.post(f"{url}")
147147
data, error = await assert_status(resp, expected)
148148
if not error:
149-
TypeAdapter(StorageAsyncJobGet).validate_python(data)
149+
TypeAdapter(TaskGet).validate_python(data)
150150

151151

152152
@pytest.mark.parametrize(

services/web/server/tests/unit/with_dbs/01/storage/test_storage_rpc.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@
3232
)
3333
from models_library.api_schemas_webserver._base import OutputSchema
3434
from models_library.api_schemas_webserver.storage import (
35-
AsyncJobLinks,
3635
DataExportPost,
37-
StorageAsyncJobGet,
3836
)
3937
from models_library.generics import Envelope
4038
from models_library.progress_bar import ProgressReport
@@ -236,13 +234,8 @@ async def test_get_async_job_result(
236234
[
237235
(
238236
[
239-
StorageAsyncJobGet(
237+
AsyncJobGet(
240238
job_id=AsyncJobId(_faker.uuid4()),
241-
links=AsyncJobLinks(
242-
status_href=_faker.uri(),
243-
abort_href=_faker.uri(),
244-
result_href=_faker.uri(),
245-
),
246239
)
247240
],
248241
status.HTTP_200_OK,

0 commit comments

Comments
 (0)