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

Anistropy messages block execution from script #207

Closed
mdoube opened this issue Mar 5, 2020 · 7 comments
Closed

Anistropy messages block execution from script #207

mdoube opened this issue Mar 5, 2020 · 7 comments
Assignees

Comments

@mdoube
Copy link
Member

mdoube commented Mar 5, 2020

Describe the bug
When running from macro, Anisotropy shows messages in the GUI which interrupts execution until the user clicks OK.

To Reproduce
Run the macro

nDirsMax = 16384;
nLinesMax = 512;
row = 0;
setBatchMode(true);
for (nDirs = 16; nDirs <= nDirsMax; nDirs *= 2){
    for (nLines = 1; nLines <= nLinesMax; nLines *= 2){
		startTime = getTime();
		run("Anisotropy", "inputimage=net.imagej.ImgPlus@73956688 directions="+nDirs+" lines="+nLines+" samplingincrement=1.73 recommendedmin=true printradii=true printeigens=true displaymilvectors=false");
    	endTime = getTime();
    	duration = endTime - startTime;
    	setResult("nDirs", row, nDirs);
    	setResult("nLines", row, nLines);
    	setResult("Duration", row, duration);
    	updateResults();
    	row++;
    }
}

Expected behavior
The script completes without user interaction. Errors and other messages could be logged to the console of Log window.

Screenshots
image

Additional context
Add any other context about the problem here.

@rimadoma
Copy link
Contributor

rimadoma commented Mar 5, 2020

Seems to be a known issue. For now we can 1.Get rid of messages that are not absolutely necessary 2. Add instructions for how to hack the macros.

Option 2 for Anisotropy would look like

run("Anisotropy", "inputimage=net.imagej.ImgPlus@73956688 directions="+nDirs+" lines="+nLines+" samplingincrement=1.73 recommendedmin=true printradii=true printeigens=true displaymilvectors=false, instruction=\"\"");`

If you want to go with option 2, we'll need to mark all message parameters with persist=false.

@mdoube
Copy link
Member Author

mdoube commented Mar 6, 2020

option 3: can we just put the message in the dialog box, so that only interactive GUI users see it?

@rimadoma
Copy link
Contributor

rimadoma commented Mar 6, 2020

This is how you add messages to a dialog box. By having

@Parameter(visibility = ItemVisibility.MESSAGE)
private String instruction = "Press 'OK' to run the plugin";

Like I mentioned above, there just so happens to be bug that makes them pop up when a macros run.

@mdoube
Copy link
Member Author

mdoube commented Mar 9, 2020

Option 2. seems to work OK at the moment.

There is one other dialog that pops up:

image

Could we make it so that if code is being called from a script, warnings and messages get output to the console or log window only and not to a GUI OK button window? This particular one doesn't block execution, but you do get a big pile of them accumulating on the screen.

It's possible to work around this for now by not asking for nDirs < 10 (it's complaining because the ellipsoid fitting requires at least 9 points = 9 directions).

rimadoma added a commit that referenced this issue Mar 9, 2020
Allows running macros with "myMessageParameter=\"\"", which prevents
them from opening a dialog (an open issue in scijava-common). Without
`persist=false` a macro like this would change the message permanently.
@rimadoma rimadoma mentioned this issue Mar 9, 2020
@rimadoma
Copy link
Contributor

rimadoma commented Mar 9, 2020

@alessandrofelder Have you encountered these issues when running Python scripts?

@alessandrofelder
Copy link
Member

Yea, I think so. I can't remember exactly, but I will try to replicate tomorrow and report here. It was ITA-related, I think.

mdoube added a commit that referenced this issue Mar 10, 2020
* Enable mocking final classes

* Add a utility method

Adds a utility method that allows cancelling plugins without showing
message dialogs, when a macro is running.

* Cancels plugins in a macro safe way

Cancels plugins so that they won't show a message dialog if a macro is
being run.

* Workaround for issue #207

Allows running macros with "myMessageParameter=\"\"", which prevents
them from opening a dialog (an open issue in scijava-common). Without
`persist=false` a macro like this would change the message permanently.

* Mark test resources for gc

Co-authored-by: Michael Doube <[email protected]>
@mdoube
Copy link
Member Author

mdoube commented Mar 10, 2020

Fixed by #210 , closing.

@mdoube mdoube closed this as completed Mar 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants