Skip to content

Add progress counter and ETA to convert/generate script output - #34

Merged
shimwell merged 2 commits into
mainfrom
add-progress-counter-eta
Jul 23, 2026
Merged

Add progress counter and ETA to convert/generate script output#34
shimwell merged 2 commits into
mainfrom
add-progress-counter-eta

Conversation

@shimwell

Copy link
Copy Markdown
Member

Summary

The convert_* and (more importantly) generate_* scripts can take a very long time, and currently give no sense of how far along they are. This adds a progress counter and ETA to every Converting: line printed to the terminal.

What it looks like

Serial convert scripts:

Converting [12/340   4%] elapsed 0:03:11 ETA 1:24:50: Fe056.ace

Generate scripts run njoy across a multiprocessing.Pool, so files all "start" at once and a per-start ETA is meaningless. Instead, a completion line is printed from the main process as each file finishes (the honest estimate for parallel work), while the child's Converting: line still shows what kicked off:

Converting: /path/to/n-026_Fe_056.endf
Processed [12/340   4%] elapsed 0:10:22 ETA 2:31:40: n-026_Fe_056.endf

Implementation

A small, thread-safe ProgressTracker helper is added to src/openmc_data/utils.py (exported from the package alongside a format_duration helper). ETA is a linear extrapolation from the average time per completed item.

  • Serial loops call tracker.starting(name) in place of the old print(f"Converting: ...").
  • Parallel Pool loops pass tracker.callback(name) as the apply_async callback/error_callback.

Touched: all convert_*.py and generate_*.py scripts, plus utils.py and __init__.py. No behavior change beyond the extra progress output; all files compile.

Closes #32

shimwell added 2 commits July 23, 2026 22:05
Adds a small, thread-safe ProgressTracker helper (plus a format_duration
helper) to utils.py and exports both from the package. Serial convert
loops call tracker.starting(name) in place of the old "Converting:"
print, and parallel generate Pool loops pass tracker.callback(name) as
the apply_async callback/error_callback so a completion line is printed
as each file finishes. ETA is a linear extrapolation from the average
time per completed item.

Closes #32
The develop branch of openmc now requires Python >=3.12, so installing
it under the workflow's Python 3.9 failed with "Package 'openmc'
requires a different Python". Bump to 3.12 to match the test_package and
test_processing workflows, and update the deprecated checkout@v2 /
setup-python@v2 actions to v4 / v5 as used by the other workflows.
@shimwell
shimwell merged commit d1834a0 into main Jul 23, 2026
2 of 3 checks passed
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.

Add progress counter and ETA to convert/generate script output

1 participant