Skip to content

Conversation

searscr
Copy link
Contributor

@searscr searscr commented Jul 17, 2025

Description of work

A bug was found in SaveNXSPE where an exception would be raised if trying to create and open a group with the same name as the group you are in. For example creating the group /something/something would raise an exception. This adds a flag for opening data that will allow us to open groups with the same name without corrupting the Nexus address if we try to open the same data multiple times.

Fixes #39672 .
Relates to EWM Defect 12236

To test:

The following script should run and successfully save the file.

import os
import numpy

# Create dummy workspace.
out_ws = CreateSimulationWorkspace(Instrument="MARI", BinParams="0,500,2000")
out_ws.setY(0, numpy.array([10.0, 50.0, 30.0, 60.0]))
AddSampleLog(out_ws, 'Ei', LogText='321', LogType='Number', NumberType='Double')
out_ws.setDistribution(True)

file_path = os.path.join(config["defaultsave.directory"], "NXSPEData.nxspe")

data = RenameWorkspace(out_ws)
SaveNXSPE(data, file_path,Psi=32)

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

  • Is the code of an acceptable quality?
  • Does the code conform to the coding standards?
  • Are the unit tests small and test the class in isolation?
  • If there is GUI work does it follow the GUI standards?
  • If there are changes in the release notes then do they describe the changes appropriately?
  • Do the release notes conform to the release notes guide?

Functional Tests

  • Do changes function as described? Add comments below that describe the tests performed?
  • Do the changes handle unexpected situations, e.g. bad input?
  • Has the relevant (user and developer) documentation been added/updated?

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.

@searscr searscr added the Bug Issues and pull requests that are regressions or would be considered a bug by users (e.g. crashing) label Jul 17, 2025
@searscr searscr added this to the Release 6.13.1 milestone Jul 17, 2025
@sf1919 sf1919 added High Priority An issue or pull request that if not addressed is severe enough to postponse a release. Patch Candidate Urgent issues that must be included in a patch following a release labels Jul 17, 2025
Copy link
Member

@AndreiSavici AndreiSavici left a comment

Choose a reason for hiding this comment

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

Needs release notes. I can still make it fail if I change the last two lines to

RenameWorkspace(out_ws, OutputWorkspace="data/data")
SaveNXSPE("data/data", file_path,Psi=32)

// check that we can make '/test_group/test_group'
TS_ASSERT_THROWS_NOTHING(file.makeGroup(grp, "NXsample", true));
TS_ASSERT_THROWS_NOTHING(file.makeGroup(grp, "NXdata", true));
TS_ASSERT_EQUALS(file.getPath(), "/test_group/test_group");
Copy link
Contributor

Choose a reason for hiding this comment

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

I am pretty certain, for a workspace named "data", that this line will actually create a a dataset called "/data/data/data". We need a test for this inside SaveNXSETest

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes you are correct, it is opening /data/data/data. Would a nominal test with the workspace named data be sufficient?

searscr and others added 3 commits July 17, 2025 22:37
Release notes for 6.13.1 will be added at the end in a spearate PR.
rboston628
rboston628 previously approved these changes Jul 18, 2025
Copy link
Contributor

@rboston628 rboston628 left a comment

Choose a reason for hiding this comment

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

I believe Andrei still approves. Thank you for adding the more sensible error message and new tests

@cailafinn cailafinn self-assigned this Jul 21, 2025
Copy link
Contributor

@cailafinn cailafinn left a comment

Choose a reason for hiding this comment

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

Looks good, just a quick question about the test that's been added:

@sf1919 sf1919 linked an issue Jul 21, 2025 that may be closed by this pull request
Copy link
Contributor

@cailafinn cailafinn left a comment

Choose a reason for hiding this comment

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

Thanks for updating that test. Looks good to me now.

@cailafinn cailafinn enabled auto-merge (squash) July 22, 2025 09:14
@cailafinn cailafinn disabled auto-merge July 22, 2025 09:14
@cailafinn cailafinn enabled auto-merge (squash) July 22, 2025 09:15
@cailafinn cailafinn merged commit eea692d into release-next Jul 22, 2025
10 checks passed
@cailafinn cailafinn deleted the fix_SaveNXSPE_bug branch July 22, 2025 11:34
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) High Priority An issue or pull request that if not addressed is severe enough to postponse a release. Patch Candidate Urgent issues that must be included in a patch following a release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SaveNXSPE can't save a workspace named "data"
6 participants