Skip to content

Consolidate manual-job recovery in check-jobs and add timeit-driven Condor scheduling - #558

Open
mondalspandan wants to merge 28 commits into
PocketCoffea:mainfrom
mondalspandan:fix/check-jobs-consolidated
Open

Consolidate manual-job recovery in check-jobs and add timeit-driven Condor scheduling#558
mondalspandan wants to merge 28 commits into
PocketCoffea:mainfrom
mondalspandan:fix/check-jobs-consolidated

Conversation

@mondalspandan

@mondalspandan mondalspandan commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

This PR supersedes #541, retaining its user-facing consolidation of manual-job recovery while simplifying and hardening the underlying implementation. It also adds throughput-based job splitting, runtime forecasting, automatic queue selection, and worker-side recovery improvements.

1. Features already implemented in #541

Features from #541 kept unchanged in this PR

  • Consolidate manual-job monitoring, resubmission, and recreation under pocket-coffea check-jobs.
  • Remove the separate pocket-coffea run --recreate-jobs workflow.
  • Support one-shot recreation with --recreate auto|<job list> and single-pass monitoring with --once.
  • Support --use-redirector, --blocklist-sites, --recreate-queue, --skip-bad-files, and --remove-running from check-jobs.
  • Allow proactive recreation of failed, idle, or running jobs in addition to reactive --resubmit.
  • Keep jobs_config.yaml as the source of the original per-job filesets during recreation.
  • Keep shared queue and site-rewrite utilities instead of duplicating recovery logic across executors and check-jobs.
  • Keep inner_run_options.yaml for forwarding selected Coffea Runner options to Condor workers.

Features from #541 modified code-wise

  • Replace per-job .sub recovery with a current-format job_state.json + resubmit.sub recovery model.
  • Make retry counts, queue settings, chunksizes, CPU requests, and memory requests persistent across check-jobs restarts.
  • Make proactive recreation transactional around config/state updates and only commit retry state after successful scheduler submission.
  • Make active-job recreation safer by confirming condor_rm and handling jobs that finish while recreation is being prepared.
  • Move reactive XRootD recovery into the worker wrapper instead of maintaining failed-PFN state in check-jobs.
  • Simplify site blocklisting to CMS/Rucio site names with normalized RSE handling and redirector fallback.
  • Simplify --skip-bad-files to update the shared current-format inner_run_options.yaml without legacy wrapper/submit-file patching.
  • Remove compatibility machinery for jobs directories generated by older PocketCoffea versions.

2. New features implemented in this PR

  • Add a dedicated .timeout job state and graceful worker process-group cleanup before Condor removes timed-out jobs.
  • Retry XRootD failures inside the worker by moving files away from failed sites before exposing the job as failed.
  • Persist successful resubmission counts and apply controlled LXPLUS queue/resource escalation on repeated failures or timeouts.
  • Detect and report initial condor_submit failures instead of leaving misleading .idle markers.
  • Support manual-job submission without transferring an X509 proxy when grid credentials are explicitly disabled.
  • Add --timeit for per-dataset processing-throughput measurements.
  • Save reusable per-dataset throughput measurements under timeit/.
  • Use saved throughput measurements to adapt manual-job splitting across datasets.
  • Add LXPLUS runtime forecasts based on measured throughput and requested worker count.
  • Add --queue auto to select an LXPLUS queue per job from its estimated runtime.
  • Support runtime forecasts for mixed-dataset jobs using the estimated runtime of the complete job.
  • Allow dataset-specific as well as sample-specific chunksize mappings.
  • Parallelize creation of per-job configurator pickles for large manual-job submissions.

valsdav and others added 27 commits July 9, 2026 17:52
The babysitter loop only caught KeyboardInterrupt, so any unguarded parse killed a
session that may have run for days. Guard the known crash sites:

- bump_jobqueue: `queues.index(jf)` raised ValueError for a non-lxplus flavour, and
  `return next_jf` raised NameError when the .sub had no +JobFlavour line (e.g. rubin's
  +MaxRuntime). Fall back to the longest known queue for an unknown flavour and return
  None when there is no flavour line.
- The SYSTEM_PERIODIC_REMOVE check did `glob(...logs/job_*.log)[0]` -> IndexError before
  any log exists; skip when there are no logs yet.
- XRootD-error log parsing indexed `c[iln+1]`/`c[iln+3]` and `.split()[-1]` without
  bounds checks -> IndexError on a truncated log; guard both.
- Add a broad except around the loop that reports the error clearly instead of dumping
  a raw traceback.

Adds offline tests for bump_jobqueue (normal, capped, unknown flavour, no flavour line).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ate-jobs

The runner/executor `--recreate-jobs` path and `check-jobs --resubmit`
duplicated a lot of logic (two `find_other_file`, two queue-bump helpers +
two `queues` lists, two fileset-rewrite + condor-resubmit loops) while
operating on the same jobs_dir on-disk contract. Fold all of it into
`check-jobs` so there is a single consumer, and remove the runner path.

check-jobs gains a one-shot proactive recreate mode and the recreate-only
knobs that used to live on `pocket-coffea run`:
- `--recreate auto|0,1,3` (+ `--once`) — recreate/resubmit a chosen set of
  jobs and exit; unlike `--resubmit` it can act on running/idle jobs too.
- `--use-redirector`, `--blocklist-sites` (unioned with the auto blacklist),
  `--recreate-queue`, `--skip-bad-files`.

Shared/reused instead of duplicated:
- new `utils/htcondor_queue.py` (QUEUES, bump_queue, set_queue) replaces
  check_jobs.bump_jobqueue and lxplus update_queue/set_queue + both `queues`.
- `site_rewrite.find_other_file` extended (exclude_urls, blocklist-by-prefix,
  fallback_redirector=None) and now used by check-jobs in place of its private
  copy.
- the submit-time inner_run_options helpers stay in executors_manual_jobs and
  are reused by check-jobs' `--skip-bad-files`.

Removed: recreate_jobs from executors_lxplus/rubin, the ABC abstractmethod,
the submit() dispatch and __init__ guard-skip, and the
--blocklist-sites/--recreate-queue/--use-redirector options on the runner
(--skip-bad-files stays; it also feeds the outer Coffea Runner). `run` now
errors with a pointer to check-jobs if a moved flag is passed.

Also fixes two latent bugs: the babysitter's undefined `log_file` NameError on
the "failed-again after resubmit" path, and the old explicit-list recreate
crashing on an undefined `runningjobs`.

Docs updated; adds tests/test_check_jobs_recreate.py plus set_queue and
find_other_file-extension cases. 39 offline unit tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
# Conflicts:
#	docs/running.md
#	pocket_coffea/executors/executors_lxplus.py
#	pocket_coffea/scripts/check_jobs.py
#	pocket_coffea/scripts/runner.py
Add per-dataset timeit files, event-targeted filtering, adaptive manual splitting, and automatic LXPLUS queue forecasts. Harden Condor/XRootD recovery and check-jobs state handling, with focused tests and documentation.
Prepare recreate replacements before removing active Condor jobs, refresh proxy credentials immediately before submission, and keep queue/resource escalation transactional. Persist replacement-attempt counts across restarts, align legacy timeout resource scaling with dynamic jobs, harden Rubin no-proxy submission, and document the resulting recovery contract.
Generate explicit LXPLUS and Rubin recovery metadata, use one authoritative job state, keep passive check-jobs read-only, and remove legacy migration paths.
@mondalspandan mondalspandan changed the title Fix/check jobs consolidated Consolidate manual-job recovery in check-jobs and add timeit-driven Condor scheduling Aug 21, 2026
@mondalspandan

Copy link
Copy Markdown
Contributor Author

Quick justification for the timeit feature (produces event throughputs based on pilot condor jobs) and the --queue auto flag (configured with 80% queue_time_threshold_percent):

image

Only 4% jobs need to be resubmitted to a longer queue. And by resubmitting longer jobs with an ncpu bump (e.g. with check-jobs -n 4), this overall strategy seems like the highest-gain speedup for long-running analyses.

@valsdav

valsdav commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Hi @mondalspandan! I will have a look at your changes. Can we consider this PR to be reviewed? It's already quite huge :)

@mondalspandan

mondalspandan commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Hi Davide, I did run full workflows with these changes a few times and everything appeared to be working. I agree it's huge, can you please also do a claude review?

@mondalspandan
mondalspandan marked this pull request as ready for review September 2, 2026 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants