iiasa / ixmp

The ix modeling platform for integrated and cross-cutting scenario analysis
https://docs.messageix.org/ixmp
Apache License 2.0
38 stars 111 forks source link

Avoid locking on failed operations #488

Closed khaeru closed 1 year ago

khaeru commented 1 year ago

The PR adds a new context manager .utils.discard_on_error() that can be used to avoid leaving scenarios in a locked state. This can occur when exceptions are raised and JDBCBackend is in use: an unclean exit means the database is left in a state that marks the scenario as "locked" for use by a particular user.

Originally developed for iiasa/message_data#446.

How to review

PR checklist

codecov[bot] commented 1 year ago

Codecov Report

Merging #488 (246be1b) into main (4274880) will increase coverage by 0.0%. The diff coverage is 100.0%.

@@          Coverage Diff          @@
##            main    #488   +/-   ##
=====================================
  Coverage   98.5%   98.5%           
=====================================
  Files         42      42           
  Lines       4506    4557   +51     
=====================================
+ Hits        4442    4493   +51     
  Misses        64      64           
Files Changed Coverage Δ
ixmp/core/timeseries.py 98.7% <100.0%> (+<0.1%) :arrow_up:
ixmp/testing/__init__.py 95.9% <100.0%> (+<0.1%) :arrow_up:
ixmp/tests/core/test_timeseries.py 100.0% <100.0%> (ø)
ixmp/tests/test_utils.py 100.0% <100.0%> (ø)
ixmp/utils/__init__.py 98.6% <100.0%> (+<0.1%) :arrow_up:
gidden commented 1 year ago

I think the force push means I can't access my review to change to accept?

gidden commented 1 year ago

Ok, was able to do a new review - thanks @khaeru !