-
Notifications
You must be signed in to change notification settings - Fork 52
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
P11 develop #800
P11 develop #800
Conversation
…y for shutter-like objects inside P11 HO (Bixente)
…y for shutter-like objects inside P11 HO (Bixente)
@@ -121,7 +121,7 @@ def load_positions(self): | |||
def get_position_list(self): | |||
return list(self._positions.keys()) | |||
|
|||
def get_properties_(self, position_index, property_name): | |||
def get_properties(self, position_index, property_name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I am not mistaken, there is already a get_properties
in one of the parent classes. Namely in HardwareObjectNode
, via HardwareObject
and AbstractActuator
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comment. Changed.
@unique | ||
class BaseValueEnum(Enum): | ||
"""Defines only the compulsory values.""" | ||
OPEN = "OPEN" | ||
CLOSED = "CLOSED" | ||
MOVING = "MOVING" | ||
UNKNOWN = "UNKNOWN" | ||
|
||
VALUES=BaseValueEnum | ||
"""Defines only the compulsory values.""" | ||
|
||
OPEN = "OPEN" | ||
CLOSED = "CLOSED" | ||
MOVING = "MOVING" | ||
UNKNOWN = "UNKNOWN" | ||
|
||
VALUES = BaseValueEnum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it inherits from AbstractShutter, no need to do this. Please see my comment comment below
def get_value(self): | ||
return self.update_fast_shutter() | ||
|
||
@property | ||
def is_open(self): | ||
return self.get_value() == self.VALUES.OPEN | ||
|
||
@property | ||
def is_closed(self): | ||
return self.get_value() == self.VALUES.CLOSED | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to define FastShutterVakue enum. As it inherits from AbstractNState, uou can simply do it in your xml file, like this:
<values>{"OPEN": "Open", "CLOSED": "Closed"}</values>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comment. What is best way to adress it from the code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you, please, be more explicit. The above comment means, that your self.VALUES.OPEN.value is "Open", as you probably need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is my xml:
FastShutter<tangoname>p11/shutter/fs</tangoname>
<channel type="tango" name="value" polling="500">value</channel>
<values>{"OPEN": "Open", "CLOSED": "Closed"}</values>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And mxcube is not happy:
File "/mxcubecore/mxcubecore/HardwareRepository.py", line 545, in parse_xml
hardware_obj = HardwareObjectFileParser.parse_string(xml_string, ho_name)
File "/mxcubecore/HardwareObjectFileParser.py", line 78, in parse_string
xml.sax.parseString(str.encode(xml_hardware_object), cur_handler)
File "/usr/lib/python3.7/xml/sax/init.py", line 48, in parseString
parser.parse(inpsrc)
File "/usr/lib/python3.7/xml/sax/expatreader.py", line 111, in parse
xmlreader.IncrementalParser.parse(self, source)
File "/usr/lib/python3.7/xml/sax/xmlreader.py", line 125, in parse
self.feed(buffer)
File "/usr/lib/python3.7/xml/sax/expatreader.py", line 217, in feed
self._parser.Parse(data, isFinal)
File "../Modules/pyexpat.c", line 417, in StartElement
File "/usr/lib/python3.7/xml/sax/expatreader.py", line 333, in start_element
self._cont_handler.startElement(name, AttributesImpl(attrs))
File "HardwareObjectFileParser.py", line 276, in startElement
new_object = instanciate_class(module_name, class_name, object_name)
HardwareObjectFileParser.py", line 105, in instanciate_class
module = load_module(module_name)
File "/gpfs/local/shared/MXCuBE/mxcubecore/mxcubecore/HardwareObjectFileParser.py", line 91, in load_module
return import(hardware_object_name, globals(), locals(), [""])
File "mxcubecore/HardwareObjects/DESY/P11FastShutter.py", line 41, in
class P11FastShutter(AbstractNState):
File "/usr/lib/python3.7/enum.py", line 862, in unique
for name, member in enumeration.members.items():
AttributeError: type object 'P11FastShutter' has no attribute 'members'
2023-11-08 18:23:30,869 |HWR |ERROR | Failed to load Hardware object /fast-shutter
@unique | ||
class BaseValueEnum(Enum): | ||
"""Defines only the compulsory values.""" | ||
OPEN = "OPEN" | ||
CLOSED = "CLOSED" | ||
MOVING = "MOVING" | ||
UNKNOWN = "UNKNOWN" | ||
|
||
VALUES=BaseValueEnum | ||
"""Defines only the compulsory values.""" | ||
|
||
OPEN = "OPEN" | ||
CLOSED = "CLOSED" | ||
MOVING = "MOVING" | ||
UNKNOWN = "UNKNOWN" | ||
|
||
VALUES = BaseValueEnum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you inherit from AbstractShutter, no need to do this. Please see my comment below.
Dear @agruzinov,
And in the init, you simply add: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_get_property
vs. get_property
, see earlier inline comment
…ate changes in qt part-multi_state_brick.py (PR800)
…s in the beamline_config.yml is set strictly to 0.0. This has also fixed the red None field for Characterisation tab.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still seems to include changes (whole commits?) that have already been merged. The pull request contains 159 commits! To me this is usually a hint that some git operations (rebase maybe?) did not go well. I recommend to take some time to investigate and fix this. Maybe make sure to extract your actual changes from the ones that are merged upstream, then squash some commits to get the number down from 159.
Now for review itself I will only look at what is outside of the DESY
directory.
mxcubecore/Command/Tango.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to contain only cosmetic changes. Do we want such changes in a pull request for a file that is otherwise untouched? What is the policy? @marcus-oscarsson
.github/workflows/tests.yml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change was already merged in be49e6d
self.log.debug(f" Found sample {smp} is loaded") | ||
self.log.debug(f" getting loaded {self.get_loaded_sample()}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know, the recommendation for logging in Python is to always use the "printf style formatting" (with %
interpolation): https://docs.python.org/3/library/stdtypes.html#old-string-formatting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is true. The best to satisfy both python recommendations and pylint would be to change to:
msg = f" Found sample {smp} is loaded\n getting loaded {self.get_loaded_sample()}"
self.log.debug(msg)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does pylint complain about printf style formatting for logging? It shouldn't, should it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately it does both - complains about not using f-string (which is in the log) and complains when using f-string in log. A bit of a mess, really.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using pylint 2.15.4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this okay?
self.log.debug("Found sample %s is loaded", smp)
self.log.debug(" getting loaded %s", self.get_loaded_sample())
Seems fine for me with the same Pylint version 2.15.4
and the same .pylintrc
configuration file.
…omatically after data collection.
Iam sorry @agruzinov I lost track of things, is this PR still active ? |
In principle yes. I guess the main issue for now is the some problems with rebase. Maybe it is better to close it for now and open a new PR then?? |
PR needs to be resubmitted. Closing. |
if self._updating_value: | ||
return # Already updating, avoid recursion | ||
|
||
self._updating_value = True | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@agruzinov, could you tell us, please, where in the sample changer you get recursion ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.focus_sizes = { | ||
-1: {"label": "unknown", "size": (0.2, 0.2)}, | ||
0: {"label": "flat", "size": (0.2, 0.2)}, | ||
1: {"label": "200x200", "size": (0.2, 0.2)}, | ||
2: {"label": "100x100", "size": (0.1, 0.1)}, | ||
3: {"label": "50x50", "size": (0.05, 0.05)}, | ||
4: {"label": "20x20", "size": (0.02, 0.02)}, | ||
5: {"label": "4x9", "size": (0.009, 0.004)}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have this both in DigitalZoomMotor and here. I am afraid this is prone to errors. Is it not possible to have it only in one place and get it in the other Hardware object
Here is another round of debug after upgrading to the latest code (mostly in DESY HO).