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
Make listener properties in StartLiveData dynamic #17926
Conversation
lhs = _kernel.funcinspect.lhs_info() | ||
if lhs[0] > 0: # Number of terms on the lhs | ||
raise RuntimeError("Assigning the output of StartLiveData is currently " |
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.
OK is this the fix until we figure out how to deal with optional output workspaces?
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.
After talking to @martyngigg, we decided that for now this will have to be considered a limitation of the simpleapi. There are several issues with capturing the output:
- Unwrapping is not working properly because of the optional "AccumulationWorkspace" output, and there's no easy fix for this.
- Even capturing in a single variable (so capturing output as a tuple without unwrapping) is setting the AccumulationWorkspace argument to the name of the variable on the left.
- There if the name of the first variable on the left matches the value of the "OutputWorkspace" argument, there is very inconsistent / buggy behaviour because now both OutputWorkspace and AccumulationWorkspace have the same name.
- Since OutputWorkspace is being periodically replaced in the ADS, any reference to it you get in Python is invalidated shortly after you get it.
@@ -85,6 +70,38 @@ void StartLiveData::init() { | |||
"completes."); | |||
} | |||
|
|||
/** | |||
* After Instrument property is set copy any properties that the instrument's |
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'm being picky: I'd say that this comment will not necessarily apply to future modifications since the listener will not be tied to the instrument.
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.
Agreed, I thought about that as well. But that will be a separate pull request, and so for now this comment reflects the behaviour implemented here.
The code here will need to be modified again once we make that change, since the propName == "Instrument"
condition will no longer be correct. Need to make sure to update this comment at that point.
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.
Sounds fine. Make a comment somewhere so that you don't forget. But you're right we shouldn't add comments to match future modifications.
} | ||
|
||
// Add new listener's properties | ||
auto listener = LiveListenerFactory::Instance().create( |
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.
Might be useful to have a comment about this (following) code relating to the transfer of ownership. Or to put this in a separate named method.
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.
Addressed by refactoring with two helper functions and simplifying code a bit.
@@ -40,6 +41,7 @@ Python Algorithms | |||
|
|||
- :ref:`MatchPeaks <algm-MatchPeaks>` performs circular shift operation (numpy roll) along the x-axis to align the peaks in the spectra. | |||
- :ref:`FindEPP <algm-FindEPP>` is improved to better determine the initial parameters and range for the fitting. | |||
- :ref:`StartLiveData <algm-StartLiveData>` can now accept LiveListener properties as parameters, based on the Instrument parameter. |
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.
I would be careful about "Instrument parameter". I initially misread this as "Instrument parameters" which is a completely different thing.
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.
I've tried clarifying the wording a bit, let me know if it works better this way.
@@ -40,6 +41,7 @@ Python Algorithms | |||
|
|||
- :ref:`MatchPeaks <algm-MatchPeaks>` performs circular shift operation (numpy roll) along the x-axis to align the peaks in the spectra. | |||
- :ref:`FindEPP <algm-FindEPP>` is improved to better determine the initial parameters and range for the fitting. | |||
- :ref:`StartLiveData <algm-StartLiveData>` can now accept LiveListener properties as parameters, based on the Instrument parameter. |
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.
I see that there is no concepts page for the LiveListener. We should definitely add that as part of a separate PR. However, I note that the algorithm rst for StartLiveData has not been updated as part of this PR. I think that it would be important to have some information in there about the fact that the algorithm is dynamically going to be picking up properties from it's listener such as SpectrumList
and PeriodList
otherwise that information will just have vanished, and I believe that these changes were originally made (the ones you just reverted), because users complained about not seeing documentation for them.
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.
Addressed by adding a section on listener properties to StartLiveData rst.
PeriodList and SpectraList are properties of the ISISHistoDataListener. They | ||
are available as arguments in this call because Instrument is set to | ||
'ISIS_Histogram', which uses that listener. | ||
|
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.
Good documentation!
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.
Thank you! :)
As required by More Flexible LiveListener design document.
This effectively reverts #234, plus modifications and additions to still achieve its purpose.
SpectraList and PeriodList properties are no longer hard-coded as part of StartLiveData.
Instead, StartLiveData will dynamically add the properties of the specific LiveListener it uses once the Instrument is set.
The Python simpleapi has been updated with a specialized version of StartLiveData to allow evaluating other arguments based on the value of the Instrument argument.
To test:
See associated issue for testing GUI behaviour.
For Python interface:
FakeISISHistoDAE
algorithm withNPeriods=5
,NSpectra=10
andNBins=100
.This should work both before and after this change.
Fixes #17912.
Release notes have been updated.
Reviewer
Please comment on the following (full description):
Code Review
Functional Tests
Do changes function as described? Add comments below that describe the tests performed?
How do the changes handle unexpected situations, e.g. bad input?
Has the relevant documentation been added/updated?
Is user-facing documentation written in a user-friendly manner?
Has developer documentation been updated if required?
Does everything look good? Comment with the ship it emoji but don't merge. A member of
@mantidproject/gatekeepers
will take care of it.