Skip to content

Commit 1968066

Browse files
authored
Merge pull request #51 from simvue-io/handle_exceptions
Set status to failed or terminated as appropriate
2 parents 05fd877 + b69ecb8 commit 1968066

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change log
22

3+
## v0.9.0
4+
5+
* Set status to `failed` or `terminated` if the context manager is used and there is an exception.
6+
37
## v0.8.0
48

59
* Support NumPy arrays, PyTorch tensors, Matplotlib and Plotly plots and picklable Python objects as artifacts.

simvue/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
from simvue.client import Client
33
from simvue.handler import Handler
44
from simvue.models import RunInput
5-
__version__ = '0.8.0'
5+
__version__ = '0.9.0'

simvue/run.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,18 @@ def __init__(self, mode='online'):
160160
def __enter__(self):
161161
return self
162162

163-
def __exit__(self, type, value, tb):
163+
def __exit__(self, type, value, traceback):
164164
if self._name and self._status == 'running':
165-
self.set_status('completed')
165+
if not type:
166+
self.set_status('completed')
167+
else:
168+
self.log_event(f"{type.__name__}: {value}")
169+
if type.__name__ in ('KeyboardInterrupt'):
170+
self.set_status('terminated')
171+
else:
172+
if traceback:
173+
self.log_event(f"Traceback: {traceback}")
174+
self.set_status('failed')
166175

167176
def _check_token(self):
168177
"""

0 commit comments

Comments
 (0)