-
Notifications
You must be signed in to change notification settings - Fork 127
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
Adding group inputs to SaveNXcanSAS algorithm #38692
base: main
Are you sure you want to change the base?
Conversation
I'm removing the high priority as the cppcheck hackathon starts today. This PR may well attract conflicts so it might be best to wait until Thursday when the hackathon has finished before dealing with them. |
👋 Hi, @adriazalvarez, Conflicts have been detected against the base branch. Please rebase your branch against the base branch. |
Lots of conflicting PRs will be merged today and tomorrow, so I will wait until then to fix the conflicts. |
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.
Just a couple of code notes.
Working well functionally, just noticed that the files produced by the script don't have the .nxs
extension. Is this the same as the original behaviour or is this an introduced change?
92c833d
to
dd28cd1
Compare
@cailafinn Yes, originally the algorithm was not producing any extension when the filename property does not specify any. I have quickly added a helper function to add extension by default (.h5), but if it's not something we want here I can revert 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.
Just one more note on the filepath handling.
auto const addDigit = [&](int index) { | ||
return isGroup ? (index < 10 ? "0" + std::to_string(index) : std::to_string(index)) : ""; | ||
}; | ||
return baseFilename + addDigit(index) + ".h5"; |
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.
It looks like you could use the NX_CANSAS_EXTENSION
you defined on L33 here.
It may also be worth editing this method and the parameter in saveSingleWorkspaceFile
to handle baseFilename
as a std::filesystem::path
. This would allow us to use things like has_extension
to only append the .h5
extension (with replace_extension
) if the user hasn't supplied one already.
…ccept workspace groups as inputs
…e condition short circuits if it is not a valid workspace and does not cause trouble with other species of workspaces like table or md workspaces
…eginning of each test
7c73624
to
7ad7d98
Compare
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 looks good to me now. Functionally tested using the provided script, producing files as expected. File names are correctly indexed. Code looking good.
@MialLewis This is now ready for gatekeeping when you are.
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.
Code looks really good, thanks.
Two queries to respond to.
@@ -342,7 +335,6 @@ class SaveNXcanSASTest : public CxxTest::TestSuite { | |||
void test_that_2D_workspace_is_saved_correctly() { | |||
// Arrange | |||
NXcanSASTestParameters parameters; | |||
removeFile(parameters.filename); |
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 a test was to error and the clean up call at the end missed, will subsequent tests fail now this has been removed?
If this could happen it could make it harder to identify and resolve any bugs revealed by the tests.
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 could see, when constructing the NXcanSASTestParameters
struct, a new temporary file was created on the respective system temporary folder, the file was immediately removed because all that was needed for saving the NXcansas file was the path of the file. I have instead used the method Poco::TemporaryFile::tempName()
on the NXcanSASTestHelper.h
file to just retrieve the path of a temporary file in the folder without creating one, so there is no need to delete it just after creation.
If a test fails, there won't be a cascading effect, as the temporary names are uniquely generated and collisions would be extremely rare. If for some reason a temporary file is generated but the test fails, the file would be on a system temporary folder, and probably removed automatically by the system shortly after.
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.
We are trying to move away from Poco with File and Path. I know @jclarkeSTFC has been working on that for #37868 . I'm wondering if we should also be avoiding using Poco::TemporaryFile
too.
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.
https://en.cppreference.com/w/cpp/io/c/tmpnam seems like a direct replacement?
I'm aware the name collision is unlikely, but as we know it is possible I'm not sure we should be introducing it.
Description of work
This PR refactors the SaveNXcanSAS algorithm to accept group workspaces as inputs. This prepares the ground for a future algorithm for saving polarized SANS data that will need the feature. More information on : #38504
Summary of work
To save groups there are three main changes to notice:
InputWorkspace
property accepts a pointer to the base classWorkspace
that can be downcasted to a matrix workspace or group workspace. To be able to still filter appropiate compatible data and distinguish between group and matrix workspace I have added a customLambdaValidator
that does unit and compatible bins validation to each workspace in the selected input groups, that will filter appropiate groups. Additionally, it also filters compatible workspaces.processGroups
methods from theAlgorithm
base class, so that it will callexec
when it needs to process matrix workspaces andprocessGroups
for processing group workspaces.Fixes #38504.
Further detail of work
To test:
Reviewer
Please comment on the points listed below (full description).
Your comments will be used as part of the gatekeeper process, so please comment clearly on what you have checked during your review. If changes are made to the PR during the review process then your final comment will be the most important for gatekeepers. In this comment you should make it clear why any earlier review is still valid, or confirm that all requested changes have been addressed.
Code Review
Functional Tests
Does everything look good? Mark the review as Approve. A member of
@mantidproject/gatekeepers
will take care of it.Gatekeeper
If you need to request changes to a PR then please add a comment and set the review status to "Request changes". This will stop the PR from showing up in the list for other gatekeepers.