-
Notifications
You must be signed in to change notification settings - Fork 126
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
Refactor LoadHelper to use NeXus::File #38766
base: main
Are you sure you want to change the base?
Refactor LoadHelper to use NeXus::File #38766
Conversation
f21ab79
to
07ccece
Compare
07ccece
to
50f0ee8
Compare
👋 Hi, @peterfpeterson, Conflicts have been detected against the base branch. Please rebase your branch against the base branch. |
50f0ee8
to
aef68a0
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.
Still trying to figure out if LoadHelper::recurseAndAddNexusFieldsToWsRun
is equivalent to the original. Here are some comments in the meantime. I'm not sure if the NeXus files close automatically when they go out of scope; if not, they need to be closed.
g_log.debug() << "convertNexusToProperties: Error loading " << filename; | ||
throw Kernel::Exception::FileError("Unable to open File:", filename); | ||
} | ||
LoadHelper::addNexusFieldsToWsRun(nxfileID, runDetails); | ||
NXclose(&nxfileID); | ||
|
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.
The file needs to be closed
NXstatus nxStat = NXopen(filename.c_str(), NXACC_READ, &nxHandle); | ||
if (nxStat != NXstatus::NX_ERROR) { | ||
try { | ||
::NeXus::File nxHandle(filename, NXACC_READ); |
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.
The file is opened but not closed.
NXhandle nxHandle; | ||
NXopen(filename.c_str(), NXACC_READ, &nxHandle); | ||
|
||
::NeXus::File nxHandle(filename, NXACC_READ); |
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.
The file is opened but not closed.
NXclose(&nxfileID); | ||
|
||
try { | ||
::NeXus::File nxfileID(filename, NXACC_READ); |
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.
The file is opened but not closed.
|
||
if (nxStat != NXstatus::NX_ERROR) { | ||
try { | ||
::NeXus::File nxHandle(m_fileName, NXACC_READ); |
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.
The file is opened but not closed/
|
||
if (nxStat != NXstatus::NX_ERROR) { | ||
try { | ||
::NeXus::File nxHandle(getPropertyValue("Filename"), NXACC_READ); |
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.
The file is opened but not closed.
g_log.debug() << "convertNexusToProperties: Error loading " << nexusfilename; | ||
|
||
try { | ||
::NeXus::File nxfileID(nexusfilename, NXACC_READ); |
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.
The file is opened but not closed.
NXclose(&nxHandle); | ||
// get some information from the NeXus file | ||
try { | ||
::NeXus::File filehandle(m_filename, NXACC_READ); |
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.
The file is opened but not closed.
bool read_property = true; | ||
if (nxinfo.type == NXnumtype::CHAR) { | ||
read_property = (rank == 1); | ||
} else if (isFloat) { |
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 think using isFloat
obscures what is happening in this if/else block. Also, writing this as an if/else block obscures that it is actually a switch of nxinfo.type
. Also, the integer cases aren't implemented in this if/else: should they be?
// generate a name for the property | ||
std::string property_name = (parent_name.empty() ? nxname : parent_name + "." + nxname); | ||
|
||
if (nxinfo.type == NXnumtype::CHAR) { |
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 above, the use of if/else is obscuring that this is a switch over nxinfo.type
. Maybe if there were also an isChar
bool defined?
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.
Also, can this not be one big switch on nxinfo.type
, instead of two separate switches on the same value?
Modify
LoadHelper::addNexusFieldsToWsRun()
to take a::NeXus::File
rather than a napiNXhandle
and update all users of the method. This is part of the consolidation of nexus code in mantid.Refs #38332.
To test:
This is a refactor and all existing tests should continue to pass.
This does not require release notes because it is a refactor.
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.