jobs

examples

api

abutils.progress_bar(finished, total, start_time=None, extra_info=None, autocomplete=True, complete=False, completion_string='\n')

Prints an ASCII progress bar.

Each call to progress_bar will update the progress bar. An example of tracking the progress of a list of items would look like:

job_list = [job1, job2, job3, ... jobN]
total_jobs = len(job_list)

#initialize the progress bar
progress_bar(0, total_jobs)

# do the jobs
for i, job in enumerate(job_list):
    do_job(job)
    progress_bar(i + 1, total_jobs)

Args:

finished (int): Number of finished jobs.

total (int): Total number of jobs.

start_time (datetime): Start time, as a datetime.datetime object.

Only required if you want to display execution time alongside the progress bar. If not provided, execution time is not shown.

extra_info (str): A string containing extra information to be displayed

at the end of the progbar string. Examples include the number of failed jobs, the name of the job batch currently being processed, etc.

complete (bool): If True, will append completion_string to the end

of the progbar string.

completion_string (str): Will be appended to the progbar string if

complete is True. Default is `

`.

abutils.monitor_mp_jobs(results: Iterable, completion_string: str | None = None, print_progress: bool = True, start_time: time | None = None)

Monitors the progress of a set of multiprocessing jobs.

Parameters:
  • results (Iterable[mp.pool.AsyncResult]) – A list of AsyncResult objects from multiprocessing jobs.

  • completion_string (str, optional) – A string to print after the progress bar when the jobs are complete.

  • print_progress (bool) – Whether or not to print a progress bar. Default is True.

  • start_time (time.time, optional) – DEPRECATED and is ignored. tqdm automatically handles the start time, but the argument is maintained for backwards compatibility.

abutils.monitor_celery_jobs(results: Iterable, start_time: time | None = None, completion_string: str = '\n', print_progress: bool = True)

Monitors the progress of a set of Celery jobs.

Parameters:
  • results (Iterable[celery.result.AsyncResult]) – A list of AsyncResult objects from Celery jobs.

  • start_time (time.time) – The time at which the jobs started. If not provided, elapsed time will not be shown.

  • completion_string (str) – A string to print when the jobs are complete. Default is a newline.

  • print_progress (bool) – Whether or not to print a progress bar. Default is True.