Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Progress Bars #1703

Merged
merged 15 commits into from
Aug 20, 2021
Merged

Conversation

atharva-2001
Copy link
Member

@atharva-2001 atharva-2001 commented Jul 9, 2021

This PR adds progress bars to TARDIS.

Description

Motivation and context

How has this been tested?

  • Other.
  • Testing pipeline.

Examples

Please visit the documentation here:
https://atharva-2001.github.io/tardis/branch/progress_bar/io/output/index.html
https://atharva-2001.github.io/tardis/branch/progress_bar/quickstart/quickstart.html

Peek 2021-08-03 23-38
Peek 2021-08-05 18-43

Type of change

  • Bug fix.
  • New feature.
  • Breaking change.
  • None of the above.

Checklist

  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
    • (optional) I have built the documentation on my fork following the instructions.
  • I have assigned and requested two reviewers for this pull request.

@tardis-bot
Copy link
Contributor

Before a pull request is accepted, it must meet the following criteria:

  • Is the necessary information provided?
  • Is this a duplicate PR?
    • If a new PR is clearly a duplicate, ask how this PR is different from the original PR?
    • If this PR is about to be merged, close the original PR with a link to this new PR that solved the issue.
  • Does it pass existing tests and are new tests provided if required?
    • The test coverage should not decrease, and for new features should be close to 100%.
  • Is the code tidy?
    • No unnecessary print lines or code comments.

@codecov
Copy link

codecov bot commented Jul 9, 2021

Codecov Report

Merging #1703 (54d82ee) into master (e21ecf7) will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1703      +/-   ##
==========================================
- Coverage   62.65%   62.63%   -0.02%     
==========================================
  Files          65       65              
  Lines        6036     6089      +53     
==========================================
+ Hits         3782     3814      +32     
- Misses       2254     2275      +21     
Impacted Files Coverage Δ
tardis/tardis/util/base.py 72.19% <0.00%> (-2.16%) ⬇️
tardis/tardis/base.py 57.14% <0.00%> (ø)
tardis/tardis/montecarlo/base.py 88.77% <0.00%> (ø)
tardis/tardis/simulation/base.py 83.25% <0.00%> (+0.07%) ⬆️
tardis/tardis/montecarlo/montecarlo_numba/base.py 26.21% <0.00%> (+0.44%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e21ecf7...54d82ee. Read the comment docs.

Copy link
Contributor

@MarkMageeAstro MarkMageeAstro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The progress bars look great, but I personally think this should not be a separate PR. To me, this is still part of the convergence plots because it's showing the progress of the model. I would like to see the layout of the progress bars and convergence plots together.

What is the impact on performance using these bars, if any?

Minor changes:

  1. The packets bar should read "XX% of packets propagated". Perhaps even "XX% of real packets propagated".
  2. There are hardcoded values for iterations and packet numbers, but these should come from the input yaml file. You can get the total packet number from (iterations - 1) * no_of_packets + last_no_of_packets

@atharva-2001
Copy link
Member Author

atharva-2001 commented Jul 9, 2021

Thank you @MarkMageeAstro!
I tried 5 iterations in each case and the simulation took me around 30 seconds using progress bars and around 27 seconds without them, using tardis_example.yml. I will make the required changes very soon. I too believe seeing the progress bars and the convergence plots together would be better. Maybe we could discuss this with others in the meeting and then close this PR.

@MarkMageeAstro
Copy link
Contributor

That's great, I would consider a ~10% increase acceptable.

from tqdm import tqdm

packet_pbar = tq.tqdm(
total=860000,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't hardcode the number of packets or iterations. These numbers need to be retrieved from the tardis config object.

bar_format="{bar}{percentage:3.0f}% packets propagated",
)
iteration_pbar = tq.tqdm(
total=20,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retrieve number of iterations from the tardis config object. This is a user specified parameter.

Comment on lines 189 to 190
with objmode:
update_packet_pbar(1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try using if (i % 1000 == 0) as a condition. You might need to also change the argument in update_packet_pbar to 1000. Use the tqdm documentation here and click the links to the source code for the update function:

https://tqdm.github.io/docs/tqdm/

Comment on lines 32 to 33
iterations = 20
packets = 860000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These values need to be read in from the config dict.

@atharva-2001 atharva-2001 force-pushed the progress_bar branch 5 times, most recently from 9fe7e2f to 4704edc Compare July 29, 2021 06:21
@atharva-2001 atharva-2001 marked this pull request as ready for review July 29, 2021 07:29
@atharva-2001 atharva-2001 force-pushed the progress_bar branch 3 times, most recently from 7d2d6ae to 4699251 Compare July 29, 2021 08:20
@tardis-sn tardis-sn deleted a comment from tardis-bot Jul 29, 2021
Copy link
Member

@jaladh-singhal jaladh-singhal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The progress bar looks nice and code quality looks ok to me (considering you haven't added docstrings to existing functions that didn't have them already). Rest about code changes - since it deals with numba I'd request @andrewfullard to have a look.

Have you checked how progress bar looks on static html page (in docs)?

@wkerzendorf
Copy link
Member

this has preliminary approval from me (pending the others approval) - it looks very nice.

Copy link
Member

@jaladh-singhal jaladh-singhal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @atharva-2001. Everything looks good except mentioning about it in our docs is missing.

AFAIR, you were adding a "Progress bar for Simulation Run" page in "Additional outputs" section explaining options related to progress bar, different modes of display, etc. along with a note in quickstart (?) that progress bar doesn't get displayed in static page but will show up in interactive mode?

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link
Member

@jaladh-singhal jaladh-singhal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the documentation

Copy link
Member

@jamesgillanders jamesgillanders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great addition to the code!

@jamesgillanders jamesgillanders merged commit 575002c into tardis-sn:master Aug 20, 2021
DhruvSondhi pushed a commit to DhruvSondhi/tardis that referenced this pull request Aug 21, 2021
* Customize bar format

* Display bars again after reset when full

* Get data from configuration file

* Track all packets at once and don't reset the progress bar

* Close last container and add docstrings

* Add option to enable/disble the progress bar

* Display container only in notebooks

* Add a progress bar to track iterations

* Align bars

* Refactor code

* Format using black

* Add message regarding progress bars in the quickstart notebook

* Demonstrate progress bars in the documentation

* Change show_progress_bar to show_progress_bars

* [build docs]
DhruvSondhi pushed a commit to DhruvSondhi/tardis that referenced this pull request Aug 21, 2021
* Customize bar format

* Display bars again after reset when full

* Get data from configuration file

* Track all packets at once and don't reset the progress bar

* Close last container and add docstrings

* Add option to enable/disble the progress bar

* Display container only in notebooks

* Add a progress bar to track iterations

* Align bars

* Refactor code

* Format using black

* Add message regarding progress bars in the quickstart notebook

* Demonstrate progress bars in the documentation

* Change show_progress_bar to show_progress_bars

* [build docs]
atharva-2001 added a commit to atharva-2001/tardis that referenced this pull request Oct 1, 2021
* Customize bar format

* Display bars again after reset when full

* Get data from configuration file

* Track all packets at once and don't reset the progress bar

* Close last container and add docstrings

* Add option to enable/disble the progress bar

* Display container only in notebooks

* Add a progress bar to track iterations

* Align bars

* Refactor code

* Format using black

* Add message regarding progress bars in the quickstart notebook

* Demonstrate progress bars in the documentation

* Change show_progress_bar to show_progress_bars

* [build docs]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants