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

Unable to open SANS interface if incorrect user file path is saved #38118

Open
rbauststfc opened this issue Oct 1, 2024 · 0 comments
Open

Unable to open SANS interface if incorrect user file path is saved #38118

rbauststfc opened this issue Oct 1, 2024 · 0 comments
Labels
Bug Issues and pull requests that are regressions or would be considered a bug by users (e.g. crashing) ISIS Team: LSS Issue and pull requests managed by the LSS subteam at ISIS Reported By User Issues that were found or highlighted by a user/scientist SANS Issues and pull requests related to SANS
Milestone

Comments

@rbauststfc
Copy link
Contributor

rbauststfc commented Oct 1, 2024

Describe the bug

A user managed to set their user file path in the ISIS SANS GUI to just a directory rather than a full file path - it's still not clear how this would have been possible via the GUI. Having managed to do this, they were subsequently unable to open the SANS GUI as it would throw an unexpected exception (see stack trace in Additional context section below).

The GUI holds on to the previous user file path, storing it using QSettings. The following script, run in the Workbench script editor, worked to clear the settings and allow the SANS GUI to open again:

from qtpy.QtCore import QSettings

settings = QSettings()
settings.beginGroup("Mantid/ISISSANS")
settings.remove("user_file")
settings.endGroup()

To Reproduce

  1. As explained, it's not currently clear how this state can be recreated via the GUI. Instead, run the following script to store the path to a directory in the relevant settings:
from qtpy.QtCore import QSettings

settings = QSettings()
settings.beginGroup("Mantid/ISISSANS")
settings.setValue("user_file", <path to directory>)
settings.endGroup()
  1. Attempt to open the ISIS SANS interface. There should be an unexpected exception and Mantid will ask if you want to terminate or continue.

Expected behavior

If there is an issue with the path saved in the settings then we should just remove it from the settings and load the interface with the user file input left blank.

Platform/Version (please complete the following information):

  • OS: originally occurred on IDAaaS and have reproduced on Windows, although a slightly different error type is thrown.
  • Mantid Version: at least as far back as 6.8

Additional context
Stack trace on Windows:

File "C:\forks\mantid\qt\applications\workbench\workbench\app\mainwindow.py", line 393, in <lambda>
    action.triggered.connect(lambda checked_py, script=script: self.launch_custom_python_gui(script))
  File "C:\forks\mantid\qt\applications\workbench\workbench\app\mainwindow.py", line 353, in launch_custom_python_gui
    self.interface_executor.execute(open(filename).read(), filename)
  File "C:\forks\mantid\qt\python\mantidqt\mantidqt\widgets\codeeditor\execution.py", line 153, in execute
    executor.execute(code_str, filename, flags, self.globals_ns, line_offset)
  File "C:\forks\mantid\qt\python\mantidqtinterfaces\mantidqtinterfaces\ISIS_SANS.py", line 35, in <module>
    run_tab_presenter = RunTabPresenter(SANSFacility.ISIS, run_tab_model=RunTabModel(), view=isis_sans_reduction_view)
  File "C:\forks\mantid\scripts\SANS\sans\gui_logic\presenter\run_tab_presenter.py", line 233, in __init__
    self.set_view(view)
  File "C:\forks\mantid\scripts\SANS\sans\gui_logic\presenter\run_tab_presenter.py", line 360, in set_view
    self._view.gui_properties_handler = SANSGuiPropertiesHandler(
  File "C:\forks\mantid\scripts\SANS\sans\gui_logic\gui_common.py", line 313, in __init__
    self._set_out_defaults()
  File "C:\forks\mantid\scripts\SANS\sans\gui_logic\gui_common.py", line 327, in _set_out_defaults
    load_func(*args)
  File "C:\forks\mantid\scripts\Interface\ui\sans_isis\sans_data_processor_gui.py", line 612, in set_out_default_user_file
    self._call_settings_listeners(lambda listener: listener.on_user_file_load())
  File "C:\forks\mantid\scripts\Interface\ui\sans_isis\sans_data_processor_gui.py", line 273, in _call_settings_listeners
    target(listener)
  File "C:\forks\mantid\scripts\Interface\ui\sans_isis\sans_data_processor_gui.py", line 612, in <lambda>
    self._call_settings_listeners(lambda listener: listener.on_user_file_load())
  File "C:\forks\mantid\scripts\SANS\sans\gui_logic\presenter\run_tab_presenter.py", line 132, in on_user_file_load
    self._presenter.on_user_file_load()
  File "C:\forks\mantid\scripts\SANS\sans\gui_logic\presenter\run_tab_presenter.py", line 397, in on_user_file_load
    user_file_items = FileLoading.load_user_file(file_path=user_file_path, file_information=self._file_information)
  File "C:\forks\mantid\scripts\SANS\sans\gui_logic\models\file_loading.py", line 26, in load_user_file
    return FileLoading._parse_legacy(file_path, file_information)
  File "C:\forks\mantid\scripts\SANS\sans\gui_logic\models\file_loading.py", line 41, in _parse_legacy
    converter = UserFileReaderAdapter(user_file_name=file_path, file_information=file_information)
  File "C:\forks\mantid\scripts\SANS\sans\user_file\txt_parsers\UserFileReaderAdapter.py", line 19, in __init__
    super(UserFileReaderAdapter, self).__init__(file_information=file_information)
  File "C:\forks\mantid\scripts\SANS\sans\user_file\txt_parsers\ParsedDictConverter.py", line 52, in __init__
    data = self.get_state_data(file_information)
  File "C:\forks\mantid\scripts\SANS\sans\user_file\txt_parsers\ParsedDictConverter.py", line 74, in get_state_data
    if DetectorId.INSTRUMENT in self._input_dict:
  File "C:\forks\mantid\scripts\SANS\sans\user_file\txt_parsers\ParsedDictConverter.py", line 59, in _input_dict
    self._cached_result = self._get_input_dict()
  File "C:\forks\mantid\scripts\SANS\sans\user_file\txt_parsers\UserFileReaderAdapter.py", line 22, in _get_input_dict
    return self._adapted_parser.read_user_file()
  File "C:\forks\mantid\scripts\SANS\sans\user_file\user_file_reader.py", line 39, in read_user_file
    with open(self._user_file) as f:
PermissionError: [Errno 13] Permission denied: <path to directory (that I did have permission for!)>

On IDAaaS the stack trace is the same, except the final error type that's thrown is:

IsADirectoryError: [Errno 21] Is a directory: <path to directory>
@rbauststfc rbauststfc added Bug Issues and pull requests that are regressions or would be considered a bug by users (e.g. crashing) SANS Issues and pull requests related to SANS ISIS Team: LSS Issue and pull requests managed by the LSS subteam at ISIS Reported By User Issues that were found or highlighted by a user/scientist labels Oct 1, 2024
@rbauststfc rbauststfc added this to the Release 6.12 milestone Oct 1, 2024
@rbauststfc rbauststfc changed the title Unable to open SANS interface if incorrect user file path is provided Unable to open SANS interface if incorrect user file path is saved Oct 1, 2024
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) ISIS Team: LSS Issue and pull requests managed by the LSS subteam at ISIS Reported By User Issues that were found or highlighted by a user/scientist SANS Issues and pull requests related to SANS
Projects
Status: Backlog
Development

No branches or pull requests

1 participant