hscommon.jobprogress.job

Job(job_proportions, callback) Manages a job’s progression and return it’s progression through a callback.
NullJob(*args, **kwargs)
class hscommon.jobprogress.job.Job(job_proportions, callback)

Manages a job’s progression and return it’s progression through a callback.

Note that this class is not foolproof. For example, you could call start_subjob, and then call add_progress from the parent job, and nothing would stop you from doing it. However, it would mess your progression because it is the sub job that is supposed to drive the progression. Another example would be to start a subjob, then start another, and call add_progress from the old subjob. Once again, it would mess your progression. There are no stops because it would remove the lightweight aspect of the class (A Job would need to have a Parent instead of just a callback, and the parent could be None. A lot of checks for nothing.). Another one is that nothing stops you from calling add_progress right after SkipJob.

_do_update(desc)

Calls the callback function with a % progress as a parameter.

The parameter is a int in the 0-100 range.

_subjob_callback(progress, desc='')

This is the callback passed to children jobs.

iter_with_progress(iterable, desc_format=None, every=1, count=None)

Iterate through iterable while automatically adding progress.

WARNING: We need our iterable’s length. If iterable is not a sequence (that is, something we can call len() on), you have to specify a count through the count argument. If count is None, len(iterable) is used.

set_progress(progress, desc='')

Sets the progress of the current job to ‘progress’, and call the callback

start_job(max_progress=100, desc='')

Begin work on the next job. You must not call start_job more than ‘jobcount’ (in __init__) times. ‘max’ is the job units you are to perform. ‘desc’ is the description of the job.

start_subjob(job_proportions, desc='')

Starts a sub job. Use this when you want to split a job into multiple smaller jobs. Pretty handy when starting a process where you know how many subjobs you will have, but don’t know the work unit count for every of them. returns the Job object

class hscommon.jobprogress.job.NullJob(*args, **kwargs)