Skip to content

Parallelize the screen driver over molecules - #97

Merged
galjos merged 2 commits into
mainfrom
parallel-screen
Jul 7, 2026
Merged

Parallelize the screen driver over molecules#97
galjos merged 2 commits into
mainfrom
parallel-screen

Conversation

@galjos

@galjos galjos commented Jul 7, 2026

Copy link
Copy Markdown
Member

screen ran molecules serially; each job already runs in its own isolated directory, so the loop is embarrassingly parallel.

  • New jobs parameter on screen and -j/--jobs CLI flag (default 1 = serial, unchanged behaviour).
  • With jobs > 1, molecules run in a ProcessPoolExecutor over a module-level, picklable worker (_run_job). Process-based because _run_thermo changes the working directory via os.chdir (api.py:503), so threads would race on the process-global cwd.
  • Preserves: per-job error isolation, resume (skip completed), atomic incremental writes, and deterministic input-order output (results are keyed by name and re-emitted in job order regardless of completion order).

The parallel branch is tested with a synchronous fake executor (so monkeypatched engines apply and no real subprocess/binary is needed): order preservation, failure isolation, and a jobs < 1 guard. Full patch coverage.

Closes #96

Add a jobs parameter (and -j/--jobs CLI flag; default 1 = serial). With
jobs > 1 the molecules run in a ProcessPoolExecutor over a module-level,
picklable worker (_run_job) -- process-based because each job changes the
working directory via os.chdir, so threads would race.

Per-job error isolation, resume (skip completed), atomic incremental
writes, and deterministic input-order output are all preserved. Tests use
a synchronous fake executor to exercise the parallel branch without real
subprocesses.

Closes #96
@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.02%. Comparing base (34d1f03) to head (e0be058).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #97      +/-   ##
==========================================
+ Coverage   96.96%   97.02%   +0.06%     
==========================================
  Files          28       28              
  Lines        1714     1749      +35     
==========================================
+ Hits         1662     1697      +35     
  Misses         52       52              
Flag Coverage Δ
unittests 97.02% <100.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Address review of the parallel screen:
- Reject duplicate molecule names in _load_jobs (names key both the result
  record and the per-molecule directory, so a collision would drop a result
  and race two parallel jobs into the same directory).
- Convert a dead worker process (BrokenProcessPool / OOM) into a per-job
  error record instead of aborting the whole screen.
- Cap the pool at min(jobs, len(pending)).

Add tests for duplicate-name rejection, worker-partial picklability (which
the in-process fake executor can't catch), reversed completion order, and
worker-death survival.
@galjos
galjos merged commit 2e706cd into main Jul 7, 2026
5 checks passed
@galjos
galjos deleted the parallel-screen branch July 7, 2026 09:54
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.

Parallelize the screen driver over molecules

1 participant