mxcube / mxcubeweb

MXCuBE-Web
http://mxcube.github.io/mxcubeweb/
GNU Lesser General Public License v3.0
25 stars 39 forks source link

Clarify purpose of `available_methods` in `beamline_config.yml` #1485

Open axelboc opened 4 weeks ago

axelboc commented 4 weeks ago

I'm trying to refactor the ContextMenu component and some of the code relies on the beamline configuration below, so I'd like to understand its purpose a bit better:

available_methods:
  datacollection: true
  characterisation: true
  helical: true
  xrf_spectrum: true
  energy_scan: true
  mesh: true
  ssx_chip_collection: true
  gphlworkflow: true
  test_collection: true

This available_methods configuration is first made available to the front-end through the beamline.availableMethod global state, which is used to hide options from the sample view's context menu.

The code that does this is unnecessarily convoluted, but basically it removes any option with a matching key in available_methods that is set to false. So if we have:

available_methods:
  datacollection: false
  ...

... then the context menu action with key datacollection doesn't get displayed. The current logic cares only about "methods" that are set to false and ignores the others (i.e. it's an opt-out mechanism).


Now the available_methods configuration is also used in Queue#get_available_tasks(). In this case, it's an opt-in mechanism: each task is made available only if its corresponding key is defined and set to true in available_methods.

Available tasks are made available to the front-end through the taskForm.defaultParameters global state:

image

When a "method" is set to false (or not set all) in available_methods, the corresponding task no longer appears in the defaultParameters object.


Okay, so with all this in mind, I'm curious to know how the available_methods is actually used in practice:

marcus-oscarsson commented 3 weeks ago

The idea is that a method needs to be set to true in available_methods to be available. It has in most cases little meaning for the standard datacollection and characterisation. Its true that available_methods is not yet respected on the sample list page and that is something we should address. There are probably some details to this that we should discuss to make this a bit more clear, but you are right that the current logic is quite convoluted and the concept only partially implemented. I'll pass by tomorrow and we can have a look at some of this to get the cleanup continued.

axelboc commented 3 weeks ago

Thanks, okay, so basically:

I'd also argue that we don't actually need to expose available_methods to the UI, since it's only used by the sample view's context menu and the same information can be inferred from the taskForm.defaultParameters object (if a method is present in this object then it's available). I could make a hook like useMethodAvailable() to abstract this so it's clear in the code.

marcus-oscarsson commented 3 weeks ago

Thanks @axelboc thats a good and clear summary :). It also a good idea to not expose available_methods, taskForm.defaultParameters would contain the same information.