Comments (6)
It would be slick, and should be doable, too, if we generate the OpService
interface and the default implementation, between the compile
and test
phase.
The only two problems I see:
- no non-generated classes in ij-ops could depend on
OpService
- it would be harder to stay SemVer-compliant because we do not change the API explicitly anymore
So what I would suggest is something different (similar to how we do things in ij1-patcher's HeadlessGenericDialog
): have a "completeness" unit test that compares the OpService
signature to the list of all the available built-in ops.
Hmm?
from imagej-ops.
There is a chicken-and-egg problem with having those method signatures lives in imagej-ops
itself: the autogenerator will need to depend on imagej-ops
in order to know the available ops. I still think it would be valuable to have these method signatures somewhere though—perhaps a separate service component elsewhere?
from imagej-ops.
I agree with @dscho that instead of autogenerating, let's add a "completeness" test that fails the build if the OpService
interface is missing any core op signatures. That will be very doable. I am pulling this into an earlier milestone, because I think having the compile-safety will be extremely helpful in many ways.
from imagej-ops.
I started work on this on the built-ins branch, which adds a fancy unit test that verifies all @BuiltIn
-annotated methods of OpService
cover the set of available Op
implementations, and vice versa.
However, I ran into trouble code generating the method signatures including generics. I posted on SO for help.
Fortunately, this functionality is not strictly required for the checking feature, since the actual type matching (especially between generic Type
and Type
, which is what the unit test is able to use in this scenario) in OPS is pretty robust. In other words: we can manually do the work of adding all 300 method signatures needed, being careful to get the generic parameters right by hand, and the unit test should at least inform us whether we are "close enough" for things to generally work.
That said, it would be ideal if the unit test could spit out the exact missing method signature which needs to be added for each uncovered Op
implementation. But doing that would require a deeper understanding of generics than I have right now.
from imagej-ops.
I thought of an easier and more flexible way to do this. The type signature comparison logic I wrote (still pending on the built-ins
branch) will still be useful, but in general we do not need to be slaves to whether everything matches. Better is for the @BuiltIn
annotation to take an op=Class<? extends Op>
parameter, which we can use to trivially determine which available ops do not have corresponding built-in method signatures.
The argument type matching on top of that is just gravy: it might be nice to warn if the signature could not possibly match the purported op class, but really that is an increasingly complex problem which does not need to be solved. On the contrary, our actual requirements are:
- Know that each concrete
Op
plugin has at least one built-in method signature in theOpService
. A parameter on@BuiltIn
would accomplish this nicely. - Make sure that each built-in method signature has a corresponding unit test. Such unit tests should also be annotated, so that we can have a unit test which ensures this is the case (watch the Watchmen 😉).
- Have the flexibility to add multiple signatures for the same
Op
, including signatures that will ultimately resolve to that op even if op reductions (#57) occur. - Avoid ever calling
OpService#run
from other built-in op implementations; rather, we should always call the appropriate built-in type-safe method, adding such built-in methods as they are needed. Then all ugly and confusing casts are encapsulated within theDefaultOpService
and its helper classes.
I will keep working on the built-ins
branch with the above requirements in mind. When that branch accomplishes these goals and is merged, this issue can be closed.
from imagej-ops.
Commit 52be9fd, and PR #145, completed this work. Thanks to @awalter17 for her hard work there.
We do not actually autogenerate the signatures, but we unit test that they are present, and spit out helpful non-generified method bodies for the signatures which are missing.
from imagej-ops.
Related Issues (20)
- Median not returning mean of two middle values for even number of values HOT 8
- Add stats.mode op to compute modal value
- Confusing behavior for histogram HOT 2
- Quesrtion: Sobel filter HOT 3
- SobelRAI derivativeComputer array error prone if dimension mismatch HOT 5
- AbstractPadAndFFTFilter overrides OutOfBoundsFactory parameter of PadAndConvolveFFTF HOT 7
- Ops filter gauss does not respect the image dimensions HOT 1
- JOML version from parent pom conflicts with current scenery/sciview
- Repeated computation of co-occurrence matrix in haralick features
- Yen threshold differs from IJ1 HOT 4
- Fractal Dimension creates thousands of zombie threads that crash ImageJ HOT 4
- filter/addPoissonNoise hangs up with large pixel values
- Size inconsistencies for Polygon2Ds HOT 2
- Improve OpSearchResult to give limited type information in stringified op HOT 2
- OpListings ignore preallocated outputs
- DefaultGaussRAI.compute() reports cryptic IAE for sigma dimension mismatch HOT 1
- ClassCastException from ConstantToIIOutputII
- OpSearcher reduces OpListings too eagerly HOT 3
- CreateOutputFFTMethods requires a image creator that can take an ImgFactory HOT 1
- FrangiVesselness: Auto-fill the spacing field
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imagej-ops.