Add progress counter and ETA to convert/generate script output - #34
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 everyConverting:line printed to the terminal.What it looks like
Serial convert scripts:
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'sConverting:line still shows what kicked off:Implementation
A small, thread-safe
ProgressTrackerhelper is added tosrc/openmc_data/utils.py(exported from the package alongside aformat_durationhelper). ETA is a linear extrapolation from the average time per completed item.tracker.starting(name)in place of the oldprint(f"Converting: ...").Poolloops passtracker.callback(name)as theapply_asynccallback/error_callback.Touched: all
convert_*.pyandgenerate_*.pyscripts, plusutils.pyand__init__.py. No behavior change beyond the extra progress output; all files compile.Closes #32