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

Add time to experiment termination conditions #4073

Merged
merged 9 commits into from
May 28, 2024

Conversation

mleot
Copy link
Contributor

@mleot mleot commented May 8, 2024

Description

This change is to add the ability to stop an experiment by setting a time delta as a termination condition. There is no current issue for this that I am aware of, but I can make one if needed. I would like to be able to do this to simulate an experiment only up until a given time.

Fixes # (issue)

Type of change

Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist:

  • No style issues: $ pre-commit run (or $ nox -s pre-commit) (see CONTRIBUTING.md for how to set this up to run automatically when committing locally, in just two lines of code)
  • All tests pass: $ python run-tests.py --all (or $ nox -s tests)
  • The documentation builds: $ python run-tests.py --doctest (or $ nox -s doctests)

You can run integration tests, unit tests, and doctests together at once, using $ python run-tests.py --quick (or $ nox -s quick).

Further checks:

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@mleot mleot changed the title add time termination lines Add time to experiment termination conditions May 8, 2024
Copy link

codecov bot commented May 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.54%. Comparing base (739a1c0) to head (0d51ceb).

Current head 0d51ceb differs from pull request most recent head fdd65e3

Please upload reports for the commit fdd65e3 to get more accurate results.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4073      +/-   ##
===========================================
- Coverage    99.55%   99.54%   -0.01%     
===========================================
  Files          287      287              
  Lines        21753    21775      +22     
===========================================
+ Hits         21657    21677      +20     
- Misses          96       98       +2     

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

@mleot mleot marked this pull request as ready for review May 16, 2024 00:11
Copy link
Member

@valentinsulzer valentinsulzer left a comment

Choose a reason for hiding this comment

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

Looks good to me. @brosaplanella can you confirm this isn't duplicating the functionality of the start_time that you added?

@brosaplanella
Copy link
Sponsor Member

No, that should be a different feature.

@kratman
Copy link
Contributor

kratman commented May 28, 2024

For Lychee the whole projects page of LLNL is down, but the main page is still OK. Probably just a random outage

Copy link
Contributor

@kratman kratman left a comment

Choose a reason for hiding this comment

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

Changes look fine to me, just the time adjustment looks reusable

Comment on lines +172 to +180
elif term.endswith("s"):
end_time_s = term.split("s")[0]
termination_dict["time"] = (float(end_time_s), "s")
elif term.endswith("min"):
end_time_s = term.split("min")[0]
termination_dict["time"] = (float(end_time_s) * 60, "s")
elif term.endswith("h"):
end_time_s = term.split("h")[0]
termination_dict["time"] = (float(end_time_s) * 3600, "s")
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume we do this elsewhere too. Maybe we should have. function for handling time units. I don't want to block this PR, but can we open a ticket for it?

Copy link
Contributor

Choose a reason for hiding this comment

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

I created #4113 to track this, @mleot let me know if you want to take that issue as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for creating that issue. It sounds like there should be another change applied to use the function that Valentin mentioned in that issue. I can take that issue if nobody else wants to take it. Maybe next week I can take a stab at applying the fix.

@kratman
Copy link
Contributor

kratman commented May 28, 2024

For Lychee the whole projects page of LLNL is down, but the main page is still OK. Probably just a random outage

Failure is gone now

@kratman kratman merged commit a427b3a into pybamm-team:develop May 28, 2024
22 of 23 checks passed
@mleot mleot deleted the add-time-experiment-termination branch May 28, 2024 21:13
js1tr3 pushed a commit to js1tr3/PyBaMM that referenced this pull request Aug 12, 2024
* add time termination lines

* fix bug

* add test

* add more test coverage

* update changelog

---------

Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com>
Co-authored-by: Eric G. Kratz <kratman@users.noreply.github.com>
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.

None yet

5 participants