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

Removing >255 measurements throws error when reproducing from workflow script #915

Closed
MarkZaidi opened this issue Feb 16, 2022 · 3 comments · Fixed by #944
Closed

Removing >255 measurements throws error when reproducing from workflow script #915

MarkZaidi opened this issue Feb 16, 2022 · 3 comments · Fixed by #944
Labels
Milestone

Comments

@MarkZaidi
Copy link

Bug report

Describe the bug
If attempting to remove over 255 measurements at once through the measurement manager, the corresponding workflow entry for that action will throw an error. This is due to the maximum number of supported arguments for a groovy function being 255.

To Reproduce
Steps to reproduce the behavior:

  1. Create >255 different measurements for a project entry containing detection objects.
  2. Remove >255 measurements through the measurement manager GUI in one action.
  3. Create a script from the workflow tab consisting of all of the above actions. Note the error message:
    ERROR: MultipleCompilationErrorsException: startup failed: General error during instruction selection: The max number of supported arguments is 255, but found 1191

Expected behavior
The script generated from the workflow tab should be able to reproduce most of the plugin-based actions, including the act of removing measurements. A quick fix is to modify the generated script and distribute the list of measurements to remove over multiple removeMeasurement() operations.

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows 10
  • QuPath Version 0.4.0-SNAPSHOT

Additional context
Minor issue, easy enough to manually distribute the list of measurements to remove over multiple removeMeasurement() statements

@petebankhead petebankhead added this to the v0.4.0 milestone Feb 16, 2022
@petebankhead
Copy link
Member

Thanks for the clear report, I wasn't aware of the 255 argument limit. I think switching to a list makes sense.

I'll look into this soon - there are a few scripting things that need an overhaul before v0.4.0.

@petebankhead
Copy link
Member

Edit: I think adding an extra method that takes a list rather than a varargs array would be a good solution in the longer term, but looping through a list for now is a good workaround.

petebankhead added a commit to petebankhead/qupath that referenced this issue Apr 4, 2022
Fixes qupath#915
Using an array is enough to overcome the problem.

The following script helps quickly add many measurements to a selected object:
```
def pathObject = getSelectedObject()
def measurements = []
try (def ml = pathObject.getMeasurementList()) {
    for (int i = 0; i < 500; i++) {
        def n = "Measurement $i"
        measurements << n
        ml.putMeasurement(n, i*2)
    }
}
```
@petebankhead
Copy link
Member

Thanks, this should now be fixed.

To update older scripts, you can convert the list of names to a String array by adding [ at the start and ] as String[] at the end.

It should look something like this

removeMeasurements(qupath.lib.objects.PathCellObject, ["Name 1", "Name 2", ..., "Name X"] as String[])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants