jobs
Tools for setting up the JobDB.
TODO: Add some quick tools for inspecting the jobdb here.
fail(job, errcode, msg, logger)
Mark and job as failed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job
|
Job
|
The job to fail. |
required |
errcode
|
ErrCode
|
The error code that thi job failed with. |
required |
msg
|
str
|
The detailed error message. |
required |
logger
|
LoggerLike
|
The logger to log the error to. |
required |
Source code in lat_beams/utils/jobs.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
make_jobdb(comm, data_dir, append='')
Create or load a JobDB at {data_dir}/jobdb{append}.db.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
comm
|
Optional[Comm]
|
The communicator if we are running with MPI or None if not. If provided then rank 0 will load the database first so that it may create it if it doesn't exist. |
required |
data_dir
|
str
|
The directory to load the db from. |
required |
append
|
str
|
String appended to db name. See docstring for details. |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
jobdb |
JobManager
|
The loaded database. For better MPI support this has a timeout of 10 and uses NullPool. |
Source code in lat_beams/utils/jobs.py
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 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
setup_jobs(comm, data_dir, jclass, get_jobdict, get_jobit, get_jobstr, get_tags, source_list, overwrite, retry_failed, job_memory, job_memory_buffer, replot, logger, append='')
Discover, create, and select jobs for execution across MPI ranks.
Existing jobs are loaded from the job database and matched against a
collection of candidate jobs generated by get_jobit. Missing jobs are
created, eligible jobs are reopened when requested, and a consolidated
list of jobs to process is returned.
Jobs may be filtered by lock status, source tag, recent visit time, and job state. Database writes are serialized across MPI ranks to avoid contention.
Jobs are created and database updates are committed serially across MPI ranks to avoid database locking contention.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
comm
|
Optional[Comm]
|
MPI communicator used to prevent deadlock between processes. |
required |
data_dir
|
str
|
Directory containing the job database. |
required |
jclass
|
str
|
Job class name passed to |
required |
get_jobdict
|
Callable[[JobManager], dict[str, Job]]
|
Function that returns a mapping from job identifier strings to existing jobs in the database. |
required |
get_jobit
|
Callable[[JobManager], Iterable[Any]]
|
Function that returns an iterable of candidate job descriptions. |
required |
get_jobstr
|
Callable[[Any], Optional[str]]
|
Function that converts a candidate job description into its unique
job identifier string. Returning |
required |
get_tags
|
Callable[[Any], dict[str, str]]
|
Function that generates the tag dictionary used when creating a new job from a candidate job description. |
required |
source_list
|
Sequence[str]
|
Allowed values of the |
required |
overwrite
|
bool
|
If |
required |
retry_failed
|
bool
|
If |
required |
job_memory
|
Optional[float]
|
Number of hours for which recently visited jobs should be skipped.
If |
required |
job_memory_buffer
|
float
|
Minimum age, in minutes, before the visit-time filter is applied. |
required |
replot
|
bool
|
If |
required |
logger
|
LoggerLike
|
Logger to log to. |
required |
append
|
str
|
String appended to db name.
See |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
jdb |
JobManager
|
Job database manager instance. |
jobs |
list[Job]
|
Complete list of jobs selected for processing across all MPI ranks. |
Source code in lat_beams/utils/jobs.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 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 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 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 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | |