pcdshub / hutch-python

Launcher and config reader for LCLS interactive IPython sessions
https://pcdshub.github.io/hutch-python/
Other
0 stars 18 forks source link

Namespace creation should recognize group with single member #145

Open teddyrendahl opened 6 years ago

teddyrendahl commented 6 years ago

It looks like the namespace generator is being a little too aggressive splitting on underscores. It would be nice if we could determine that a group will a single member and not split on the following underscores in it's name.

An example: xpp_sb2_slits_low.

There is no other device with name xpp_sb2_slits_*. However this is still split

xpp.sb2.low  # IterableNamespace with one member
xpp.sb2.low.slits  # Actual device

Expected Behavior

I think that we should avoid that final split and have the namespace structure just be:

xpp.sb2.low_slits

Is this as quick a fix as I imagined or does this have repercussions I'm not thinking of?

ZLLentz commented 6 years ago

This is neither a quick fix nor a super difficult one. Best is probably to refactor tree_namespace to group everything into a dictionary tree instead of directly into the namespace tree, and then walk the dictionary at the end to construct the namespace tree.

Right now we construct everything as we go, which means we can't know ahead of time whether or not a set will have one element.

ZLLentz commented 6 years ago

This refactor would make it easy to fix the invalid name bug