raytools.utility

progress bar

class raytools.utility.TStqdm(*_, **__)[source]

Bases: tqdm

ts_message(s)[source]
write(s, file=None, end='\n', nolock=False)[source]

Print a message via tqdm (without overlap with bars).

set_description(desc=None, refresh=True)[source]

Set/modify description of the progress bar.

Parameters:
  • desc (str, optional)

  • refresh (bool, optional) – Forces refresh [default: True].

raytools.utility.pool_call(func, args, *fixed_args, cap=None, expandarg=True, desc='processing', workers=True, pbar=True, **kwargs)[source]

calls func for a sequence of arguments using a ProcessPool executor and a progress bar. result is equivalent to:

result = []
for arg in args:
    result.append(func(*args, *fixed_args, **kwargs))
return result
Parameters:
  • func (callable) – the function to execute in parallel

  • args (Sequence[Sequence]) – list of arguments (each item is expanded with ‘*’ unless expandarg is false). first N args of func

  • fixed_args (Sequence) – arguments passed to func that are the same for all calls (next N arguments after args)

  • cap (int, optional) – execution cap for ProcessPool

  • expandarg (bool, optional) – expand args with ‘*’ when calling func

  • desc (str, optional) – label for progress bar

  • workers (Union[bool, str], optional) – return threadpool (‘t’, ‘threads’, ‘thread’) or processpool (True)

  • pbar (bool, optional) – display progress bar while executing

  • kwargs – additional keyword arguments passed to func

Return type:

sequence of results from func (order preserved)