StaticPool
Bases: Thread
Creates a pool to submit job and manage tasks based on their estimated costs. Jobs are given at the invocation of the instance and ends when all jobs are processed.
Attributes:
Name | Type | Description |
---|---|---|
init_memory |
int
|
Memory available at the creation of the pool. It can be overrided with override_max_value |
memory |
int
|
Memory available at the moment |
output |
str or None
|
The file to write the output. If none, will write on the console. (default is None) |
pool |
list
|
A list of jobs to be executed |
launched |
list
|
A list of jobs that have been launched |
idle_time |
int
|
The time in seconds between each verification by the system of the current resources allocations (default is 1) |
refresh_time |
int
|
The time in seconds between each status emission by the pool (default is 5) |
is_over |
bool
|
If True, the pool is terminated |
count |
int
|
The number of jobs submitted |
start_date |
datetime object
|
The date at which the pool has been created |
end_date |
datetime object
|
The date at which the pool has been terminated |
Methods
allocate(calculation) Virtually allocate an amount of memory based on the calculation cost - Not meant to be called by the user - release(self, calculation) Virtually release an amount of memory based on the calculation cost - Not meant to be called by the user - end(now=False) Ends the pool and wait for it to be dead run() The running function of the pool. Is called by start method - Not meant to be called by the user - display_status() Displays the current status of the pool with running jobs, memory allocation, calculation times and job in the queue emit_status() Execute the display_status method every refresh_time with a time stamp check_status() A thread that check the current status and health of the pool - Not meant to be called by the user - review(awaiting=False) Displays a summary of all calculation performed by the pool. It should only be called after when the pool is dead (i.e. after the end function is called).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target |
function
|
The function containing the jobs to be performed |
required |
args |
list of tuples
|
A list of tuples containing the arguments to be parsed. For instance, if n jobs of the function have to be executed with k arguments for the function, a list of n tuples, each containing k arguments should be given |
required |
cost |
int
|
The cost of each job in giga octets |
20
|
idle_time |
int, optional
|
The time in seconds between each verification by the system of the current resources allocations (default is 1) |
1
|
refresh_time |
int, optional
|
The time in seconds between each status emission by the pool (default is 5) |
5
|
override_max_value |
int or None, optional
|
The maximum virtual memory available in the system/for the pool. If None, will get the maximum from the OS (default is None) |
None
|
output |
str or None, optional
|
The file to write the output. If none, will write on the console. (default is None) |
None
|
Source code in PoolFlow\static_pool.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
|
runnings
property
Returns a list with running jobs - Not meant to be called by the user -
deads
property
Returns a list of dead jobs - Not meant to be called by the user -
allocate(calc)
Virtually allocate an amount of memory based on the calculation cost - Not meant to be called by the user -
Parameters:
Name | Type | Description | Default |
---|---|---|---|
calc |
a Calculation object
|
|
required |
Source code in PoolFlow\static_pool.py
119 120 121 122 123 124 125 126 127 128 |
|
release(calc)
Virtually release an amount of memory based on the calculation cost - Not meant to be called by the user -
Parameters:
Name | Type | Description | Default |
---|---|---|---|
calc |
a Calculation object
|
|
required |
Source code in PoolFlow\static_pool.py
130 131 132 133 134 135 136 137 138 139 |
|
run()
The running function of the pool. Is called by start method - Not meant to be called by the user -
Source code in PoolFlow\static_pool.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
|
display_status()
Displays the current status of the pool with running jobs, memory allocation, calculation times and job in the queue
Source code in PoolFlow\static_pool.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
|
emit_status()
Execute the display_status method every refresh_time with a time stamp
Source code in PoolFlow\static_pool.py
193 194 195 196 197 198 199 200 201 202 203 |
|
check_status()
A thread that check the current status and health of the pool - Not meant to be called by the user -
Source code in PoolFlow\static_pool.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
|
review(awaiting=False)
Displays a summary of all calculation performed by the pool. It should only be called after when the pool is dead (i.e. after the end function is called).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
awaiting |
bool
|
If True, will wait for the pool to end. (default is False) |
False
|
Source code in PoolFlow\static_pool.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
end(now=False)
Ends the pool and wait for it to be dead.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
now |
bool, optional
|
If True, forces the jobs to end (default is False) |
False
|
Source code in PoolFlow\static_pool.py
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
|