I2PC / scipion

Scipion is an image processing framework to obtain 3D models of macromolecular complexes using Electron Microscopy (3DEM)
http://scipion.i2pc.es
Other
76 stars 47 forks source link

'Condition' parameter of the 'local' protocol parameter should reflect state of the 'global' protocol parameter #1770

Open DStrelak opened 6 years ago

DStrelak commented 6 years ago

Is your feature request related to a problem? Please describe. Let's say I have a protocol, which can execute both GPU and CPU implementation of an algorithm. And let's assume that the GPU implementation has an additional parameter (e.g. max GPU memory that the algorithm can use). Clearly, this additional parameter should not be visible for the CPU version.

Describe the solution you'd like I would like to be able to specify condition on such a (local) parameter, using the _USEGPU (global) parameter.

Example (currently not working in devel-pluginization branch):

form.addHidden(params.USE_GPU, params.BooleanParam, default=False,
                       label="Use GPU version",
                       help="XXX")
form.addParam("max_gpu_mem", params.IntParam,
                      label='Max GPU memory to use',
                      condition="useGpu",
                      help="XXX")

Describe alternatives you've considered Currently, I have decided to describe both in help and label that this parameter is for GPU version only.

Additional context Note: Currently the condition sort of works, however, it is not interactive. It reflexts only the state of the global parameter at the time of instantiation (i.e. if I set the GPU version as a default, the memory parameter appears in the form, but it won't hide when I select CPU version).

delarosatrevin commented 6 years ago

Can you comment more in the use of the global USE_GPU variable? I think that you current case can be covered with the current tools and the "simple" mechanism for condition evaluation. If I understood correctly, you can do something like:

if USE_GPU:
   # add a boolean param (named useGpu) that allows choosing between cpu or gpu
else:
   # add a hidden param (named useGpu as well) that is always false, so useGpu=False always
# add memory param with condition on useGpu
DStrelak commented 6 years ago

I am not sure what you're asking/proposing.

I want to use a single .py protocol file for both CPU and GPU version of the same algorithm. I want the user to be able to dynamically decide whether to use GPU or CPU version.

To paraphrase my issue, changes in the 'upper, global' part of the protocol form do not trigger events (evaluation of the visibility) in the 'lower, local' part of the protocol.

However, changes in the 'lower, local' part of the protocol do trigger these events, so I can do sth like:

form.addParam("a", ...)
form.addParam("b", condition="a")