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

Dependency updates #274

Merged
merged 9 commits into from
Nov 13, 2020
Merged

Dependency updates #274

merged 9 commits into from
Nov 13, 2020

Conversation

mdoube
Copy link
Member

@mdoube mdoube commented Oct 30, 2020

Update pom.xml to use scijava 29.2.1 and handle downstream effects of that change.

Hack around some downstream effects:
- change in API for formatService.getFormat
- Tests fail due to malformed calls
These commented-out tests may need reworking in the future.

Remove explicit versions of things included/referred to in scijava >= 29
These seem to be breaking due to API changes in scijava 29
Use whatever version is being declared upstream by scijava
Sometimes these tests pass and sometimes they fail, but no-one knows
why the result is variable.
Copy link
Member

@alessandrofelder alessandrofelder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am worried about commenting out tests.
I assume the reasoning behind this is that they have stopped passing? just seen the commit message.
I will try and figure out what the problem is this week.

@mdoube
Copy link
Member Author

mdoube commented Nov 3, 2020

I am worried about commenting out tests.

Me too. These tests seem like obscure corner cases rather than main function (e.g. if file is not an image), so I'm not too worried.

I will try and figure out what the problem is this week.

OK but balance the cost of your time against the risk that these tests are meant to be averting. The Fractal Dimension one is a known unknown - a kind of Heisentest. Sometimes passes, sometimes doesn't. The Analyse Skeleton one seems obscure, like a file format test which should be handled way upstream from the wrapper plugin, and could possibly be discarded for this reason. It's not obvious to me what it's actually testing, and whether what it is testing is relevant to this level of plugin. Same for the empty image is not binary test, because it's impossible to generate an image with 0 pixels as far as I can tell.

testSphereRidge() seems important, that one may be worth fixing.

@alessandrofelder
Copy link
Member

Starting on the FindRidgePoints test - I am getting the tests to pass but mvn showing

[ERROR] Cannot create plugin: class='io.scif.convert.FileToDatasetConverter', priority=1.0, enabled=true, pluginType=Converter

Is this what you are seeing too, @mdoube ?

@mdoube
Copy link
Member Author

mdoube commented Nov 3, 2020

Is this what you are seeing too, @mdoube ?

Yes exactly. Test passes when run directly in Eclipse, but throws this to the console:

[ERROR] Cannot create plugin: class='io.scif.convert.FileToDatasetConverter', priority=1.0, enabled=true, pluginType=Converter

@imagejan wrote on Gitter:

this is a known issue, and while it displays as an error (as the plugin can’t be created), it doesn’t affect your tests. The cause is a missing DatasetIOService at test time.
See the second paragraph here: scifio/scifio#443 (comment)

Uncommented in 47c91f9

@mdoube
Copy link
Member Author

mdoube commented Nov 3, 2020

ElementUtilTest.testIsBinaryReturnsFalseIfIntervalEmpty() fails with:

net.imglib2.exception.InvalidDimensionsException: Expected only positive dimensions but got: [0]
	at net.imglib2.Dimensions.verifyAllPositive(Dimensions.java:166)
	at net.imglib2.Dimensions.verify(Dimensions.java:208)
	at net.imglib2.img.array.ArrayImgFactory.create(ArrayImgFactory.java:90)
	at net.imglib2.img.array.ArrayImgFactory.create(ArrayImgFactory.java:69)
	at net.imglib2.img.array.ArrayImgs.doubles(ArrayImgs.java:555)
	at org.bonej.utilities.ElementUtilTest.testIsBinaryReturnsFalseIfIntervalEmpty(ElementUtilTest.java:234)

Which suggests to me that this condition (an image with zero size) is now checked for and prevented earlier in execution.
Test deleted in 96b2e93

@mdoube
Copy link
Member Author

mdoube commented Nov 3, 2020

AnalyseSkeletonWrapperTest.testBadFormatIntensityImageCancelsPlugin() fails with:

org.junit.ComparisonFailure: Cancel reason is incorrect expected:<[Image format is not recognized]> but was:<[An error occurred while opening the image]>
	at org.junit.Assert.assertEquals(Assert.java:125)
	at org.bonej.wrapperPlugins.AnalyseSkeletonWrapperTest.testBadFormatIntensityImageCancelsPlugin(AnalyseSkeletonWrapperTest.java:170)

It's not clear to me what error condition the test is actually checking for (and for that reason is a candidate for deletion):

	@Test
	public void testBadFormatIntensityImageCancelsPlugin() throws Exception {
		// SETUP
		final ImagePlus imagePlus = IJ.createImage("test", 3, 3, 3, 8);
		final File exceptionFile = mock(File.class);
		when(exceptionFile.getAbsolutePath()).thenReturn("file.foo");
		when(MOCK_UI.chooseFile(any(File.class), anyString())).thenReturn(
			exceptionFile);

		// EXECUTE
		final CommandModule module = command().run(
			AnalyseSkeletonWrapper.class, true, "inputImage", imagePlus,
			"pruneCycleMethod", "Lowest intensity voxel").get();

		// VERIFY
		assertTrue("Plugin should have cancelled", module.isCanceled());
		assertEquals("Cancel reason is incorrect", "Image format is not recognized",
			module.getCancelReason());
	}

Additionally, this test class (but not this particular test method) complains many times, which appears to be the same problem as scifio/scifio#443 (comment):

[ERROR] Cannot create plugin: class='org.scijava.io.http.HTTPHandle', priority=0.0, enabled=true, pluginType=DataHandle

Zero dimension images are prevented from being created upstream, so this
test has no effect.
An error was being thrown that does not affect the test run or its
outcome. See scifio/scifio#443
@alessandrofelder
Copy link
Member

I think that AnalyseSkeletonWrapperTest.testBadFormatIntensityImageCancelsPlugin() checks that the AnalyseSkeletonWrapper throws a FormatException when the input file name extension is .foo. This is to make sure that the user gets a different, more nuanced error message when they pass an image with a dodgy file name extension than in cases where something else goes wrong when opening the image. So for that reason, I think having the test would be useful.

The underlying cause of this not passing anymore is the DefaultFormatService's getFormat() method now returns null instead of throwing a FormatException, as far as I can tell.

I hope to dig deeper tomorrow.

@mdoube
Copy link
Member Author

mdoube commented Nov 6, 2020

The underlying cause of this not passing anymore is the DefaultFormatService's getFormat() method now returns null instead of throwing a FormatException, as far as I can tell.

Right, so the null then triggers somewhere a NullPointerException:

Addinge.toString() to AnalyseSkeletonWrapper.openIntensityImage()

		catch (final IOException | NullPointerException e) {
			cancelMacroSafe(this, "An error occurred while opening the image: "+e.toString());
                        e.printStackTrace();
			logService.trace(e);
		}

Is logged like this by the test:

An error occurred while opening the image: java.io.FileNotFoundException: file.foo (No such file or directory)

java.io.FileNotFoundException: file.foo (No such file or directory)
	at java.io.FileInputStream.open0(Native Method)
	at java.io.FileInputStream.open(FileInputStream.java:195)
	at java.io.FileInputStream.<init>(FileInputStream.java:138)
	at org.scijava.text.DefaultTextService.open(DefaultTextService.java:63)
	at org.scijava.text.DefaultTextService.asHTML(DefaultTextService.java:75)
	at org.scijava.text.io.TextIOPlugin.open(TextIOPlugin.java:70)
	at org.scijava.text.io.TextIOPlugin.open(TextIOPlugin.java:48)
	at org.scijava.io.DefaultIOService.open(DefaultIOService.java:69)
	at org.bonej.wrapperPlugins.AnalyseSkeletonWrapper.openIntensityImage(AnalyseSkeletonWrapper.java:300)
	at org.bonej.wrapperPlugins.AnalyseSkeletonWrapper.run(AnalyseSkeletonWrapper.java:198)
	at org.scijava.command.CommandModule.run(CommandModule.java:196)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:165)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:124)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:63)
	at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:225)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

@alessandrofelder
Copy link
Member

Exactly.
The NPE is thrown because the File.foo doesn't actually exist (it's just being mocked by the test to check that the FormatException is thrown). So the code thinks the format is fine (no format exception) and then tries to open the file?

This set of changes to the DefaultFormatService is the key.

This is probably my lack of understanding what an empty FormatList means here, but possibly worth double-checking: @ctrueden @frauzufall, are you happy with returning null when the FormatList is empty, or should that trigger a FormatException too?
(I am basing this on the fact that in the FormatService javadoc, it says that getFormat will throw a FormatException
"if no compatible format was found, or if something goes wrong checking the source".
)
Thanks a lot for your help!

@alessandrofelder
Copy link
Member

I suggest we remove the negative test from AnalyzeSkeletonWrapper for now, and I've opened an issue so we don't forget to reinstate it once we figure out how to do it. See #275. At least this way, we don't get held up.

@alessandrofelder alessandrofelder self-requested a review November 12, 2020 21:06
@mdoube mdoube merged commit fd1c3fd into master Nov 13, 2020
@mdoube mdoube deleted the dependency-updates branch November 13, 2020 01:37
mdoube added a commit that referenced this pull request Apr 5, 2024
* Update Eclipse Collections to 10.4.0

* Update scijava to 29.2.1

Hack around some downstream effects:
- change in API for formatService.getFormat
- Tests fail due to malformed calls
These commented-out tests may need reworking in the future.

Remove explicit versions of things included/referred to in scijava >= 29

* Remove com.miglayout from and LocalThickness version from pom.xml

* Comment out some failing tests for later investigation

These seem to be breaking due to API changes in scijava 29

* Remove the Eclipse Collections version declaration

Use whatever version is being declared upstream by scijava

* Reinstate fractal dimension wrapper tests. See issue #229

Sometimes these tests pass and sometimes they fail, but no-one knows
why the result is variable.

* Remove test that checks for an image with a single zero dimension

Zero dimension images are prevented from being created upstream, so this
test has no effect.

* Restore commented-out test

An error was being thrown that does not affect the test run or its
outcome. See scifio/scifio#443

* remove this test for now

Co-authored-by: alessandrofelder <[email protected]>
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

Successfully merging this pull request may close these issues.

2 participants