Skip to content

Commit ca74d85

Browse files
author
Andrei Neagu
committed
revert
1 parent e44e780 commit ca74d85

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

services/dask-sidecar/src/simcore_service_dask_sidecar/file_utils.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
import aiofiles
1313
import aiofiles.tempfile
1414
import fsspec # type: ignore[import-untyped]
15-
from common_library.pydantic_networks_extension import FileUrlLegacy
16-
from pydantic import ByteSize, TypeAdapter
15+
from pydantic import ByteSize, FileUrl, TypeAdapter
1716
from pydantic.networks import AnyUrl
1817
from servicelib.logging_utils import LogLevelInt, LogMessageStr
1918
from settings_library.s3 import S3Settings
@@ -146,7 +145,7 @@ async def pull_file_from_remote(
146145
storage_kwargs = _s3fs_settings_from_s3_settings(s3_settings)
147146
await _copy_file(
148147
src_url,
149-
TypeAdapter(FileUrlLegacy).validate_python(dst_path.as_uri()),
148+
TypeAdapter(FileUrl).validate_python(dst_path.as_uri()),
150149
src_storage_cfg=cast(dict[str, Any], storage_kwargs),
151150
log_publishing_cb=log_publishing_cb,
152151
text_prefix=f"Downloading '{src_url.path.strip('/')}':",
@@ -216,7 +215,7 @@ async def _push_file_to_remote(
216215
storage_kwargs = _s3fs_settings_from_s3_settings(s3_settings)
217216

218217
await _copy_file(
219-
TypeAdapter(FileUrlLegacy).validate_python(file_to_upload.as_uri()),
218+
TypeAdapter(FileUrl).validate_python(file_to_upload.as_uri()),
220219
dst_url,
221220
dst_storage_cfg=cast(dict[str, Any], storage_kwargs),
222221
log_publishing_cb=log_publishing_cb,

services/dask-sidecar/tests/unit/test_file_utils.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import fsspec
1515
import pytest
1616
from faker import Faker
17-
from pydantic import AnyUrl, parse_obj_as
17+
from pydantic import AnyUrl, TypeAdapter, parse_obj_as
1818
from pytest_localftpserver.servers import ProcessFTPServer
1919
from pytest_mock.plugin import MockerFixture
2020
from settings_library.s3 import S3Settings
@@ -45,8 +45,8 @@ def s3_presigned_link_storage_kwargs(s3_settings: S3Settings) -> dict[str, Any]:
4545

4646
@pytest.fixture
4747
def ftp_remote_file_url(ftpserver: ProcessFTPServer, faker: Faker) -> AnyUrl:
48-
return parse_obj_as(
49-
AnyUrl, f"{ftpserver.get_login_data(style='url')}/{faker.file_name()}"
48+
return TypeAdapter(AnyUrl).validate_python(
49+
f"{ftpserver.get_login_data(style='url')}/{faker.file_name()}"
5050
)
5151

5252

@@ -56,8 +56,7 @@ async def s3_presigned_link_remote_file_url(
5656
aiobotocore_s3_client,
5757
faker: Faker,
5858
) -> AnyUrl:
59-
return parse_obj_as(
60-
AnyUrl,
59+
return TypeAdapter(AnyUrl).validate_python(
6160
await aiobotocore_s3_client.generate_presigned_url(
6261
"put_object",
6362
Params={"Bucket": s3_settings.S3_BUCKET_NAME, "Key": faker.file_name()},
@@ -68,7 +67,9 @@ async def s3_presigned_link_remote_file_url(
6867

6968
@pytest.fixture
7069
def s3_remote_file_url(s3_settings: S3Settings, faker: Faker) -> AnyUrl:
71-
return parse_obj_as(AnyUrl, f"s3://{s3_settings.S3_BUCKET_NAME}{faker.file_path()}")
70+
return TypeAdapter(AnyUrl).validate_python(
71+
f"s3://{s3_settings.S3_BUCKET_NAME}{faker.file_path()}"
72+
)
7273

7374

7475
@dataclass(frozen=True)

0 commit comments

Comments
 (0)