mamut_routing_tools.bks_campaign.runner¶
Run a campaign's tasks: resumable worker processes with memory-aware admission.
- One spawned worker process per task: a solver's memory is returned to the
system after every run, and a fixed driver is picked up by the next worker.
Workers are managed one by one (no shared pool), so a worker that dies (the
out-of-memory killer) costs only its own run: it gets a
failedrecord (--retry-failedruns it again), its orphaned solver is killed, and the other runs carry on. - Admission: a task starts only while the memory estimates of the running
tasks plus its own fit the budget (
resources.memory_gb, or 80 % ofMemAvailable); at least one task always runs. - A
warm_start = "best"task starts only once the other runs of its instance and objective have finished, and looks its start routes up at that moment: the best valid archived run, or the stored BKS. - Workers solve, check and write their own run record (atomically); they never write a BKS. Harvest is a separate, single-writer step.
- First Ctrl-C: stop admitting, let the running tasks finish. A second one aborts: workers get SIGTERM, which kills their solver's process group. Workers ignore the terminal's SIGINT, from the moment they start (it is blocked while they boot), so the first Ctrl-C never interrupts a run halfway.
- SIGTERM (
kill,timeout, systemd, a batch scheduler before its SIGKILL) aborts at once: the running tasks are stopped and leave no record, so the nextrunredoes them.
memory_budget_gb
¶
resources.memory_gb: a number, or auto = 80 % of MemAvailable (Linux; 8 GB elsewhere).
Source code in MAMUT-routing-tools/src/mamut_routing_tools/bks_campaign/runner.py
execute_task
¶
Worker: solve one task, check it, write its record; returns a short summary.
Source code in MAMUT-routing-tools/src/mamut_routing_tools/bks_campaign/runner.py
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 | |
run_tasks
¶
run_tasks(
plan: CampaignPlan,
*,
out: Path,
workers: int,
memory_gb: float,
progress: Callable[[str], None] = print,
max_tasks: int | None = None,
) -> dict[str, Any]
Run the plan's tasks; returns (and writes to run.DONE) a summary.
Source code in MAMUT-routing-tools/src/mamut_routing_tools/bks_campaign/runner.py
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 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | |