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

clarified source of an error message #1086

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bruceravel
Copy link
Contributor

@bruceravel bruceravel commented Jan 3, 2023

in the put method to the EpicsSignal class, there is a check to be sure that the signal can be written to, i.e. that self.write_access is true. that error message results in an unhelpful traceback in that it provides no information identifying the PV triggering the message. in the case of a deeply nested signal, this error message is unilluminating. this commit adds self.name to the error message.


This is, in my opinion, an example of a common anti-pattern in ophyd. There are many error messages that do a poor job identifying the prima causa of the error, simply resulting in a lengthy traceback that is hard to parse for someone not well versed in ophyd's internals.

In my case, I was, with a lot of poking and prodding, able to identify the source of the error. Had the error message included the name (as in self.name) of the ophyd object, it would have been a much shorter path to identifying the problem.

My solution was to simply append self.name to the error message. Not a perfect solution, but it would at least point the human doing the debugging in the right direction.

I have a hard time believing this is simply a problem for someone like me, who is writing beamline code without also having a deep understanding of Ophyd. I cannot believe that a context-free error message could be helpful even to Ophyd's main developers.

Were I king of the world (or at least of DSSI), I would call for a full audit of ophyd to find all examples of context-free messages like this one. I would then call for agreement on a convention for making better, more helpful, better contextualized error messages.

All right! Rant is finished. Thanks for humoring me 😁

in the put method to the EpicsSignal class, there is a check
to be sure that the signal can be written to, i.e. that
self.write_access is true.  that error message results in an unhelpful
traceback in that it provides no information identifying the PV
triggering the message.  in the case of a deeply nested signal, this
error message is unilluminating.  this commit adds self.name to the
error message.
@@ -2056,7 +2056,7 @@ def put(
use_complete = self._put_complete

if not self.write_access:
raise ReadOnlyError("No write access to underlying EPICS PV")
raise ReadOnlyError(f"No write access to underlying EPICS PV : {self.name}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is an EPICS signal, can you also add the write_pvname to the message? It's one of the diagnostics our instrument teams want to see in such a message.

Copy link
Contributor

@prjemian prjemian Jan 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the message would be helped by putting the write PV name first as stated.

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

Successfully merging this pull request may close these issues.

2 participants