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

Add mantidworkbench as an entry point for the mantidworkbench Conda package #37750

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

thomashampson
Copy link
Contributor

@thomashampson thomashampson commented Aug 6, 2024

Description of work

  • Add mantidworkbench as an entry point to the application. Users can now launch with either workbench or mantidworkbench from within a Conda environment.
  • Configure the Conda package entry points to use jemalloc on Linux. Previously, the workbench entry point did not include the same jemalloc setup as the mantidworkbench script that was available on Linux installs. Now on Linux both entry points will call the same launch script that will configure jemalloc to be used.
    Here is a diagram to help illustrate the changes:
    image

Summary of work

Added a new wrapper script called workbench_launch_wrapper that is now the entry point defined in the conda-build recipe. The new script will detect whether you are using Linux. If not, workbench is launched as before. If it is Linux, it will call the script that used to be named mantidworkbench that will configure jemalloc before launching the application.

Purpose of work

  • There have been cases where users have asked for a mantidworkbench entry point to avoid confusion.
  • It is already an entry point on Linux, but will perform additional steps before launching the application (e.g. setting up jemalloc)
  • Currently if you launch on Linux with the Conda entry point (workbench), it bypasses the jemalloc setup, and the application does not perform well.

Fixes #37538

To test:

On all OS:
Install the test package:
conda install jclarkestfc/label/entryPointTest::mantidworkbench
Test the following things:

  1. Verify that mantid workbench launches with both mantidworkbench and workbench
  2. Test that the error report functions with both entry points (e.g. use the SegFault algorithm)
  3. Test that the error reporter doesn't pop up when passing the --single-process argument to either entry point
  4. (Linux only) verify that both launch entry points configure jemalloc correctly by running os.environ['LD_PRELOAD'] in workbench's python console. It should output the location of libjemalloc.so.2 from inside your Conda environment.
  5. (Linux only) Check that the --debug argument works when launching with either entry point.
  6. On each OS, install the standalone packages and make sure they still work as expected:
    https://builds.mantidproject.org/job/build_packages_from_branch/957/

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.

@thomashampson thomashampson marked this pull request as ready for review August 6, 2024 12:53
@jhaigh0 jhaigh0 added the ISIS Team: Core Issue and pull requests managed by the Core subteam at ISIS label Aug 6, 2024
@thomashampson thomashampson added this to the Release 6.11 milestone Aug 8, 2024
@@ -100,10 +100,11 @@ set(PYTHON_ARGS " -Wdefault::DeprecationWarning -Werror:::mantid -Werror:::manti
set(PYTHON_EXEC_LOCAL "\${CONDA_PREFIX}/bin/python")
set(PREAMBLE "${CONDA_PREAMBLE_TEXT}")
set(LOCAL_PYPATH "${CMAKE_CURRENT_BINARY_DIR}/bin/")
# The python command to start workbench
set(MANTIDWORKBENCH_EXEC "-c \"from workbench.app.main import main; main()\"")
Copy link
Member

@peterfpeterson peterfpeterson Aug 8, 2024

Choose a reason for hiding this comment

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

If you are feeling a little crazy, you can rename workbench.app.main to workbench.app.__main__ and people then can run python -m workbench.app to get workbench started.

For simpler things, the little import-y bit here is autogenerated by setuptools once you define the entrypoint.

Copy link
Member

Choose a reason for hiding this comment

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

from workbench.app.main import main


def launch():
Copy link
Member

@peterfpeterson peterfpeterson Aug 8, 2024

Choose a reason for hiding this comment

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

I think this is missing the bits for return codes. The final lines should be like this. Things that return None will exit with a zero return code as you would expect.

@peterfpeterson
Copy link
Member

Can the new wrapper get named mantidworkbench_whatever instead? workbench in the PATH is pretty ambigious.

@thomashampson thomashampson marked this pull request as draft August 13, 2024 11:05
@github-actions github-actions bot added the Has Conflicts Used by the bot to label pull requests that have conflicts label Sep 4, 2024
Copy link

github-actions bot commented Sep 4, 2024

👋 Hi, @thomashampson,

Conflicts have been detected against the base branch. Please rebase your branch against the base branch.

@sf1919
Copy link
Contributor

sf1919 commented Sep 11, 2024

I'm going to change the milestone on this as it's unlikely we can get this sorted before end of tomorrow.

@sf1919 sf1919 modified the milestones: Release 6.11, Release 6.12 Sep 11, 2024
@jclarkeSTFC jclarkeSTFC force-pushed the 37538_mantidworkbench_entry_point branch from 44d22a5 to c262ecd Compare October 29, 2024 10:10
@jclarkeSTFC jclarkeSTFC removed the Has Conflicts Used by the bot to label pull requests that have conflicts label Oct 29, 2024
@jclarkeSTFC jclarkeSTFC marked this pull request as ready for review November 13, 2024 09:53
from workbench.app.main import main


def launch():
Copy link
Member

Choose a reason for hiding this comment

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

This becomes much easier to add tests to if the sys.argv is an argument to the function

Suggested change
def launch():
def launch(args):



if __name__ == "__main__":
sys.exit(launch())
Copy link
Member

Choose a reason for hiding this comment

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

then this becomes

Suggested change
sys.exit(launch())
sys.exit(launch(sys.argv))

command = ["launch_mantidworkbench"] + sys.argv[1:]
subprocess.run(command)
else:
main()
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't main() get the command line arguments?

@jclarkeSTFC jclarkeSTFC force-pushed the 37538_mantidworkbench_entry_point branch from 88fdeea to 01e69ff Compare November 20, 2024 13:37
@thomashampson
Copy link
Contributor Author

I've updated the diagram in the description to reflect the recent changes.

@thomashampson
Copy link
Contributor Author

thomashampson commented Dec 6, 2024

I've verified on Windows that:

  • both entry points work from a Conda install
  • the standalone install launches fine

@thomashampson
Copy link
Contributor Author

I've verified that os.environ['LD_PRELOAD'] outputs the expected jemalloc location on Linux conda {workbench, mantidworkbench} and standalone package.

@thomashampson
Copy link
Contributor Author

For some reason the standalone package isn't launching on MacOS.

@jclarkeSTFC jclarkeSTFC force-pushed the 37538_mantidworkbench_entry_point branch from 01e69ff to e34ccfb Compare December 10, 2024 09:13
@jclarkeSTFC
Copy link
Contributor

https://builds.mantidproject.org/job/build_packages_from_branch/956/

macOS standalone after rebase

Copy link
Contributor

@jhaigh0 jhaigh0 left a comment

Choose a reason for hiding this comment

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

Whoops didn't mean to approve yet

Copy link
Contributor

@jhaigh0 jhaigh0 left a comment

Choose a reason for hiding this comment

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

(fix the mac stand alone)

@jclarkeSTFC
Copy link
Contributor

jclarkeSTFC commented Dec 10, 2024

https://builds.mantidproject.org/job/build_packages_from_branch/959/

This one's going to be a winner

Edit: updated to second attempt at winning

Then someone can pass in arguments directly instead of using
sys.argv. If no arguments are given then sys.argv gets used
by default.

Co-authored-by: Thomas Hampson <[email protected]>
@jclarkeSTFC jclarkeSTFC force-pushed the 37538_mantidworkbench_entry_point branch from 748c60f to 6492632 Compare December 11, 2024 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ISIS Team: Core Issue and pull requests managed by the Core subteam at ISIS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Harmonise workbench and mantidworkbench entry points
5 participants