Skip to content

Commit d27914b

Browse files
author
Andrei Neagu
committed
removed type IDStr form description
1 parent 60132fe commit d27914b

File tree

22 files changed

+73
-109
lines changed

22 files changed

+73
-109
lines changed

packages/service-library/src/servicelib/archiving_utils/_interface_7zip.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from typing import Final
1111

1212
import tqdm
13-
from models_library.basic_types import IDStr
1413
from pydantic import NonNegativeInt
1514
from servicelib.logging_utils import log_catch
1615
from tqdm.contrib.logging import tqdm_logging_redirect
@@ -199,7 +198,7 @@ async def archive_dir(
199198
) -> None:
200199
if progress_bar is None:
201200
progress_bar = ProgressBarData(
202-
num_steps=1, description=IDStr(f"compressing {dir_to_compress.name}")
201+
num_steps=1, description=f"compressing {dir_to_compress.name}"
203202
)
204203

205204
options = " ".join(
@@ -223,7 +222,7 @@ async def archive_dir(
223222

224223
async with AsyncExitStack() as exit_stack:
225224
sub_progress = await exit_stack.enter_async_context(
226-
progress_bar.sub_progress(folder_size_bytes, description=IDStr("..."))
225+
progress_bar.sub_progress(folder_size_bytes, description="...")
227226
)
228227

229228
tqdm_progress = exit_stack.enter_context(
@@ -290,7 +289,7 @@ async def unarchive_dir(
290289
) -> set[Path]:
291290
if progress_bar is None:
292291
progress_bar = ProgressBarData(
293-
num_steps=1, description=IDStr(f"extracting {archive_to_extract.name}")
292+
num_steps=1, description=f"extracting {archive_to_extract.name}"
294293
)
295294

296295
# get archive information
@@ -304,7 +303,7 @@ async def unarchive_dir(
304303

305304
async with AsyncExitStack() as exit_stack:
306305
sub_prog = await exit_stack.enter_async_context(
307-
progress_bar.sub_progress(steps=total_bytes, description=IDStr("..."))
306+
progress_bar.sub_progress(steps=total_bytes, description="...")
308307
)
309308

310309
tqdm_progress = exit_stack.enter_context(

packages/service-library/src/servicelib/fastapi/docker_utils.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from typing import Final
44

55
import httpx
6-
from models_library.basic_types import IDStr
76
from models_library.docker import DockerGenericTag
87
from pydantic import ByteSize, TypeAdapter, ValidationError
98
from settings_library.docker_registry import RegistrySettings
@@ -129,9 +128,7 @@ async def pull_images(
129128
num_steps=images_total_size,
130129
progress_report_cb=progress_cb,
131130
progress_unit="Byte",
132-
description=IDStr(
133-
f"pulling {len(images)} images",
134-
),
131+
description=f"pulling {len(images)} images",
135132
) as pbar:
136133

137134
await asyncio.gather(

packages/service-library/src/servicelib/progress_bar.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from inspect import isawaitable
55
from typing import Final, Optional, Protocol, runtime_checkable
66

7-
from models_library.basic_types import IDStr
87
from models_library.progress_bar import (
98
ProgressReport,
109
ProgressStructuredMessage,
@@ -84,7 +83,7 @@ async def main_fct():
8483
"description": "Optionally defines the step relative weight (defaults to steps of equal weights)"
8584
},
8685
)
87-
description: IDStr = field(metadata={"description": "define the progress name"})
86+
description: str = field(metadata={"description": "define the progress name"})
8887
progress_unit: ProgressUnit | None = None
8988
progress_report_cb: AsyncReportCB | ReportCB | None = None
9089
_current_steps: float = _INITIAL_VALUE
@@ -210,7 +209,7 @@ async def finish(self) -> None:
210209
def sub_progress(
211210
self,
212211
steps: int,
213-
description: IDStr,
212+
description: str,
214213
step_weights: list[float] | None = None,
215214
progress_unit: ProgressUnit | None = None,
216215
) -> "ProgressBarData":

packages/service-library/tests/test_progress_bar.py

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import pytest
1111
from faker import Faker
12-
from models_library.basic_types import IDStr
1312
from models_library.progress_bar import ProgressReport, ProgressStructuredMessage
1413
from pydantic import ValidationError
1514
from pytest_mock import MockerFixture
@@ -55,7 +54,7 @@ async def test_progress_bar_progress_report_cb(
5554
num_steps=outer_num_steps,
5655
progress_report_cb=mocked_cb,
5756
progress_unit="Byte",
58-
description=IDStr(faker.pystr()),
57+
description=faker.pystr(),
5958
) as root:
6059
assert root.num_steps == outer_num_steps
6160
assert root.step_weights is None # i.e. all steps have equal weight
@@ -97,7 +96,7 @@ async def test_progress_bar_progress_report_cb(
9796
# 2nd step is a sub progress bar of 10 steps
9897
inner_num_steps_step2 = 100
9998
async with root.sub_progress(
100-
steps=inner_num_steps_step2, description=IDStr(faker.pystr())
99+
steps=inner_num_steps_step2, description=faker.pystr()
101100
) as sub:
102101
assert sub._current_steps == pytest.approx(0) # noqa: SLF001
103102
assert root._current_steps == pytest.approx(1) # noqa: SLF001
@@ -126,7 +125,7 @@ async def test_progress_bar_progress_report_cb(
126125
# 3rd step is another subprogress of 50 steps
127126
inner_num_steps_step3 = 50
128127
async with root.sub_progress(
129-
steps=inner_num_steps_step3, description=IDStr(faker.pystr())
128+
steps=inner_num_steps_step3, description=faker.pystr()
130129
) as sub:
131130
assert sub._current_steps == pytest.approx(0) # noqa: SLF001
132131
assert root._current_steps == pytest.approx(2) # noqa: SLF001
@@ -148,7 +147,7 @@ async def test_progress_bar_progress_report_cb(
148147
def test_creating_progress_bar_with_invalid_unit_fails(faker: Faker):
149148
with pytest.raises(ValidationError):
150149
ProgressBarData(
151-
num_steps=321, progress_unit="invalid", description=IDStr(faker.pystr())
150+
num_steps=321, progress_unit="invalid", description=faker.pystr()
152151
)
153152

154153

@@ -159,7 +158,7 @@ async def test_progress_bar_always_reports_0_on_creation_and_1_on_finish(
159158
progress_bar = ProgressBarData(
160159
num_steps=num_steps,
161160
progress_report_cb=mocked_progress_bar_cb,
162-
description=IDStr(faker.pystr()),
161+
description=faker.pystr(),
163162
)
164163
assert progress_bar._current_steps == _INITIAL_VALUE # noqa: SLF001
165164
async with progress_bar as root:
@@ -207,7 +206,7 @@ async def test_progress_bar_always_reports_1_on_finish(
207206
progress_bar = ProgressBarData(
208207
num_steps=num_steps,
209208
progress_report_cb=mocked_progress_bar_cb,
210-
description=IDStr(faker.pystr()),
209+
description=faker.pystr(),
211210
)
212211
assert progress_bar._current_steps == _INITIAL_VALUE # noqa: SLF001
213212
async with progress_bar as root:
@@ -249,7 +248,7 @@ async def test_progress_bar_always_reports_1_on_finish(
249248

250249

251250
async def test_set_progress(caplog: pytest.LogCaptureFixture, faker: Faker):
252-
async with ProgressBarData(num_steps=50, description=IDStr(faker.pystr())) as root:
251+
async with ProgressBarData(num_steps=50, description=faker.pystr()) as root:
253252
assert root._current_steps == pytest.approx(0) # noqa: SLF001
254253
assert root.num_steps == 50
255254
assert root.step_weights is None
@@ -264,7 +263,7 @@ async def test_set_progress(caplog: pytest.LogCaptureFixture, faker: Faker):
264263

265264

266265
async def test_reset_progress(caplog: pytest.LogCaptureFixture, faker: Faker):
267-
async with ProgressBarData(num_steps=50, description=IDStr(faker.pystr())) as root:
266+
async with ProgressBarData(num_steps=50, description=faker.pystr()) as root:
268267
assert root._current_steps == pytest.approx(0) # noqa: SLF001
269268
assert root.num_steps == 50
270269
assert root.step_weights is None
@@ -292,43 +291,41 @@ async def test_reset_progress(caplog: pytest.LogCaptureFixture, faker: Faker):
292291

293292
async def test_concurrent_progress_bar(faker: Faker):
294293
async def do_something(root: ProgressBarData):
295-
async with root.sub_progress(steps=50, description=IDStr(faker.pystr())) as sub:
294+
async with root.sub_progress(steps=50, description=faker.pystr()) as sub:
296295
assert sub.num_steps == 50
297296
assert sub.step_weights is None
298297
assert sub._current_steps == 0 # noqa: SLF001
299298
for n in range(50):
300299
await sub.update()
301300
assert sub._current_steps == (n + 1) # noqa: SLF001
302301

303-
async with ProgressBarData(num_steps=12, description=IDStr(faker.pystr())) as root:
302+
async with ProgressBarData(num_steps=12, description=faker.pystr()) as root:
304303
assert root._current_steps == pytest.approx(0) # noqa: SLF001
305304
assert root.step_weights is None
306305
await asyncio.gather(*[do_something(root) for n in range(12)])
307306
assert root._current_steps == pytest.approx(12) # noqa: SLF001
308307

309308

310309
async def test_too_many_sub_progress_bars_raises(faker: Faker):
311-
async with ProgressBarData(num_steps=2, description=IDStr(faker.pystr())) as root:
310+
async with ProgressBarData(num_steps=2, description=faker.pystr()) as root:
312311
assert root.num_steps == 2
313312
assert root.step_weights is None
314-
async with root.sub_progress(steps=50, description=IDStr(faker.pystr())) as sub:
313+
async with root.sub_progress(steps=50, description=faker.pystr()) as sub:
315314
for _ in range(50):
316315
await sub.update()
317-
async with root.sub_progress(steps=50, description=IDStr(faker.pystr())) as sub:
316+
async with root.sub_progress(steps=50, description=faker.pystr()) as sub:
318317
for _ in range(50):
319318
await sub.update()
320319

321320
with pytest.raises(RuntimeError):
322-
async with root.sub_progress(
323-
steps=50, description=IDStr(faker.pystr())
324-
) as sub:
321+
async with root.sub_progress(steps=50, description=faker.pystr()) as sub:
325322
...
326323

327324

328325
async def test_too_many_updates_does_not_raise_but_show_warning_with_stack(
329326
caplog: pytest.LogCaptureFixture, faker: Faker
330327
):
331-
async with ProgressBarData(num_steps=2, description=IDStr(faker.pystr())) as root:
328+
async with ProgressBarData(num_steps=2, description=faker.pystr()) as root:
332329
assert root.num_steps == 2
333330
assert root.step_weights is None
334331
await root.update()
@@ -344,7 +341,7 @@ async def test_weighted_progress_bar(mocked_progress_bar_cb: mock.Mock, faker: F
344341
num_steps=outer_num_steps,
345342
step_weights=[1, 3, 1],
346343
progress_report_cb=mocked_progress_bar_cb,
347-
description=IDStr(faker.pystr()),
344+
description=faker.pystr(),
348345
) as root:
349346
mocked_progress_bar_cb.assert_called_once_with(
350347
ProgressReport(
@@ -399,7 +396,7 @@ async def test_weighted_progress_bar_with_weighted_sub_progress(
399396
num_steps=outer_num_steps,
400397
step_weights=[1, 3, 1],
401398
progress_report_cb=mocked_progress_bar_cb,
402-
description=IDStr(faker.pystr()),
399+
description=faker.pystr(),
403400
) as root:
404401
mocked_progress_bar_cb.assert_called_once_with(
405402
ProgressReport(
@@ -426,7 +423,7 @@ async def test_weighted_progress_bar_with_weighted_sub_progress(
426423

427424
# 2nd step is a sub progress bar of 5 steps
428425
async with root.sub_progress(
429-
steps=5, step_weights=[2, 5, 1, 2, 3], description=IDStr(faker.pystr())
426+
steps=5, step_weights=[2, 5, 1, 2, 3], description=faker.pystr()
430427
) as sub:
431428
assert sub.step_weights == [2 / 13, 5 / 13, 1 / 13, 2 / 13, 3 / 13, 0]
432429
assert sub._current_steps == pytest.approx(0) # noqa: SLF001
@@ -487,7 +484,7 @@ async def test_weighted_progress_bar_with_weighted_sub_progress(
487484
async def test_weighted_progress_bar_wrong_num_weights_raises(faker: Faker):
488485
with pytest.raises(RuntimeError):
489486
async with ProgressBarData(
490-
num_steps=3, step_weights=[3, 1], description=IDStr(faker.pystr())
487+
num_steps=3, step_weights=[3, 1], description=faker.pystr()
491488
):
492489
...
493490

@@ -496,7 +493,7 @@ async def test_weighted_progress_bar_with_0_weights_is_equivalent_to_standard_pr
496493
faker: Faker,
497494
):
498495
async with ProgressBarData(
499-
num_steps=3, step_weights=[0, 0, 0], description=IDStr(faker.pystr())
496+
num_steps=3, step_weights=[0, 0, 0], description=faker.pystr()
500497
) as root:
501498
assert root.step_weights == [1, 1, 1, 0]
502499

@@ -509,13 +506,13 @@ async def test_concurrent_sub_progress_update_correct_sub_progress(
509506
num_steps=3,
510507
step_weights=[3, 1, 2],
511508
progress_report_cb=mocked_progress_bar_cb,
512-
description=IDStr(faker.pystr()),
509+
description=faker.pystr(),
513510
) as root:
514-
sub_progress1 = root.sub_progress(23, description=IDStr(faker.pystr()))
511+
sub_progress1 = root.sub_progress(23, description=faker.pystr())
515512
assert sub_progress1._current_steps == _INITIAL_VALUE # noqa: SLF001
516-
sub_progress2 = root.sub_progress(45, description=IDStr(faker.pystr()))
513+
sub_progress2 = root.sub_progress(45, description=faker.pystr())
517514
assert sub_progress2._current_steps == _INITIAL_VALUE # noqa: SLF001
518-
sub_progress3 = root.sub_progress(12, description=IDStr(faker.pystr()))
515+
sub_progress3 = root.sub_progress(12, description=faker.pystr())
519516
assert sub_progress3._current_steps == _INITIAL_VALUE # noqa: SLF001
520517

521518
# NOTE: in a gather call there is no control on which step finishes first

packages/simcore-sdk/src/simcore_sdk/node_data/data_manager.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from pathlib import Path
33
from tempfile import TemporaryDirectory
44

5-
from models_library.basic_types import IDStr
65
from models_library.projects import ProjectID
76
from models_library.projects_nodes_io import NodeID, StorageFileID
87
from models_library.users import UserID
@@ -105,7 +104,7 @@ async def _pull_legacy_archive(
105104
) -> None:
106105
# NOTE: the legacy way of storing states was as zip archives
107106
async with progress_bar.sub_progress(
108-
steps=2, description=IDStr(f"pulling {destination_path.name}")
107+
steps=2, description=f"pulling {destination_path.name}"
109108
) as sub_prog:
110109
with TemporaryDirectory() as tmp_dir_name:
111110
archive_file = Path(tmp_dir_name) / __get_s3_name(

packages/simcore-sdk/src/simcore_sdk/node_ports_common/aws_s3_cli.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
from asyncio.streams import StreamReader
77
from pathlib import Path
88

9-
from common_library.errors_classes import OsparcErrorMixin
10-
119
from aiocache import cached # type: ignore[import-untyped]
12-
from models_library.basic_types import IDStr
10+
from common_library.errors_classes import OsparcErrorMixin
1311
from pydantic import AnyUrl, ByteSize
1412
from servicelib.progress_bar import ProgressBarData
1513
from servicelib.utils import logged_gather
@@ -242,7 +240,7 @@ async def _sync_sources(
242240
async with progress_bar.sub_progress(
243241
steps=folder_size,
244242
progress_unit="Byte",
245-
description=IDStr(f"transferring {local_dir.name}"),
243+
description=f"transferring {local_dir.name}",
246244
) as sub_progress:
247245
aws_s3_cli_log_parsers: list[BaseLogParser] = (
248246
[DebugLogParser()] if debug_logs else []

packages/simcore-sdk/src/simcore_sdk/node_ports_common/file_io_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
RequestInfo,
1919
)
2020
from models_library.api_schemas_storage import ETag, FileUploadSchema, UploadedPart
21-
from models_library.basic_types import IDStr, SHA256Str
21+
from models_library.basic_types import SHA256Str
2222
from multidict import MultiMapping
2323
from pydantic import AnyUrl, NonNegativeInt
2424
from servicelib.aiohttp import status
@@ -216,7 +216,7 @@ async def download_link_to_file(
216216
sub_progress = await stack.enter_async_context(
217217
progress_bar.sub_progress(
218218
steps=file_size or 1,
219-
description=IDStr(f"downloading {file_path.name}"),
219+
description=f"downloading {file_path.name}",
220220
)
221221
)
222222

@@ -400,7 +400,7 @@ async def upload_file_to_presigned_links(
400400
)
401401
sub_progress = await stack.enter_async_context(
402402
progress_bar.sub_progress(
403-
steps=file_size, description=IDStr(f"uploading {file_name}")
403+
steps=file_size, description=f"uploading {file_name}"
404404
)
405405
)
406406

packages/simcore-sdk/src/simcore_sdk/node_ports_common/filemanager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
LinkType,
1313
UploadedPart,
1414
)
15-
from models_library.basic_types import IDStr, SHA256Str
15+
from models_library.basic_types import SHA256Str
1616
from models_library.projects_nodes_io import LocationID, LocationName, StorageFileID
1717
from models_library.users import UserID
1818
from pydantic import AnyUrl, ByteSize, TypeAdapter
@@ -364,7 +364,7 @@ async def _upload_path( # pylint: disable=too-many-arguments
364364
)
365365

366366
if not progress_bar:
367-
progress_bar = ProgressBarData(num_steps=1, description=IDStr("uploading"))
367+
progress_bar = ProgressBarData(num_steps=1, description="uploading")
368368

369369
is_directory: bool = isinstance(path_to_upload, Path) and path_to_upload.is_dir()
370370
if (

packages/simcore-sdk/src/simcore_sdk/node_ports_common/r_clone.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from aiocache import cached # type: ignore[import-untyped]
1212
from aiofiles import tempfile
1313
from common_library.errors_classes import OsparcErrorMixin
14-
from models_library.basic_types import IDStr
1514
from pydantic import AnyUrl, BaseModel, ByteSize
1615
from servicelib.progress_bar import ProgressBarData
1716
from servicelib.utils import logged_gather
@@ -224,7 +223,7 @@ async def _sync_sources(
224223
async with progress_bar.sub_progress(
225224
steps=folder_size,
226225
progress_unit="Byte",
227-
description=IDStr(f"transferring {local_dir.name}"),
226+
description=f"transferring {local_dir.name}",
228227
) as sub_progress:
229228
r_clone_log_parsers: list[BaseLogParser] = (
230229
[DebugLogParser()] if debug_logs else []

packages/simcore-sdk/src/simcore_sdk/node_ports_v2/nodeports_v2.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from typing import Any
88

99
from models_library.api_schemas_storage import LinkType
10-
from models_library.basic_types import IDStr
1110
from models_library.projects import ProjectIDStr
1211
from models_library.projects_nodes_io import NodeIDStr
1312
from models_library.services_types import ServicePortKey
@@ -229,7 +228,7 @@ async def _set_with_notifications(
229228

230229
tasks = []
231230
async with progress_bar.sub_progress(
232-
steps=len(port_values.items()), description=IDStr("set multiple")
231+
steps=len(port_values.items()), description="set multiple"
233232
) as sub_progress:
234233
for port_key, (value, set_kwargs) in port_values.items():
235234
tasks.append(

0 commit comments

Comments
 (0)