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

Make listener properties in StartLiveData dynamic #17926

Merged
merged 10 commits into from Nov 7, 2016

Conversation

MikeHart85
Copy link
Contributor

@MikeHart85 MikeHart85 commented Nov 1, 2016

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:

  1. Run a FakeISISHistoDAE algorithm with NPeriods=5, NSpectra=10 and NBins=100.
  2. Run the following code in the console:
ConfigService.setFacility('TEST_LIVE')
StartLiveData(Instrument='ISIS_Histogram', OutputWorkspace='OutWS', AccumulationWorkspace='AccWS', UpdateEvery=1, AccumulationMethod='Replace', PeriodList=[1,3], SpectraList=[2,4,6])

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
  • Is the code of an acceptable quality?
  • Does the code conform to the coding standards? Is it well structured with small focussed classes/methods/functions?
  • Are there unit/system tests in place? Are the unit tests small and test the a class in isolation?
  • If there are changes in the release notes then do they describe the changes appropriately?
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.

@MikeHart85 MikeHart85 added Bug Issues and pull requests that are regressions or would be considered a bug by users (e.g. crashing) State: In Progress labels Nov 1, 2016
@MikeHart85 MikeHart85 added this to the Release 3.9 milestone Nov 1, 2016
lhs = _kernel.funcinspect.lhs_info()
if lhs[0] > 0: # Number of terms on the lhs
raise RuntimeError("Assigning the output of StartLiveData is currently "
Copy link
Contributor

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?

Copy link
Contributor Author

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:

  1. Unwrapping is not working properly because of the optional "AccumulationWorkspace" output, and there's no easy fix for this.
  2. 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.
  3. 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.
  4. 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
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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(
Copy link
Contributor

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.

Copy link
Contributor Author

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.
Copy link
Contributor

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.

Copy link
Contributor Author

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.
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good documentation!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you! :)

@OwenArnold
Copy link
Contributor

:shipit:

@AndreiSavici AndreiSavici merged commit 865f001 into master Nov 7, 2016
@AndreiSavici AndreiSavici deleted the 17912_Dynamic_Listener_Properties branch November 7, 2016 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues and pull requests that are regressions or would be considered a bug by users (e.g. crashing)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants