Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespace connects to lazy components #103

Closed
teddyrendahl opened this issue Apr 9, 2018 · 3 comments · Fixed by #107
Closed

Namespace connects to lazy components #103

teddyrendahl opened this issue Apr 9, 2018 · 3 comments · Fixed by #107
Labels

Comments

@teddyrendahl
Copy link
Contributor

Expected Behavior

There are components in the AreaDetector module that are not lazy. When we create the namespaces and call getattr on these they attempt to connect. This causes issues including a large start-up time while we wait for connections.

Current Behavior

2018-04-09 10:51:48 - PID 4477           utils.py: 47  safe_load          INFO     Loading default groups...
2018-04-09 10:51:48 - PID 4477       namespace.py: 36  class_namespace    DEBUG    Create class_namespace cls=EpicsMotor, scope=hutch_python.db
2018-04-09 10:52:03 - PID 4477           utils.py: 52  safe_load          ERROR    Failed to load default groups
2018-04-09 10:52:03 - PID 4477           utils.py: 53  safe_load          DEBUG    Failed to connect to MFX:DG2:P6740:IMAGE2:BayerPattern_RBV
Traceback (most recent call last):
  File "/reg/g/pcds/pyps/conda/py36/envs/pcds-1.0.0/lib/python3.6/site-packages/hutch_python/utils.py", line 49, in safe_load
    yield
  File "/reg/g/pcds/pyps/conda/py36/envs/pcds-1.0.0/lib/python3.6/site-packages/hutch_python/load_conf.py", line 258, in load_conf
    default_class_namespace('EpicsMotor', 'motors', cache)
  File "/reg/g/pcds/pyps/conda/py36/envs/pcds-1.0.0/lib/python3.6/site-packages/hutch_python/load_conf.py", line 316, in default_class_namespace
    objs = class_namespace(cls, scope='hutch_python.db')
  File "/reg/g/pcds/pyps/conda/py36/envs/pcds-1.0.0/lib/python3.6/site-packages/hutch_python/namespace.py", line 65, in class_namespace
    accumulate(obj, scope_objs, cache)
  File "/reg/g/pcds/pyps/conda/py36/envs/pcds-1.0.0/lib/python3.6/site-packages/hutch_python/namespace.py", line 58, in accumulate
    accumulate(sub_obj, scope_objs, cache)
  File "/reg/g/pcds/pyps/conda/py36/envs/pcds-1.0.0/lib/python3.6/site-packages/hutch_python/namespace.py", line 58, in accumulate
    accumulate(sub_obj, scope_objs, cache)
  File "/reg/g/pcds/pyps/conda/py36/envs/pcds-1.0.0/lib/python3.6/site-packages/hutch_python/namespace.py", line 57, in accumulate
    sub_obj = getattr(obj, comp_name)
  File "/reg/g/pcds/pyps/conda/py36/envs/pcds-1.0.0/lib/python3.6/site-packages/ophyd/device.py", line 176, in __get__
    instance._signals[self.attr] = self.create_component(instance)
  File "/reg/g/pcds/pyps/conda/py36/envs/pcds-1.0.0/lib/python3.6/site-packages/ophyd/device.py", line 134, in create_component
    cpt_inst.wait_for_connection()
  File "/reg/g/pcds/pyps/conda/py36/envs/pcds-1.0.0/lib/python3.6/site-packages/ophyd/signal.py", line 474, in wait_for_connection
    self._read_pv.pvname)
TimeoutError: Failed to connect to MFX:DG2:P6740:IMAGE2:BayerPattern_RBV

Possible Solution

We should skip all non-lazy components while creating namespaces.

@ZLLentz
Copy link
Member

ZLLentz commented Apr 9, 2018

Should we unilaterally reject all lazy devices, even those that match the class? I think it's possible to do this in a way where we minimize the getattrs but still catch the things we want.

@teddyrendahl
Copy link
Contributor Author

I am kind of convinced that should avoid using any non-lazy components in our devices which we means this edge case will only exist when dealing with things like AreaDetector. If this is going to be the case I think it is fine to drop everything. Not too concerned about making groups for peoples AreaDetector plugins. If they want it they can do it explicitly.

@ZLLentz
Copy link
Member

ZLLentz commented Apr 9, 2018

OK, I'll drop all the lazy, but I'm also taking the opportunity to minimize the number of times we recurse each device

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants