Repository navigation
Closed
scijava/incubator
#113Milestone
Description
The improvements made to ops.help() have been great for helping me explore the new API. But there is some unexpected behavior like ops.help("create").
For example here's the output for deconvolve:
print(ops.help("deconvolve"))
Names:
> deconvolve.accelerate
> deconvolve.firstGuess
> deconvolve.normalizationFactor
> deconvolve.richardsonLucy
> deconvolve.richardsonLucyCorrection
> deconvolve.richardsonLucyTV
> deconvolve.richardsonLucyUpdateBut when I do the same for create I get this:
print(ops.help("create"))
Ops:
> create(
Inputs:
Dimensions null
Object null
Outputs:
ImgFactory<Object> output1 -> imgFactory
)
Aliases: [create.imgFactory]
> create(
Inputs:
Dimensions null
Type null
Outputs:
Img<Type> output1 -> img
)
Aliases: [create.img]
> create(
Inputs:
Dimensions null
Type null
ImgFactory<Type> null
Outputs:
Img<Type> output1 -> img
)
Aliases: [create.img]
> create(
Inputs:
Dimensions null
IntegerType null
Outputs:
ImgLabeling<Object, IntegerType> output1 -> imgLabeling
)
Aliases: [create.imgLabeling]
> create(
Inputs:
Dimensions null
IntegerType null
ImgFactory<IntegerType> null
Outputs:
ImgLabeling<Object, IntegerType> output1 -> imgLabeling
)
Aliases: [create.imgLabeling]
> create(
Inputs:
double[][] null
ComplexType null
Outputs:
RandomAccessibleInterval<ComplexType> output1 -> kernelRAI
)
Aliases: [create.kernel]
> create(
Inputs:
double[] null
Integer null
ComplexType null
Outputs:
RandomAccessibleInterval<ComplexType> output1 -> biGaussKernelRAI
)
Aliases: [create.kernel2ndDerivBiGauss]
> create(
Inputs:
double[] null
Integer null
ComplexType null
Outputs:
RandomAccessibleInterval<ComplexType> output1 -> biGaussKernelRAI
)
Aliases: [create.kernelBiGauss]
> create(
Inputs:
Dimensions null
Double null
Double null
Double null
Double null
Double null
Double null
Double null
ComplexType+NativeType null
Outputs:
Img<ComplexType+NativeType> output1 -> diffractionKernelRAI
)
Aliases: [create.kernelDiffraction]
> create(
Inputs:
double[] null
double[] null
ComplexType null
Outputs:
RandomAccessibleInterval<ComplexType> output1 -> gaborKernelRAI
)
Aliases: [create.kernelGabor]
> create(
Inputs:
Double null
double[] null
ComplexType null
Outputs:
RandomAccessibleInterval<ComplexType> output1 -> gaborKernelRAI
)
Aliases: [create.kernelGabor]
> create(
Inputs:
double[] null
ComplexType null
Outputs:
RandomAccessibleInterval<ComplexType> output1 -> gaussKernelRAI
)
Aliases: [create.kernelGauss]
> create(
Inputs:
Double null
Integer null
ComplexType null
Outputs:
RandomAccessibleInterval<ComplexType> output1 -> gaussKernelRAI
)
Aliases: [create.kernelGauss]
> create(
Inputs:
double[] null
ComplexType null
Outputs:
RandomAccessibleInterval<ComplexType> output1 -> logKernelRAI
)
Aliases: [create.kernelLog]
> create(
Inputs:
Double null
Integer null
ComplexType null
Outputs:
RandomAccessibleInterval<ComplexType> output1 -> logKernelRAI
)
Aliases: [create.kernelLog]
> create(
Inputs:
ComplexType null
Outputs:
RandomAccessibleInterval<ComplexType> output1 -> sobelKernelRAI
)
Aliases: [create.kernelSobel]
> create(
Inputs:
Type null
Outputs:
Type output1 -> type
)
Aliases: [create.type]
> create(
Inputs:
Outputs:
BitType output1 -> output
)
Aliases: [create.bit]
> create(
Inputs:
Outputs:
ByteType output1 -> output
)
Aliases: [create.byte]
> create(
Inputs:
Outputs:
ComplexFloatType output1 -> output
)
Aliases: [create.cfloat32]
> create(
Inputs:
Outputs:
ComplexDoubleType output1 -> output
)
Aliases: [create.cfloat64]
> create(
Inputs:
Outputs:
FloatType output1 -> output
)
Aliases: [create.float32]
> create(
Inputs:
Outputs:
DoubleType output1 -> output
)
Aliases: [create.float64]
> create(
Inputs:
Outputs:
IntType output1 -> output
)
Aliases: [create.int32]
> create(
Inputs:
Outputs:
LongType output1 -> output
)
Aliases: [create.int64]
> create(
Inputs:
Outputs:
ShortType output1 -> output
)
...I expected an output like this:
> create.Img
> create.ImgFactory
> create.ImgLabeling
> create.ImgPlus
> create.kernel
> create.kernelDiffraction
> create.kernelGabor
...There are a few other namespaces that do this, which I think is okay if there are no sub methods (i.e. namespace.method) but it didn't make sense to me in the create namespace case.
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
- StatusShow more project fieldsDone
Activity
hinerm commentedon Dec 28, 2023
The desired output here is certainly available through the
aliases, but that may not always be the case.One simple option would be to have a heuristic that abbreviates things if a) there are N+ results (say, N=5) and b) the results actually have aliases.
But if we're considering changes to the help output I personally would favor moving to something more javadoc-ish that succinctly summarizes the available ops. For something user-facing anything longer than a page of text (~45 lines) feels unwieldy (currently the
createhelp has 572 lines).When I'm looking at this output, I have these thoughts:
Inputssection can be omittedoutput1 -> outputtell us? Why have output names at all? Where are they even coming from?create) repeated seems unnecessary. It's an implementation detail that the user doesn't care about - the relevant info is that the indicated method is reachable via the op name that was given.Personally I would want to see a table like this:
I also noticed that if an op is matched by its alias, that isn't reflected in the result. e.g.
Whereas I think it would be more flexible to report the queried command, and then group all un-queried aliases together, e.g.:
Of course, this probably breaks down for Ops with large numbers of parameters... but wrapping lines may be sufficient.
@ctrueden @elevans @gselzer thoughts/feelings?
gselzer commentedon Dec 28, 2023
Here are my thoughts @hinerm:
What do you mean by abbreviation? It would be one thing to add additional simplifiers to e.g. reduce down some of those
createOps, but I do think that we would need to actually list all Ops. I think whether or not I'd be in favor depends on what you're thinking...Yes, I agree that we probably need something better. More on that below.
Yup, good idea.
No, you cannot - we can fix that too.
Well, they come from the
Member- allMembers need a name so we default it withoutput1, although we could special-caseItemIO.OUTPUTmembers inOpDescriptionGeneratorto ignore them. Theoutputis coming from the description of the@returntag in the javadoc - if you don't like it, we should edit the javadoc!createis the name of the Op - we actually don't write the function name, because like you said it's an implementation detail.I'm not sure what you'd prefer, when we're working within the confines of a
String. I'll leave the table discussion to below.Sure, we could add that.
Your example there looks nice, but there are a number of technical questions that remain to be answered:
TableBasedOpDescriptionGeneratorin scijava-ops-legacy that operates via side effects, but that would only work in ImageJ2/Fiji.Yeah, that's a tricky one. What if we ignore the aliases? Is a user really going to want to know the other names you can use to call an Op? Seems like an implementation detail...
Well, if you agree that we don't need the alias, then we're left with a one-column table, which means we don't even need a table? Maybe we just use whitespace better?
gselzer commentedon Jan 2, 2024
@hinerm I set up branch
scijava/scijava-ops-engine/refactor-descriptionsfor progress on this issue. So far I have:OutputsandComputers (I/O)sections.@elevans @ctrueden did you get a chance to reflect on @hinerm's suggestions above?
gselzer commentedon Jan 3, 2024
I spent a little more time this morning, and @elevans helped me out a little with the design!
Here's what
ops.help("create")looks like now:Computers and Inplaces are a little trickier, but here's the solution @elevans and I came up with:
(Inplaces instead annotate a parameter with
MUTABLEand the output type isNone [Overwrites MUTABLE]ctrueden commentedon Jan 3, 2024
I agree with all of @hinerm's suggestions above, and had similar thoughts to what @gselzer already wrote. Here are my current thoughts and questions given the current status above:
Why is this
•symbol used? Can we please just use the asterisk*? Or else: use Unicode more thoroughly like → instead of->? Either way is OK, but let's be consistent.Did we rename "container" to "buffer" now? I'm OK with that, but I'm not OK with it being called "container" under the hood and "buffer" only in the help. If you guys feel the term "buffer" is friendlier, let's rename it throughout the codebase. FWIW: I do think the term "buffer" is wrong here technically, because a buffer traditionally can be too small for the output, at which point the output stops computing there, whereas with Ops, an exception is presumably thrown if the container is the wrong size? This may be a larger issue for discussion...
I do not like the
-> None [Fills BUFFER]and-> None [Overwrites MUTABLE]syntax. It is clunky and I would rather just omit it. If you don't know what a "Buffer" or "Mutable" is, then read the basic Ops introduction, where it is explained.I'm not sure it's a good idea to leave off the parameter names. Those names exist to make the op's purpose easier to understand, and cutting them for the sake of conciseness seems arbitrary to me. You could just as easily cut the formal types in favor of the names. Furthermore, in languages that support keyword arguments, not knowing the keywords sucks. So probably we just need to have both names and types. But we ought to use the Python/Kotlin-style declaration syntax of
image: RandomAccessibleInterval<NumericType>rather than Java'sRandomAccessibleInterval<NumericType> image, especially since you are already using the Python/Kotlin-style return value syntax with->here; mixing them is inconsistent and confusing.Regarding the create ops: I don't understand why for all of them the name is
createwhile it's only the aliases that have the fully qualified names. Shouldn't it be the other way around, where the shorthandcreateis simply an alias for each?I feel like I already discussed this elsewhere (either written or verbal) with @gselzer, but for this specific issue of
ops.help("create")conflating thecreateops with thecreatenamespace: didn't we agree that we simply want it to show only the create namespace, and leave off the ops? If not: that's how I think it should work (i.e. I agree with @elevans's original expectation here). The fact that these ops all have an aliascreatein the global namespace is an implementation detail, which doesn't actually have to be that way: let's consider changing it tocreateContainerto avoid conflation with thecreatenamespace. Then when people want to see all thecreateContainerops in one listing, they can just ask for it withops.help("createContainer").gselzer commentedon Jan 3, 2024
Thanks @ctrueden for responding!
Oh, yeah,
*looks just fine. Let's just use that then.Fair point - let's just keep it container now.
The goal here is to make it clear that (a) one of the input objects will be altered and (b) denote which object it is. I believe that this solution ties those two things together nicely by making use of shared terminology (i.e. the capitalized word in both the output and the input). I am curious as to whether you believe this goal is not important, or whether you have another design that may accomplish it better.
Good catch, I meant to add that but forgot. Note that there's a real crunch for space with this design - for a lot of the image Ops, there's so much text that we wrap lines, and that reduces readability. I'm not saying we shouldn't add names, just noting that space is at a premium with this design.
Since we did away with printing out the aliases of Ops on this branch, we just return all Ops with that name, note that Ops still has no formal definition of an alias - under the hood it's just a bunch of strings.
Okay, so there are two different needs at play here:
With that being said, here's the additional requirement that I'd like to impose with naming, and the changes that will be required:
namespace\.namei.e. there has to be (at least??) one period in the name to require each name belong to some namespace.create/copyOps must have a name that belongs to thecreate/copynamespace.create/copyOps (or at least all of the ones that want to be used by the engine) also declare the nameengine.create/engine.copy.ctrueden commentedon Jan 3, 2024
👍👍
Sounds good.
Why force it? It's not a technical requirement for the Ops engine. Just trying to corral people toward a best practice?
Yep. But I still think there is value in declaring the "best" of the names as the name, and others as aliases. For the
engine.createops, I favorengine.createbeing given as an alias, not as the most visible name in the declaration. (And same forengine.copy.)I understand, and I think we are all on the same wavelength about this.
Perhaps we should take a page out of the Python code linter book, and do something like:
for short signatures, and:
for signatures exceeding a certain length, say 88 characters?
gselzer commentedon Jan 3, 2024
@ctrueden thanks again for the feedback!
Well, my point was more that if we make the requirement a requirement we will likely have to change the names of many of the create Ops such that they no longer have names
create/copy- they'll have to have a namecreate.X, if they don't have one already.And my point here was that I don't think it really matters, since now we aren't describing Ops with their aliases. The question would then be where you'd see that an Op can be found by multiple names, and I can't really think of one.
Potentially, although keep in mind that I think it looks sillier in our case without the function name (note that I haven't added the parameter names back in yet):
And at that point we'd be so close to adding back some of the things that made @hinerm want the changes:
Also keep in mind that I haven't (yet?) modified
helpVerbose- so maybe that can satisfy some of these things you're concerned about?ctrueden commentedon Jan 3, 2024
If we're only talking about the simple/default help here, then my vote is to cut the types in favor of only the names. Or use drastically simplified types like "image", "number", etc. So then we won't get lines that are "too long" anymore.
elevans commentedon Jan 4, 2024
I agree with @ctrueden here in that we cut the types in favor of only the names for the simpler
helpcall. I'm not sure if using simplified types would be better or add more confusion into the mix.Merge pull request #113 from scijava/scijava/scijava-ops-engine/refac…