Skip to content

Commit

Permalink
better progress messages
Browse files Browse the repository at this point in the history
  • Loading branch information
ungarj committed Nov 9, 2023
1 parent e406e61 commit 519d63b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
12 changes: 11 additions & 1 deletion mapchete/commands/_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,17 @@ def _process_everything(
for future in mp.compute(**kwargs):
result = TaskResult.from_future(future)
if print_task_details:
msg_callback(str(result))
msg = f"task {result.id}: {result.process_msg}"
if result.profiling:
max_allocated = (
result.profiling["memory"].max_allocated / 1024 / 1024
)
head_requests = result.profiling["requests"].head_count
get_requests = result.profiling["requests"].get_count
requests = head_requests + get_requests
transfer = result.profiling["requests"].get_bytes / 1024 / 1024
msg += f" (max memory usage: {max_allocated:.2f}MB, {requests} GET and HEAD requests, {transfer:.2f}MB transferred)"
msg_callback(msg)
yield result
# explicitly exit the mp object on success
mp.__exit__(None, None, None)
Expand Down
2 changes: 1 addition & 1 deletion mapchete/processing/profilers/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def wrapped_f(*args, **kwargs) -> Union[Any, Tuple[Any, MeasuredRequests]]:
"please install tilebench if you want to use this feature."
)

@profile(add_to_return=True)
@profile(add_to_return=True, quiet=True)
def _decorated(func, fargs, fkwargs) -> Any:
return func(*fargs, **fkwargs)

Expand Down
3 changes: 2 additions & 1 deletion mapchete/processing/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ def from_future(future: MFuture) -> TaskResult:
profiling=process_info.profiling or future.profiling,
)
elif isinstance(process_info, TileProcessInfo):
tile = process_info.tile
return TaskResult(
id=process_info.tile,
id=f"tile-{tile.zoom}-{tile.row}-{tile.col}",
processed=process_info.processed,
process_msg=process_info.process_msg,
profiling=process_info.profiling or future.profiling,
Expand Down

0 comments on commit 519d63b

Please sign in to comment.