Skip to content

Create context manager that allows a loop to be interrupted early#83

Merged
nathan-hess merged 1 commit into
mainfrom
interruptible-loop
Feb 14, 2024
Merged

Create context manager that allows a loop to be interrupted early#83
nathan-hess merged 1 commit into
mainfrom
interruptible-loop

Conversation

@nathan-hess
Copy link
Copy Markdown
Owner

@nathan-hess nathan-hess commented Feb 14, 2024

Major Changes and Improvements

  • Created a context manager pyxx.dev.InterruptibleLoop that allows (possibly long-running) loops to be exited early by pressing Ctrl+c
    • This can be useful in cases such as training a machine learning model, when it may be desirable to stop training partway through (based on observed losses) but the script needs to gracefully end (saving data, generating figures, etc.) rather than immediately terminating
    • Handling SIGINT is a convenient way to accomplish this as it is simple and intuitive
  • Added unit tests and documentation for new class

@nathan-hess nathan-hess added documentation Improvements or additions to documentation enhancement New feature or request testing Additions or updates to automated unit and regression tests labels Feb 14, 2024
@nathan-hess nathan-hess self-assigned this Feb 14, 2024
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4caf222) 100.000% compared to head (a40678e) 100.000%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##               main        #83   +/-   ##
===========================================
  Coverage   100.000%   100.000%           
===========================================
  Files            38         39    +1     
  Lines          1254       1276   +22     
  Branches        254        255    +1     
===========================================
+ Hits           1254       1276   +22     
Files Coverage Δ
pyxx/dev/__init__.py 100.000% <100.000%> (ø)
pyxx/dev/classes/__init__.py 100.000% <100.000%> (ø)
pyxx/dev/classes/loops.py 100.000% <100.000%> (ø)

@nathan-hess nathan-hess merged commit 1504348 into main Feb 14, 2024
@nathan-hess nathan-hess deleted the interruptible-loop branch February 14, 2024 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request testing Additions or updates to automated unit and regression tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant