Skip to content

Commit 79dc0e1

Browse files
author
Andrei Neagu
committed
revert adapter pattern
1 parent c28d1cc commit 79dc0e1

File tree

3 files changed

+5
-19
lines changed

3 files changed

+5
-19
lines changed

packages/models-library/src/models_library/api_schemas_dynamic_scheduler/dynamic_services.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
from typing import Final
2-
31
from models_library.api_schemas_directorv2.dynamic_services import DynamicServiceCreate
42
from models_library.projects import ProjectID
53
from models_library.projects_nodes_io import NodeID
64
from models_library.resource_tracker import HardwareInfo, PricingInfo
75
from models_library.services_resources import ServiceResourcesDictHelpers
86
from models_library.users import UserID
97
from models_library.wallets import WalletInfo
10-
from pydantic import BaseModel, ConfigDict, TypeAdapter
8+
from pydantic import BaseModel, ConfigDict
119

1210

1311
class DynamicServiceStart(DynamicServiceCreate):
@@ -37,11 +35,6 @@ class DynamicServiceStart(DynamicServiceCreate):
3735
)
3836

3937

40-
DynamicServiceStartAdapter: Final[TypeAdapter[DynamicServiceStart]] = TypeAdapter(
41-
DynamicServiceStart
42-
)
43-
44-
4538
class DynamicServiceStop(BaseModel):
4639
user_id: UserID
4740
project_id: ProjectID
@@ -60,8 +53,3 @@ class DynamicServiceStop(BaseModel):
6053
}
6154
}
6255
)
63-
64-
65-
DynamicServiceStopAdapter: Final[TypeAdapter[DynamicServiceStop]] = TypeAdapter(
66-
DynamicServiceStop
67-
)

services/dynamic-scheduler/tests/unit/api_rpc/test_api_rpc__services.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from models_library.api_schemas_directorv2.dynamic_services import DynamicServiceGet
1313
from models_library.api_schemas_dynamic_scheduler.dynamic_services import (
1414
DynamicServiceStart,
15-
DynamicServiceStartAdapter,
1615
DynamicServiceStop,
1716
)
1817
from models_library.api_schemas_webserver.projects_nodes import (
@@ -183,7 +182,7 @@ async def test_get_state(
183182
@pytest.fixture
184183
def dynamic_service_start() -> DynamicServiceStart:
185184
# one for legacy and one for new style?
186-
return DynamicServiceStartAdapter.validate_python(
185+
return TypeAdapter(DynamicServiceStart).validate_python(
187186
DynamicServiceStart.model_config["json_schema_extra"]["example"]
188187
)
189188

services/dynamic-scheduler/tests/unit/conftest.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
import pytest
55
from models_library.api_schemas_dynamic_scheduler.dynamic_services import (
66
DynamicServiceStart,
7-
DynamicServiceStartAdapter,
87
DynamicServiceStop,
9-
DynamicServiceStopAdapter,
108
)
119
from models_library.projects_nodes_io import NodeID
10+
from pydantic import TypeAdapter
1211

1312

1413
@pytest.fixture
@@ -18,7 +17,7 @@ def _(node_id: NodeID) -> DynamicServiceStart:
1817
DynamicServiceStart.model_config["json_schema_extra"]["example"]
1918
)
2019
dict_data["service_uuid"] = f"{node_id}"
21-
return DynamicServiceStartAdapter.validate_python(dict_data)
20+
return TypeAdapter(DynamicServiceStart).validate_python(dict_data)
2221

2322
return _
2423

@@ -30,6 +29,6 @@ def _(node_id: NodeID) -> DynamicServiceStop:
3029
DynamicServiceStop.model_config["json_schema_extra"]["example"]
3130
)
3231
dict_data["node_id"] = f"{node_id}"
33-
return DynamicServiceStopAdapter.validate_python(dict_data)
32+
return TypeAdapter(DynamicServiceStop).validate_python(dict_data)
3433

3534
return _

0 commit comments

Comments
 (0)