Skip to content

Python Help Window Feature Addition - Use ConfigService for Docs Path #39201

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

Merged
merged 4 commits into from
Apr 16, 2025

Conversation

darshdinger
Copy link
Contributor

Description of work

Summary of work

Modified the Python Help Window (HelpWindowModel) to retrieve the local HTML documentation path from Mantid's ConfigService using the existing docs.html.root property. This removes the need to explicitly pass this path as a parameter when creating the help window components.

This change utilizes the existing docs.html.root configuration property within Mantid's ConfigService, centralizing the definition of the local help documentation path and simplifying the Help Window's interface and instantiation. It makes the Help Window consistent with how other parts of Mantid locate configured resources.

Issues #37248

Here is the EWM link: EWM 10007

Further detail of work

  • Removed the localDocs/localDocsBase parameter from HelpWindowModel.__init__, HelpWindowPresenter.__init__, and the show_help_page function in helpwindowbridge.py.
  • Removed the corresponding --local-docs command-line argument and MANTID_LOCAL_DOCS_BASE environment variable handling from helpwindowbridge.py.
  • In HelpWindowModel.__init__, mantid.kernel.ConfigService is now imported at the top level and used to retrieve the path:
    config_service = ConfigService.Instance()
    raw_path = config_service.getString("docs.html.root", True)
  • Error handling (try...except) around the ConfigService import and calls ensures robustness in environments where ConfigService might not be fully initialized or the property is absent/empty.
  • If a valid directory path is retrieved from docs.html.root, the model configures itself for "Offline Docs" mode using that path. Otherwise, it defaults gracefully to "Online Docs" mode.
  • Updated test_helpwindowmodel.py significantly to reflect the removal of the localDocsBase parameter and to use unittest.mock.patch to simulate various return values from ConfigService.Instance().getString("docs.html.root", True). This allows testing of different scenarios (valid path, invalid path, no path found) without requiring a live ConfigService.

To test:

In order to test this, you need to first build mantid workbench with the python help window enabled. Follow these steps in order to achieve this:

  1. cmake . -DCMAKE_BUILD_TYPE=Debug -DENABLE_QTASSISTANT=OFF
  2. ninja all docs-html
  3. ./bin/lauch_mantidworkbench.sh

Following this use the command ./bin/launch_mantidworkbench.sh to launch the workbench.

Within the workbench window navigate to the Algorithm Manager window and select any algo:
image

Double left click to open the algo menu:
image

Press the "?" button and to launch the python help window and notice within the debug logs that ConfigService is being employed to retrieve the local docs location:

HelpWindowModel-[Debug] Retrieved 'docs.html.root' from ConfigService: '/home/dzj/mantid/build/docs/html'

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.

@darshdinger darshdinger added this to the Release 6.13 milestone Apr 14, 2025
dlcaballero16
dlcaballero16 previously approved these changes Apr 14, 2025
Copy link
Contributor

@dlcaballero16 dlcaballero16 left a comment

Choose a reason for hiding this comment

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

Tested as described and verified docs were obtained through ConfigService.

Copy link
Member

@peterfpeterson peterfpeterson left a comment

Choose a reason for hiding this comment

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

I have some questions on how the behavior works on getting the local path set when there is or isn't an exception. I think it needs some comments or a little bit better of organization to clarify what is going on.

As is, it looks like it is "always" online, but it sets the base URL to be the offline version.

@darshdinger darshdinger force-pushed the replace-hard-coded-path-configservice branch from 051d27a to d804d2d Compare April 15, 2025 17:45
Copy link
Member

@peterfpeterson peterfpeterson left a comment

Choose a reason for hiding this comment

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

One more changes for rhobustness:

  1. Build the offline docs
  2. remove docs/html/index.html
  3. start the main help page

It would be helpful to add a warning/error message that the HTML file is not found.

Otherwise the code looks good.

@peterfpeterson peterfpeterson enabled auto-merge (squash) April 16, 2025 20:37
@peterfpeterson peterfpeterson merged commit 4dc8da5 into main Apr 16, 2025
10 checks passed
@peterfpeterson peterfpeterson deleted the replace-hard-coded-path-configservice branch April 16, 2025 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants