unexpected behaviour of session env dict
it seems like there is a problem with the update of the session env dict regarding objects imported via config.get
. Looking at the output below it seems like config objects are only inserted into the curren_session.env_dict after executing another operation on the env_dict which seems weird to me.
BLISS [1]: import numpy
...: from bliss import current_session
BLISS [2]: a = numpy.array([1])
BLISS [3]: next((key for key, obj in current_session.env_dict.items() if obj is a), None)
Out [3]: 'a'
BLISS [4]: b = numpy.array([2])
...: print(next((key for key, obj in current_session.env_dict.items() if obj is b), None))
b
BLISS [6]: config.get('diode2')
Out [6]: <bliss.controllers.simulation_diode.SimulationDiodeSamplingCounter object at 0x7f2486f60b10>
BLISS [7]: print(next((key for key, obj in current_session.env_dict.items() if obj is diode2), None))
_
BLISS [8]: print(next((key for key, obj in current_session.env_dict.items() if obj is diode2), None))
diode2
BLISS [9]: config.get('diode3')
Out [9]: <bliss.controllers.simulation_diode.SimulationDiodeSamplingCounter object at 0x7f2486317f90>
BLISS [10]: print(next((key for key, obj in current_session.env_dict.items() if obj is diode3), None))
_
BLISS [11]: print(next((key for key, obj in current_session.env_dict.items() if obj is diode3), None))
diode3
while things work for the numpy arrays (or any other object) as expected this is not the case for diode2 and diode3 (cells 7 and 10)
actually a simple invoking the env_dict once is good enough to trigger the update"
BLISS [24]: config.get('diode8')
Out [24]: <bliss.controllers.simulation_diode.SimulationDiodeSamplingCounter object at 0x7f2485cc7350>
BLISS [25]: current_session.env_dict
Out [25]: {#'__builtins__': ... and a lot more}
BLISS [26]: print(next((key for key, obj in current_session.env_dict.items() if obj is diode8), None))
diode8