progress.workers¶
The progress of the activities which run in a worker process.
A run which hands its work to a pool (the experiments of a runner, the runs of
a fit, the scans of an identifiability) sees the progress of its workers
through a queue: the worker puts a Snapshot of every activity on it, see
worker_reporting, and a thread of the parent replays the snapshots on its
reporter, see forwarding. The activities of a worker nest under the activity
of the parent, so the bar of a scan of a worker is drawn below the bar of the
run which waits for it.
The queue of the parent may carry other messages as well, e.g. the events of
the experiments of sbmlsim.experiment.progress, which the thread hands to a
listener: one queue and one thread carry the progress of a run.
Snapshot
dataclass
¶
What an activity of a worker is at, the message of the queue.
The snapshot holds what a reporter renders, not the activity itself: the
activity of a worker lives in its process, and the parent builds one of
its own from the snapshots, see forwarding.
Attributes:
| Name | Type | Description |
|---|---|---|
pid |
int
|
the process the activity runs in, which identifies it with |
uid |
int
|
the activity in its process. |
parent_uid |
int | None
|
the activity it runs in, |
kind |
str
|
what kind of operation it is. |
label |
str
|
what it runs on. |
completed |
int
|
the steps which are done. |
total |
int | None
|
the steps in total, |
workers |
int
|
the steps which are processed at once. |
elapsed |
float
|
the seconds since the activity started. |
state |
str
|
|
error |
str | None
|
what the activity failed by, |
QueueReporter
¶
Put the activities of a worker on the queue of its parent.
Create the reporter of a worker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
messages
|
Any
|
the queue to the parent. |
required |
worker_reporting
¶
Report the activities of a worker to the queue of its parent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
messages
|
Any | None
|
the queue to the parent, |
required |
forwarding
¶
Forward the messages of the workers while the run lasts.
A thread of the parent takes the messages from the queue: a Snapshot is
replayed on the reporter, every other message is handed to the listener. A
worker which is terminated while it writes, e.g. when Ctrl-C stops the
pool, can leave a message half written, which the thread waits for in
vain: it is a daemon and is not waited for longer than a second, so it
never holds up the end of a run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
messages
|
Any | None
|
the queue of the workers, |
required |
target
|
Reporter | None
|
what renders the activities of the workers, |
None
|
listener
|
Callable[[Any], None] | None
|
what receives the other messages of the queue, |
None
|
parent
|
Activity | None
|
the activity the activities of the workers nest under. |
None
|
poll
|
float
|
the seconds the thread waits for the next message. |
POLL
|
close
|
bool
|
close the queue when the run ends, for a queue of a pool which is not used again. |
False
|