Skip to content

Commit 53b257a

Browse files
author
Andrei Neagu
committed
refactor progress
1 parent 335b550 commit 53b257a

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

services/storage/src/simcore_service_storage/api/_worker_tasks/_data_export.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from ...dsm import get_dsm_provider
1010
from ...modules.celery.utils import get_celery_worker_client, get_fastapi_app
1111
from ...simcore_s3_dsm import SimcoreS3DataManager
12-
from ._tqdm_utils import get_export_progress, set_absolute_progress
12+
from ._progress_utils import get_tqdm_progress, set_tqdm_absolute_progress
1313

1414
_logger = logging.getLogger(__name__)
1515

@@ -29,10 +29,10 @@ async def data_export(
2929
),
3030
)
3131

32-
with get_export_progress(total=1, description=f"{task.name}") as pbar:
32+
with get_tqdm_progress(total=1, description=f"{task.name}") as pbar:
3333

3434
async def _progress_cb(report: ProgressReport) -> None:
35-
set_absolute_progress(pbar, current_progress=report.actual_value)
35+
set_tqdm_absolute_progress(pbar, report)
3636
await get_celery_worker_client(task.app).set_task_progress(task, report)
3737

3838
return await dsm.create_s3_export(

services/storage/src/simcore_service_storage/api/_worker_tasks/_tqdm_utils.py renamed to services/storage/src/simcore_service_storage/api/_worker_tasks/_progress_utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import Final
22

3+
from models_library.progress_bar import ProgressReport
34
from pydantic import NonNegativeFloat
45
from tqdm import tqdm
56

@@ -13,11 +14,11 @@
1314
}
1415

1516

16-
def get_export_progress(total: NonNegativeFloat, *, description: str) -> tqdm:
17+
def get_tqdm_progress(total: NonNegativeFloat, *, description: str) -> tqdm:
1718
return tqdm(**TQDM_EXPORT_OPTIONS, total=total, desc=description)
1819

1920

20-
def set_absolute_progress(pbar: tqdm, *, current_progress: NonNegativeFloat) -> None:
21+
def set_tqdm_absolute_progress(pbar: tqdm, report: ProgressReport) -> None:
2122
"""used when the progress does not come in chunk by chunk but as the total current value"""
22-
pbar.n = current_progress
23+
pbar.n = report.actual_value
2324
pbar.refresh()

0 commit comments

Comments
 (0)