-
Notifications
You must be signed in to change notification settings - Fork 15
Add a test framework for scripts #16
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
Conversation
|
I was thinking maybe I could use the |
|
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 |
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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?
7df1428 to
9724281
Compare
c30173a to
2ef01fc
Compare
|
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...). |
|
Update : the tests pass without issue but to do that I had to add : to the Exact error is : |
|
Hm, I'm not sure how to best solve the circular dependency issue. Any scripts using |
|
Exactly we are stuck because this repo needs ImageJ to run those scripts... |
Yes, but ImageJ doesn't require this repo, does it? |
|
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 ? |
|
So script-editor is a scijava package (https://github.com/scijava/script-editor) so I guess it's not acceptable to add Beside that So in theory the most obvious repo to add I realize is far from ideal but I propose to remove What do you think ? I am open to any others suggestions. |
|
I confirm the trick works locally on my machine. |
|
Why does Maybe I'm missing something here, or is the dependency required for Jenkins to deploy the whole ImageJ application?? |
|
Exactly. I was thinking about Jenkins deployment. I think ImageJ contains all the deps that need to be shipped to build the final software. |
|
So at the end we should find another way to ship |
|
@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. |
|
Yes it's because of the To make it work you'll have to remove 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. |
|
My quick 2c from a mobile devixe while on vacation:
* imagej should have a runtime dep on imagej-scripting.
* imagej-scripting should _not_ depend on imagej. It should depend on e.g.
imagej-common where Dataset lives.
* If imagej-scripting truly needs the net.imagej.ImageJ gateway (does it? I
somehow doubt it), then we have a problem... which could be solved by
adding another component like imagej-app which unions imagej +
imagej-scripting and maybe other things. But I hope we can avoid this.
|
Thanks, @ctrueden, for that hint. Indeed, we don't need # @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 Do we actually need the |
|
Well I understand that you don't want I am aware I can use
Now if you guys don't see any alternative that make everyone happy I am gonna remove all the |
|
@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. |
|
Fair enough, I understand the scijava application argument. Let's close this PR and open a new one with the |
|
Here is the new PR : #17 |
|
Hadrien certainly has a point, and I agree that ideally use of ImageJ
gateway should be okay and even encouraged for easy scripting. That was one
main reason for its existence after all. I have several thoughts and
options to suggest but cannot write them on mobile device now easily. I
will respond in more detail next week.
|
|
Glad to hear :-) So let's just merge #17 without any |
In continuation to #15 I propose this.
What do you think ?