aim
aim copied to clipboard
TypeError raised when accessing run.active after calling run.close()
🐛 Bug
When checking the active property of a run object after calling run.close(), a TypeError is raised.
In [5]: run = aim.Run()
In [6]: run.active
Out[6]: True
In [7]: run.close()
In [8]: run.active
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[8], line 1
----> 1 run.active
File ~/.pyenv/versions/3.11.8/envs/nabla-3.11.8/lib/python3.11/site-packages/aim/sdk/run.py:217, in StructuredRunMixin.active(self)
209 @property
210 def active(self):
211 """Check if run is active or not.
212
213 :getter: Returns run's active state.
214 :type: bool
215 """
217 if self.end_time:
218 return False
219 else:
File ~/.pyenv/versions/3.11.8/envs/nabla-3.11.8/lib/python3.11/site-packages/aim/sdk/run.py:192, in StructuredRunMixin.end_time(self)
187 """Run finalization time [UTC] as timestamp.
188
189 :getter: Returns run finalization time.
190 """
191 try:
----> 192 return self.meta_run_tree['end_time']
193 except KeyError:
194 # run saved with old version. fallback to sqlite data
195 return self.props.end_time
TypeError: 'NoneType' object is not subscriptable
To reproduce
- Initialize a run object using aim.Run().
- Check the active property of the run object. (It returns True as expected).
- Close the run object using run.close().
- Check the active property of the run object again.
Expected behavior
After calling run.close(), the active property should return False without raising an exception.
Environment
- aim==3.19.2 aim-ui==3.19.2 aimrecords==0.0.7 aimrocks==0.4.0
- Python 3.11.8
- pip 24.0
- Linux
Additional information
The error appears to be caused by self.meta_run_tree['end_time'] returning None.
A check should be added to ensure self.meta_run_tree is not None before attempting to read the end_time key. Thank you for looking into this issue.
Hey @awav! Thank a lot for opening the issue. I'll investigate it and would post an update once the fix is done.