Skip to content

Abort command of the sample changer doesn't work #1875

@alessandro-olivo

Description

@alessandro-olivo

Long story short

When clicking the "Abort" button (see picture below), an error occurs and the abort operation is not performed.

Image
  • Network inspection:

    Image
  • Error log

    Traceback (most recent call last):
      File "/home/alessandro/devel/anaconda3/envs/mxcube_new/lib/python3.11/site-packages/flask/app.py", line 880, in full_dispatch_request
        rv = self.dispatch_request()
             ^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/alessandro/devel/anaconda3/envs/mxcube_new/lib/python3.11/site-packages/flask/app.py", line 865, in dispatch_request
        return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/alessandro/devel/anaconda3/envs/mxcube_new/lib/python3.11/site-packages/flask/app.py", line 270, in <lambda>
        view_func=lambda **kw: self_ref().send_static_file(**kw),  # type: ignore # noqa: B950
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/alessandro/devel/anaconda3/envs/mxcube_new/lib/python3.11/site-packages/flask/app.py", line 318, in send_static_file
        return send_from_directory(
               ^^^^^^^^^^^^^^^^^^^^
      File "/home/alessandro/devel/anaconda3/envs/mxcube_new/lib/python3.11/site-packages/flask/helpers.py", line 552, in send_from_directory
        return werkzeug.utils.send_from_directory(  # type: ignore[return-value]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/alessandro/devel/anaconda3/envs/mxcube_new/lib/python3.11/site-packages/werkzeug/utils.py", line 575, in send_from_directory
        raise NotFound()
    werkzeug.exceptions.NotFound: 404 Not Found: The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

The problem

The issue is that the frontend calls the endpoint sample_changer/send_command/abort but the route defined here expects an additional /args parameter in the URL path.

A possible solution

A working solution (already tested) is to modify routes/samplechnager.py to support both URL patterns

+   @bp.route("/send_command/<cmdparts>", methods=["GET"])
    @bp.route("/send_command/<cmdparts>/<args>", methods=["GET"])
    @server.require_control
    @server.restrict
    def send_command(cmdparts, args=None):
        try:
            ret = HWR.beamline.sample_changer_maintenance.send_command(cmdparts, args)
        except Exception:
            ...

But I can see other solutions like changing the endpoint called by the frontend or creating a new route in the routes/samplechanger.py, something like /abort.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions