demo¶
The demo plugin: sums of squares, split into one unit per number.
A unit writes its square into the output port squares (out/squares/<i>.json), the
merge the sum into the summary of the task (out/summary.json, which compare
reads; no port).
SquaresSettings
¶
Bases: BaseModel
Settings of the squares demo.
Attributes:
| Name | Type | Description |
|---|---|---|
n |
int
|
Number of units. |
sleep_s |
float
|
Seconds each unit sleeps. |
fail_at |
int | None
|
Index of a unit which fails. |
memory_mb |
int
|
Megabytes each unit allocates. |
count_units
¶
Count the units of work.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
SquaresSettings
|
Settings of the task. |
required |
Returns:
| Type | Description |
|---|---|
int
|
The number of units. |
setup
¶
Create the directory of the output port, once per process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
SquaresSettings
|
Settings of the task. |
required |
paths
|
TaskPaths
|
Locations of the task. |
required |
compute_unit
¶
Write the square of the index, atomically (temporary file, rename).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
SquaresSettings
|
Settings of the task. |
required |
index
|
int
|
Index of the unit. |
required |
paths
|
TaskPaths
|
Locations of the task. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
The unit is the one set to fail. |
merge
¶
Write the sum of the squares.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
SquaresSettings
|
Settings of the task. |
required |
paths
|
TaskPaths
|
Locations of the task. |
required |