Skip to content

Commit 3f91e30

Browse files
remove deprecated
1 parent 10a80b3 commit 3f91e30

File tree

19 files changed

+42
-38
lines changed

19 files changed

+42
-38
lines changed

packages/dask-task-models-library/src/dask_task_models_library/container_tasks/io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def from_task_output(
175175
msg = f"Could not locate '{output_key}' in {output_data_file}"
176176
raise ValueError(msg)
177177

178-
return cls.parse_obj(data)
178+
return cls.model_validate(data)
179179

180180
model_config = ConfigDict(
181181
json_schema_extra={

packages/dask-task-models-library/tests/container_tasks/test_io.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_io_models_examples(model_cls, model_cls_examples):
3030
for name, example in model_cls_examples.items():
3131
print(name, ":", pformat(example))
3232

33-
model_instance = model_cls.parse_obj(example)
33+
model_instance = model_cls.model_validate(example)
3434

3535
assert model_instance, f"Failed with {name}"
3636
print(name, ":", model_instance)
@@ -73,7 +73,7 @@ def test_create_task_output_from_task_with_optional_fields_as_required(
7373
"examples"
7474
]:
7575

76-
task_output_schema = TaskOutputDataSchema.parse_obj(schema_example)
76+
task_output_schema = TaskOutputDataSchema.model_validate(schema_example)
7777
outputs_file_name = _create_fake_outputs(
7878
task_output_schema, tmp_path, optional_fields_set, faker
7979
)
@@ -94,7 +94,7 @@ def test_create_task_output_from_task_with_optional_fields_as_required(
9494
def test_create_task_output_from_task_throws_when_there_are_missing_files(
9595
tmp_path: Path, faker: Faker
9696
):
97-
task_output_schema = TaskOutputDataSchema.parse_obj(
97+
task_output_schema = TaskOutputDataSchema.model_validate(
9898
{
9999
"required_file_output": {
100100
"required": True,
@@ -115,7 +115,7 @@ def test_create_task_output_from_task_throws_when_there_are_missing_files(
115115
def test_create_task_output_from_task_does_not_throw_when_there_are_optional_missing_files(
116116
tmp_path: Path, faker: Faker
117117
):
118-
task_output_schema = TaskOutputDataSchema.parse_obj(
118+
task_output_schema = TaskOutputDataSchema.model_validate(
119119
{
120120
"optional_file_output": {
121121
"required": False,
@@ -136,7 +136,7 @@ def test_create_task_output_from_task_does_not_throw_when_there_are_optional_mis
136136
def test_create_task_output_from_task_throws_when_there_are_entries(
137137
tmp_path: Path, faker: Faker
138138
):
139-
task_output_schema = TaskOutputDataSchema.parse_obj(
139+
task_output_schema = TaskOutputDataSchema.model_validate(
140140
{
141141
"some_output": {
142142
"required": True,
@@ -155,7 +155,7 @@ def test_create_task_output_from_task_throws_when_there_are_entries(
155155
def test_create_task_output_from_task_does_not_throw_when_there_are_optional_entries(
156156
tmp_path: Path, faker: Faker
157157
):
158-
task_output_schema = TaskOutputDataSchema.parse_obj(
158+
task_output_schema = TaskOutputDataSchema.model_validate(
159159
{
160160
"some_output": {
161161
"required": False,
@@ -184,6 +184,6 @@ def test_objects_are_compatible_with_dask_requirements(model_cls, model_cls_exam
184184
for name, example in model_cls_examples.items():
185185
print(name, ":", pformat(example))
186186

187-
model_instance = model_cls.parse_obj(example)
187+
model_instance = model_cls.model_validate(example)
188188
reloaded_instance = loads(dumps(model_instance))
189189
assert reloaded_instance == model_instance

packages/pytest-simcore/src/pytest_simcore/docker_registry.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ def external_registry_settings(
106106
if external_envfile_dict:
107107
config = {
108108
field: external_envfile_dict.get(field, None)
109-
for field in RegistrySettings.__fields__
109+
for field in RegistrySettings.model_fields
110110
}
111-
return RegistrySettings.parse_obj(config)
111+
return RegistrySettings.model_validate(config)
112112
return None
113113

114114

packages/pytest-simcore/src/pytest_simcore/pydantic_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def test_model_examples(
6464
model_cls: type[BaseModel], example_name: int, example_data: Any
6565
):
6666
print(example_name, ":", json.dumps(example_data))
67-
assert model_cls.parse_obj(example_data)
67+
assert model_cls.model_validate(example_data)
6868
"""
6969

7070
def _is_model_cls(obj) -> bool:

packages/pytest-simcore/src/pytest_simcore/rabbit_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def rabbit_env_vars_dict(
5656
async def rabbit_settings(rabbit_env_vars_dict: EnvVarsDict) -> RabbitSettings:
5757
"""Returns the settings of a rabbit service that is up and responsive"""
5858

59-
settings = RabbitSettings.parse_obj(rabbit_env_vars_dict)
59+
settings = RabbitSettings.model_validate(rabbit_env_vars_dict)
6060
await wait_till_rabbit_responsive(settings.dsn)
6161
return settings
6262

packages/pytest-simcore/src/pytest_simcore/services_api_mocks_for_aiohttp_clients.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def create_computation_cb(url, **kwargs) -> CallbackResult:
107107
"62237c33-8d6c-4709-aa92-c3cf693dd6d2",
108108
],
109109
}
110-
returned_computation = ComputationTask.parse_obj(
110+
returned_computation = ComputationTask.model_validate(
111111
ComputationTask.model_config["json_schema_extra"]["examples"][0]
112112
).copy(
113113
update={
@@ -131,7 +131,7 @@ def get_computation_cb(url, **kwargs) -> CallbackResult:
131131
state = RunningState.NOT_STARTED
132132
pipeline: dict[str, list[str]] = FULL_PROJECT_PIPELINE_ADJACENCY
133133
node_states = FULL_PROJECT_NODE_STATES
134-
returned_computation = ComputationTask.parse_obj(
134+
returned_computation = ComputationTask.model_validate(
135135
ComputationTask.model_config["json_schema_extra"]["examples"][0]
136136
).copy(
137137
update={
@@ -169,7 +169,7 @@ def list_clusters_cb(url, **kwargs) -> CallbackResult:
169169
body=json.dumps(
170170
[
171171
json.loads(
172-
Cluster.parse_obj(
172+
Cluster.model_validate(
173173
random.choice(
174174
Cluster.model_config["json_schema_extra"]["examples"]
175175
)
@@ -187,7 +187,7 @@ def get_cluster_cb(url, **kwargs) -> CallbackResult:
187187
return CallbackResult(
188188
status=200,
189189
payload=json.loads(
190-
Cluster.parse_obj(
190+
Cluster.model_validate(
191191
{
192192
**random.choice(
193193
Cluster.model_config["json_schema_extra"]["examples"]
@@ -218,7 +218,7 @@ def patch_cluster_cb(url, **kwargs) -> CallbackResult:
218218
return CallbackResult(
219219
status=200,
220220
payload=json.loads(
221-
Cluster.parse_obj(
221+
Cluster.model_validate(
222222
{
223223
**random.choice(
224224
Cluster.model_config["json_schema_extra"]["examples"]

packages/service-integration/src/service_integration/cli/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def main(
6262
overrides["COMPOSE_VERSION"] = compose_version
6363

6464
# save states
65-
ctx.settings = AppSettings.parse_obj(overrides) # type: ignore[attr-defined] # pylint:disable=no-member
65+
ctx.settings = AppSettings.model_validate(overrides) # type: ignore[attr-defined] # pylint:disable=no-member
6666

6767

6868
#

packages/service-library/src/servicelib/aiohttp/long_running_tasks/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ async def _start(session: ClientSession, url: URL, json: RequestBody | None) ->
3535
data, error = unwrap_envelope(await response.json())
3636
assert not error # nosec
3737
assert data is not None # nosec
38-
return TaskGet.parse_obj(data)
38+
return TaskGet.model_validate(data)
3939

4040

4141
@retry(**_DEFAULT_AIOHTTP_RETRY_POLICY)
@@ -57,7 +57,7 @@ async def _wait_for_completion(
5757
data, error = unwrap_envelope(await response.json())
5858
assert not error # nosec
5959
assert data is not None # nosec
60-
task_status = TaskStatus.parse_obj(data)
60+
task_status = TaskStatus.model_validate(data)
6161
yield task_status.task_progress
6262
if not task_status.done:
6363
await asyncio.sleep(

packages/service-library/src/servicelib/aiohttp/requests_validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def parse_request_path_parameters_as(
140140
use_error_v1=use_enveloped_error_v1,
141141
):
142142
data = dict(request.match_info)
143-
return parameters_schema_cls.parse_obj(data)
143+
return parameters_schema_cls.model_validate(data)
144144

145145

146146
def parse_request_query_parameters_as(

packages/service-library/src/servicelib/deferred_tasks/_redis_task_tracker.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ async def get(self, task_uid: TaskUID) -> TaskScheduleModel | None:
4343
return await self._get_raw(_get_key(task_uid))
4444

4545
async def save(self, task_uid: TaskUID, task_schedule: TaskScheduleModel) -> None:
46-
await self.redis_client_sdk.redis.set(_get_key(task_uid), task_schedule.json())
46+
await self.redis_client_sdk.redis.set(
47+
_get_key(task_uid), task_schedule.model_dump_json()
48+
)
4749

4850
async def remove(self, task_uid: TaskUID) -> None:
4951
await self.redis_client_sdk.redis.delete(_get_key(task_uid))

0 commit comments

Comments
 (0)