Skip to content

Add Abort Callback to Run #500

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

Merged
merged 18 commits into from
Oct 4, 2024
Merged

Add Abort Callback to Run #500

merged 18 commits into from
Oct 4, 2024

Conversation

kzscisoft
Copy link
Collaborator

Adds the option to provide a callback which is executed when a run is aborted:

with Run(abort_callback=my_callback):
   ...

@kzscisoft kzscisoft added the enhancement New feature or request label Aug 28, 2024
@kzscisoft kzscisoft added this to the API v1.1 milestone Aug 28, 2024
@kzscisoft kzscisoft requested a review from wk9874 August 28, 2024 11:03
@kzscisoft kzscisoft linked an issue Aug 28, 2024 that may be closed by this pull request
@kzscisoft kzscisoft force-pushed the 490-alert-trigger-callback-option branch 3 times, most recently from d1e4794 to 7f6e335 Compare August 28, 2024 12:39
@kzscisoft kzscisoft force-pushed the 490-alert-trigger-callback-option branch from 7f6e335 to cd8fe4c Compare August 28, 2024 12:43
simvue/run.py Outdated
@@ -313,7 +319,7 @@ def _heartbeat(
fg="red" if self._term_color else None,
bold=self._term_color,
)
if abort_callback:
if abort_callback is not None:
abort_callback()
os._exit(1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

dont think we need this

@kzscisoft
Copy link
Collaborator Author

Latest on this is that _exit has been used to cover the Python-based simulation as opposed to terminal/external process. Need a solution which:

  • Will stop the Python simulation if an alert is thrown
  • Won't stop the script if it is NOT a python based simulation but rather uses add_process, perhaps use of add_process switches this off?

@wk9874 what do you think?

@kzscisoft kzscisoft marked this pull request as draft September 11, 2024 08:49
@kzscisoft kzscisoft marked this pull request as ready for review September 11, 2024 09:32
@kzscisoft kzscisoft force-pushed the 490-alert-trigger-callback-option branch from 0933c02 to eb8c6ba Compare September 27, 2024 07:41
@kzscisoft kzscisoft requested a review from wk9874 October 4, 2024 10:36
@wk9874 wk9874 merged commit 652d58f into dev Oct 4, 2024
14 checks passed
@kzscisoft kzscisoft deleted the 490-alert-trigger-callback-option branch October 9, 2024 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Alert 'trigger callback' option Support user-defined functions as options to abort a simulation
2 participants