Task #11472 (closed)
BUG: OMERO.scripts can mishandle min/max parameter attributes
Reported by: | crueden-x | Owned by: | crueden-x |
---|---|---|---|
Priority: | critical | Milestone: | 5.0.3 |
Component: | Scripting | Version: | 4.4.8 |
Keywords: | n.a. | Cc: | wmoore, spli, jburel, jamoore |
Resources: | n.a. | Referenced By: | n.a. |
References: | n.a. | Remaining Time: | n.a. |
Sprint: | n.a. |
Description
If a script has multiple parameters, one with min/max values, and the next without, the OMERO.scripts bounds checking erroneously emits "OUT OF BOUNDS" errors claiming the value of the subsequent parameter is too large.
I ran into this issue while testing the ImageJ "Widget Demo" command as an OMERO script. It has many parameters, so I am not 100% confident that the bug boils down to the situation as simply as described above, but certainly with the Widget Demo the behavior I observed was as follows:
- A numeric parameter with min=0, max=1000
- A multiple-choice string parameter with a small set of values
When entering values into the console using omero scripts launch XYZ, an "OUT OF BOUNDS" error was given after entering a valid option for the multiple-choice string parameter.
My guess is that perhaps parameter objects are being reused and min/max from the previous parameter is not being cleared?
If the bug is not easy to reproduce based on this description, let me know and I will do some more research into the exact conditions of the bug.
Change History (12)
comment:1 Changed 11 years ago by jamoore
- Cc wmoore spli jburel added
- Milestone changed from Unscheduled to OMERO-4.4.9
- Owner set to jamoore
- Priority changed from minor to critical
- Version changed from 5.0.0-beta1 to 4.4.8
comment:2 Changed 11 years ago by jamoore
comment:3 Changed 11 years ago by jamoore
Hmmm...changing to List.ofType(rstring()) also didn't work. Curtis: the widget demo reliably reproduces? Could you perhaps attach the output of params for it?
comment:4 Changed 11 years ago by jamoore
- Milestone changed from OMERO-4.4.9 to OMERO-4.4.x
Moving to 4.4.x
comment:5 Changed 10 years ago by crueden-x
Sorry for letting this sit for so long. I just noticed your request for feedback.
I was able to reproduce this problem today using the latest version of ImageJ-OMERO with OMERO 5.0.1:
- Install ImageJ into an OMERO 5.0.1 server as described online.
- Download widget-demo-1.0.0-SNAPSHOT.jar and place it into your $OMERO_PREFIX/lib/ImageJ.app/jars folder.
- Download this patched imagej-omero-0.1.0-SNAPSHOT.jar and overwrite the one in $OMERO_PREFIX/lib/ImageJ.app/jars/omero. (See bottom of this comment for details on why this patch is needed.)
- Run $OMERO_PREFIX/lib/ImageJ.app/lib/gen-scripts --force --all to regenerate scripts.
- Run omero script list to list the scripts.
- Run omero script params $(omero script list | grep 'Widget' | sed 's/|.*//') to list parameters of the Widget Demo command. You'll notice that the max is populated for several of the parameters, but the mins of zero are not. I don't know if that's related, or a different bug...
- Run omero script launch $(omero script list | grep 'Widget' | sed 's/|.*//') to execute the widget demo.
- The values don't matter that much, as long as you hit valid multiple choice values. Here is a sample execution:
$ omero script launch 709 Using session deacf984-defd-4cff-8dd6-b8a9904d016f (omero@localhost:4064). Idle timeout: 10.0 min. Current group: LOCI Enter value for "pBoolean": true Enter value for "oBoolean": false Enter value for "pByte": 1 Enter value for "pDouble": 2 Enter value for "pFloat": 3 Enter value for "pInt": 4 Enter value for "pLong": 5 Enter value for "pShort": 6 Enter value for "oByte": 7 Enter value for "oDouble": 8 Enter value for "oFloat": 9 Enter value for "oInt": 10 Enter value for "oLong": 11 Enter value for "oShort": 12 Enter value for "bigInteger": 13 Enter value for "bigDecimal": 14 Enter value for "pChar": z Enter value for "oChar": q Enter value for "string": Hi Enter value for "choice": quick Enter value for "file": /tmp/foo Enter value for "color": yellow Enter value for "spinnerInteger": 15 Enter value for "sliderInteger": 16 Enter value for "scrollBarInteger": 17 Enter value for "sliderDouble": 18 Enter value for "scrollBarDouble": 19 Enter value for "choiceRadioH": Maybe Enter value for "choiceRadioV": Loved Enter value for "x": 20 Enter value for "twoX": 21 Enter value for "message": Done Bad parameters: exception ::omero::ValidationException { serverStackTrace = serverExceptionClass = message = Invalid parameters: OUT OF BOUNDS for "choiceRadioV": Loved is above max OUT OF BOUNDS for "message": Done is above max OUT OF BOUNDS for "choiceRadioH": Maybe is above max OUT OF BOUNDS for "string": Hi is above max OUT OF BOUNDS for "choice": quick is above max }
As you can see, the max is somehow erroneously applied to later string parameters.
I don't quite have ImageJ scripts working yet, or I would pare down this example to make things simpler. If you need a smaller test case let me know and I can work on creating a simpler ImageJ2 command. But this bug is probably not urgent to solve before Paris. We can fix it later this summer.
FWIW, here is the output of params on the Widget Demo:
omero script params 709 Using session deacf984-defd-4cff-8dd6-b8a9904d016f (omero@localhost:4064). Idle timeout: 10.0 min. Current group: LOCI id: 709 name: [ImageJ] Widget Demo version: 1.0.0-SNAPSHOT-87e5e4152d60784e145f44ba4e158fbb51a19258 authors: institutions: description: namespaces: stdout: text/plain stderr: text/plain inputs: pBoolean - (no description) Optional: False Type: ::omero::RBool Min: Max: Values: oBoolean - (no description) Optional: False Type: ::omero::RBool Min: Max: Values: pByte - (no description) Optional: False Type: ::omero::RString Min: Max: Values: pDouble - (no description) Optional: False Type: ::omero::RDouble Min: Max: Values: pFloat - (no description) Optional: False Type: ::omero::RFloat Min: Max: Values: pInt - (no description) Optional: False Type: ::omero::RInt Min: Max: Values: pLong - (no description) Optional: False Type: ::omero::RLong Min: Max: Values: pShort - (no description) Optional: False Type: ::omero::RString Min: Max: Values: oByte - (no description) Optional: False Type: ::omero::RString Min: Max: Values: oDouble - (no description) Optional: False Type: ::omero::RDouble Min: Max: Values: oFloat - (no description) Optional: False Type: ::omero::RFloat Min: Max: Values: oInt - (no description) Optional: False Type: ::omero::RInt Min: Max: Values: oLong - (no description) Optional: False Type: ::omero::RLong Min: Max: Values: oShort - (no description) Optional: False Type: ::omero::RString Min: Max: Values: bigInteger - (no description) Optional: False Type: ::omero::RString Min: Max: Values: bigDecimal - (no description) Optional: False Type: ::omero::RString Min: Max: Values: pChar - (no description) Optional: False Type: ::omero::RString Min: Max: Values: oChar - (no description) Optional: False Type: ::omero::RString Min: Max: Values: string - (no description) Optional: False Type: ::omero::RString Min: Max: Values: choice - (no description) Optional: False Type: ::omero::RString Min: Max: Values: The, quick, brown, fox, jumps, over, the, lazy, dog file - (no description) Optional: False Type: ::omero::RString Min: Max: Values: color - (no description) Optional: False Type: ::omero::RString Min: Max: Values: spinnerInteger - (no description) Optional: False Type: ::omero::RInt Min: Max: 1000 Values: sliderInteger - (no description) Optional: False Type: ::omero::RInt Min: Max: 1000 Values: scrollBarInteger - (no description) Optional: False Type: ::omero::RInt Min: Max: 1000 Values: sliderDouble - (no description) Optional: False Type: ::omero::RDouble Min: 0.2 Max: 1000.7 Values: scrollBarDouble - (no description) Optional: False Type: ::omero::RDouble Min: 0.2 Max: 1000.7 Values: choiceRadioH - (no description) Optional: False Type: ::omero::RString Min: Max: Values: Yes, No, Maybe choiceRadioV - (no description) Optional: False Type: ::omero::RString Min: Max: Values: Loved, Really liked, Liked, Disliked, Really disliked x - (no description) Optional: False Type: ::omero::RFloat Min: Max: Values: twoX - Demonstrates callback functionality. Equal to double x. Optional: False Type: ::omero::RFloat Min: Max: Values: message - Demonstrates preview functionality by displaying the given message in the ImageJ status bar. Optional: False Type: ::omero::RString Min: Max: Values: outputs: result - (no description) Optional: False Type: ::omero::RString Min: Max: Values:
Lastly, the reason for the patched version of the imagej-omero JAR is because the version on master currently has a workaround for this bug. In the patched version, the workaround has been disabled as follows:
git dif diff --git a/src/main/java/net/imagej/omero/DefaultOMEROService.java b/src/main/java/net/imagej/omero/DefaultOMEROService.java index 1e1c501..15cc593 100644 --- a/src/main/java/net/imagej/omero/DefaultOMEROService.java +++ b/src/main/java/net/imagej/omero/DefaultOMEROService.java @@ -93,12 +93,10 @@ public class DefaultOMEROService extends AbstractService implements if (choices != null && !choices.isEmpty()) { param.values = (omero.RList) toOMERO(choices); } - // TEMP: Disabled until OME issue #11472 is resolved - // https://trac.openmicroscopy.org.uk/ome/ticket/11472 -// final Object min = item.getMinimumValue(); -// if (min != null) param.min = toOMERO(min); -// final Object max = item.getMaximumValue(); -// if (max != null) param.max = toOMERO(max); + final Object min = item.getMinimumValue(); + if (min != null) param.min = toOMERO(min); + final Object max = item.getMaximumValue(); + if (max != null) param.max = toOMERO(max); return param; }
comment:6 Changed 10 years ago by jamoore
- Milestone changed from 5.x to 5.0.3
comment:7 Changed 10 years ago by jamoore
Referencing ticket #1343 has changed sprint.
comment:8 Changed 10 years ago by jamoore
Referencing ticket #918 has changed sprint.
comment:9 Changed 10 years ago by jamoore
- Cc jamoore added
- Owner changed from jamoore to crueden-x
So it looks like what's happening is an empty string is being set as the min/max by imagej-omero. This doesn't show up in the params output (since an empty string displays as nothing). But I can reproduce the same behavior like this:
$ bin/omero script cat /empty-max.py import omero import omero.scripts as _os import omero.rtypes as _ot c = _os.client("test", _os.String("a", max=_ot.rstring(""), optional=False))
$ bin/omero script params /empty-max.py id: 14798 name: test version: authors: institutions: description: namespaces: stdout: text/plain stderr: text/plain inputs: a - (no description) Optional: False Type: ::omero::RString Min: Max: Values: outputs:
$ bin/omero script launch /empty-max.py a=hi Bad parameters: exception ::omero::ValidationException { serverStackTrace = serverExceptionClass = message = Invalid parameters: OUT OF BOUNDS for "a": hi is above max
With https://github.com/openmicroscopy/openmicroscopy/pull/2582, the output of the params command should be:
id: 14654 name: [ImageJ] Widget Demo version: 1.0.0-SNAPSHOT-b56d138f9e0757ce9e51815eb5d1c3bfc4ac898d authors: institutions: description: namespaces: stdout: text/plain stderr: text/plain inputs: pBoolean - (no description) Optional: False Type: ::omero::RBool Min: Max: Values: oBoolean - (no description) Optional: False Type: ::omero::RBool Min: Max: Values: pByte - (no description) Optional: False Type: ::omero::RString Min: Max: Values: pDouble - (no description) Optional: False Type: ::omero::RDouble Min: Max: Values: pFloat - (no description) Optional: False Type: ::omero::RFloat Min: Max: Values: pInt - (no description) Optional: False Type: ::omero::RInt Min: Max: Values: pLong - (no description) Optional: False Type: ::omero::RLong Min: Max: Values: pShort - (no description) Optional: False Type: ::omero::RString Min: Max: Values: oByte - (no description) Optional: False Type: ::omero::RString Min: Max: Values: oDouble - (no description) Optional: False Type: ::omero::RDouble Min: Max: Values: oFloat - (no description) Optional: False Type: ::omero::RFloat Min: Max: Values: oInt - (no description) Optional: False Type: ::omero::RInt Min: Max: Values: oLong - (no description) Optional: False Type: ::omero::RLong Min: Max: Values: oShort - (no description) Optional: False Type: ::omero::RString Min: Max: Values: bigInteger - (no description) Optional: False Type: ::omero::RString Min: Max: Values: bigDecimal - (no description) Optional: False Type: ::omero::RString Min: Max: Values: pChar - (no description) Optional: False Type: ::omero::RString Min: Max: Values: oChar - (no description) Optional: False Type: ::omero::RString Min: Max: Values: string - (no description) Optional: False Type: ::omero::RString Min: '' Max: '' Values: choice - (no description) Optional: False Type: ::omero::RString Min: '' Max: '' Values: The, quick, brown, fox, jumps, over, the, lazy, dog file - (no description) Optional: False Type: ::omero::RString Min: Max: Values: date - (no description) Optional: False Type: ::omero::RString Min: Max: Values: color - (no description) Optional: False Type: ::omero::RString Min: Max: Values: spinnerInteger - (no description) Optional: False Type: ::omero::RInt Min: 0 Max: 1000 Values: sliderInteger - (no description) Optional: False Type: ::omero::RInt Min: 0 Max: 1000 Values: scrollBarInteger - (no description) Optional: False Type: ::omero::RInt Min: 0 Max: 1000 Values: sliderDouble - (no description) Optional: False Type: ::omero::RDouble Min: 0.2 Max: 1000.7 Values: scrollBarDouble - (no description) Optional: False Type: ::omero::RDouble Min: 0.2 Max: 1000.7 Values: choiceRadioH - (no description) Optional: False Type: ::omero::RString Min: '' Max: '' Values: Yes, No, Maybe choiceRadioV - (no description) Optional: False Type: ::omero::RString Min: '' Max: '' Values: Loved, Really liked, Liked, Disliked, Really disliked x - (no description) Optional: False Type: ::omero::RFloat Min: Max: Values: twoX - Demonstrates callback functionality. Equal to double x. Optional: False Type: ::omero::RFloat Min: Max: Values: message - Demonstrates preview functionality by displaying the given message in the ImageJ status bar. Optional: False Type: ::omero::RString Min: '' Max: '' Values: button - (no description) Optional: True Type: ::omero::RString Min: Max: Values: outputs: result - (no description) Optional: False Type: ::omero::RString Min: '' Max: '' Values:
comment:10 Changed 10 years ago by jmoore <josh@…>
(In [26bf13f2a2835d97bb7cd22d4753bfabb867ee4f/ome.git] on branch develop) Print empty min/max strings in quotes (See #11472)
bin/omero script params was being misleading by showing
no value for min/max of String arguments when the min or
max was the empty string. This adds single quotes to the
empty string to make it clear that a min or max is present.
comment:11 Changed 10 years ago by jamoore
- Resolution set to fixed
- Status changed from new to closed
Discussed with Curtis in Paris: next changes are imagej-omero side. Closing this.
comment:12 Changed 10 years ago by crueden-x
Thanks Josh, I filed https://github.com/imagej/imagej-omero/issues/46 to track this on the ImageJ-OMERO side.
First attempt to reproduce: