Skip to content

Conversation

@hadim
Copy link
Contributor

@hadim hadim commented Dec 4, 2016

In continuation to #15 I propose this.

What do you think ?

@hadim
Copy link
Contributor Author

hadim commented Dec 4, 2016

ping @bnorthan @imagejan @ctrueden

@hadim
Copy link
Contributor Author

hadim commented Dec 4, 2016

I was thinking maybe I could use the .fake format such as "8bit-signed&pixelType=int8&axes=X,Y,Z,Channel,Time&lengths=1160,1160,3,5,7.fake"

@ctrueden
Copy link
Member

ctrueden commented Dec 5, 2016

We use the fake format for testing in many places. Note that as part of the SJC3 I/O work, it will change from a pseudoformat with .fake extension, to a URI-style protocol like testimage:// or something like that. But I'll try to preserve backwards compatibility.

Copy link
Member

@imagejan imagejan left a comment

Choose a reason for hiding this comment

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

Nice work! You are currently just checking if the scripts don't fail, right? How about checking if they return the correct result as well?

Also, can you split the whitespace changes in the crop script into a separate commit (as they are unrelated to the test framework)?

*
* @author Hadrien Mary
*/
public class AbstractScriptTest {
Copy link
Member

Choose a reason for hiding this comment

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

abstract keyword missing (at least the class name suggests so)

*
* @author Hadrien Mary
*/
public class TestScript extends AbstractScriptTest {
Copy link
Member

Choose a reason for hiding this comment

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

In line with the current ImageJ conventions, and to be consistent with AbstractScriptTest, the class name should be ScriptTest or maybe some more specific ImageJ2ScriptTest, so there can also be DeconvolutionScriptTest etc.

IIRC, throughout the ImageJ universe (e.g. imagej-ops), the convention is to have an interface (i.e. interface ScriptTest) that is implemented by an abstract class that is then extended by a default implementation or several specific ones.


final ScriptModule m = scriptService.run(scriptFile, true).get();

final Dataset output = (Dataset) m.getReturnValue();
Copy link
Member

Choose a reason for hiding this comment

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

How about asserting that the output is not null?

@hadim hadim force-pushed the test-scripts branch 2 times, most recently from 7df1428 to 9724281 Compare December 6, 2016 00:12
@hadim hadim force-pushed the test-scripts branch 2 times, most recently from c30173a to 2ef01fc Compare December 6, 2016 00:15
@hadim
Copy link
Contributor Author

hadim commented Dec 6, 2016

Ok after a big fight with the API I have finally figured out how to test those scripts :-)

I am pretty happy with the result. Now everyone should easily be able to test scripts in this repo and that will increase a lot their robustness and usefulness. That was needed in my opinion by the fact they are available in the Script Editor. Such scripts should never throw an error in the Script Editor.

Once this is merged I invite everyone to write tests for their own scripts in this repo (it's super easy and quick to do).

Beside that I am happy to address any others comments you might have about this PR (please don't ask me to separate the commit that modify the scripts from the commit of the tests...).

@hadim
Copy link
Contributor Author

hadim commented Dec 6, 2016

Update : the tests pass without issue but to do that I had to add :

<dependency>
            <groupId>net.imagej</groupId>
            <artifactId>imagej</artifactId>
            <scope>test</scope>
            <type>jar</type>
        </dependency>

to the pom.xml which create a circular dependency and maven does not seem to like it a lot :-(

Exact error is :

Rule 6: org.apache.maven.plugins.enforcer.BanCircularDependencies failed with message:
Circular Dependency found. Your project's groupId:artifactId combination must not exist in the list of direct or transitive dependencies.
  net.imagej:imagej-scripting

@hadim hadim assigned hadim and unassigned hadim Dec 6, 2016
@imagejan
Copy link
Member

imagejan commented Dec 6, 2016

Hm, I'm not sure how to best solve the circular dependency issue. Any scripts using net.imagej.Dataset will definitely need imagej as a (test/runtime) dependency.
I guess imagej-scripting could be removed from imagej's pom.xml, where it currently is a runtime dependency?!
@ctrueden we'll need your advice here again...

@hadim
Copy link
Contributor Author

hadim commented Dec 6, 2016

Exactly we are stuck because this repo needs ImageJ to run those scripts...

@imagejan
Copy link
Member

imagejan commented Dec 6, 2016

Exactly we are stuck because this repo needs ImageJ to run those scripts...

Yes, but ImageJ doesn't require this repo, does it?

@hadim
Copy link
Contributor Author

hadim commented Dec 6, 2016

Well ImageJ ship with those scripts in the Script Editor... So we have to figure out which component of the ecosystem really needs this repo as a dep. Ideally that would be only the Script Editor repo correct ?

@hadim
Copy link
Contributor Author

hadim commented Dec 6, 2016

So script-editor is a scijava package (https://github.com/scijava/script-editor) so I guess it's not acceptable to add imagej-scripting to it.

Beside that imagej-scripting package is never called because of the auto discovery mechanism of resources/script_templates meaning that scripts will be added to script-editor whatever the package is.

So in theory the most obvious repo to add imagej-scripting is ImageJ at the end.

I realize is far from ideal but I propose to remove image-scripting from ImageJ repo and add it instead to imagej-ui-swing. The motivation is that imagej-scripting is only available to the user through an UI at the end. Because imagej-scripting does not depend on imagej-ui-swing that should solve the issue.

What do you think ? I am open to any others suggestions.

@hadim
Copy link
Contributor Author

hadim commented Dec 6, 2016

I confirm the trick works locally on my machine.

@imagejan
Copy link
Member

imagejan commented Dec 6, 2016

Why does imagej need to depend on imagej-scripting at all? It's sufficient if scripting is present at runtime for the templates to be discovered. If it's missing, ImageJ will still run, no?

Maybe I'm missing something here, or is the dependency required for Jenkins to deploy the whole ImageJ application??

@hadim
Copy link
Contributor Author

hadim commented Dec 6, 2016

Exactly. I was thinking about Jenkins deployment. I think ImageJ contains all the deps that need to be shipped to build the final software.

@hadim
Copy link
Contributor Author

hadim commented Dec 6, 2016

So at the end we should find another way to ship imagej-scripting. The proposal made above is one of the way (probably not the best one).

@bnorthan
Copy link
Contributor

bnorthan commented Dec 8, 2016

@hadim I just got the latest code and ran into the "Circular Dependency Error", at this point I don't have anything to add to that discussion. However when this part is fixed, and the project is easy to build I will be happy to do further testing.

@hadim
Copy link
Contributor Author

hadim commented Dec 8, 2016

Yes it's because of the imagej dependency.

To make it work you'll have to remove imagej-scripting dep from the imagej pom.xml and use that version of imagej (remove the SNAPSHOT tag from imagej also).

i realise it's complicated but at the moment I have no other solutions than that.

Let's wait next week and see what @ctrueden has to say about that.

@ctrueden
Copy link
Member

ctrueden commented Dec 9, 2016 via email

@imagejan
Copy link
Member

imagejan commented Dec 9, 2016

  • imagej-scripting should not depend on imagej. It should depend on e.g. imagej-common where Dataset lives.

Thanks, @ctrueden, for that hint. Indeed, we don't need net.imagej.ImageJ in your scripts, @hadim. They can be replaced by the appropriate services:

# @OpService ops
# @DatasetService ds

# [...]

ops.run("...") # instead of ij.op().run()

output = ds.create(outputImg) # instead of ij.dataset().create()

I tested these changes and pushed a commit to the test-scripts branch. (@hadim you can also push topic branches directly on the main repo instead of your fork. If you then open a pull request, we can all modify it before merging by pushing to that topic branch.)

Do we actually need the DatasetService at all here? Can't you just output the Imgs themselves?

@hadim
Copy link
Contributor Author

hadim commented Dec 9, 2016

Well I understand that you don't want imagej dep in imagej-scripting but from a "scripting" point of view, scripts we put in this repo should not be restricted to a smaller API/libraries than the one available in the Script Editor just because of a pom.xml issue.

I am aware I can use DatasetService and OpService instead of ImageJ but I prefer to use ImageJ because it decreases the number of lines at the beginning of the script and I use it in all my scripts. Same is for Img, I know I could use it instead of Dataset but I prefer to have the same input for all my scripts and use Dataset because sometime I need a Dataset object.

imagej is the package that contain all the ImageJ dependencies and also the ImageJ class. Do these two things need to be in the same repo ? Would it be a possibility to move ImageJ class in imagej-common for example ? It's just a guess here and I probably don't know well enough the overall API to be able to make a good judgment.

Now if you guys don't see any alternative that make everyone happy I am gonna remove all the # @ImageJ ij.

@bnorthan
Copy link
Contributor

bnorthan commented Dec 9, 2016

@hadim these scripts should be structured so that they could be run in any scijava application, for example KNIME. So we need to consider what services/classes/structures are generic to scijava, and which ones are specific to ImageJ.

@hadim
Copy link
Contributor Author

hadim commented Dec 9, 2016

Fair enough, I understand the scijava application argument. Let's close this PR and open a new one with the test-scripts branch in this repo.

@hadim hadim closed this Dec 9, 2016
@hadim hadim deleted the test-scripts branch December 9, 2016 14:13
@hadim
Copy link
Contributor Author

hadim commented Dec 9, 2016

Here is the new PR : #17

@ctrueden
Copy link
Member

ctrueden commented Dec 9, 2016 via email

@hadim
Copy link
Contributor Author

hadim commented Dec 9, 2016

Glad to hear :-)

So let's just merge #17 without any ij call in the scripts and open a new discussion for this ImageJ dep story.

@hadim hadim mentioned this pull request Dec 9, 2016
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.

4 participants