Skip to content

Add Op Parameter Nullability, Java Field Op Parameter Types to YAML#216

Merged
hinerm merged 3 commits intomainfrom
scijava-ops-indexer/yaml-param-nullability
May 16, 2024
Merged

Add Op Parameter Nullability, Java Field Op Parameter Types to YAML#216
hinerm merged 3 commits intomainfrom
scijava-ops-indexer/yaml-param-nullability

Conversation

@gselzer
Copy link
Copy Markdown
Member

@gselzer gselzer commented May 13, 2024

This PR, designed to close #200, by adding a nullable field in the YAML to each parameter of each Op. Currently, the indexer fills this field by:

  • Looking for the @Nullable annotation on any method parameters (suitable for Ops written as Java classes and methods), recording that parameter as nullable.
  • Looking for (nullable) written at the end of a parameter tag (suitable for Ops written as Java classes, fields, and methods), recording that parameter as nullable.
  • Failing the first two, records the parameter as not nullable.

This PR additionally solves some other related issues:

  • Java Field Ops did not have their parameter types included in the YAML

    This is a difficult issue for us to solve, because as annotation processing happens before compilation we cannot introspect the field type to find the functional method. The solution was to analyze the string output from the field's TypeMirror, which includes fully qualified type strings for each of the type parameters of the functional interface. Since there's a direct mapping from type parameter to functional method type for each of the interfaces in scijava-function, it means we can derive parameter types for each Op field implementing one of the supported Op interfaces. If the field is not one of our supported interfaces, all parameter types are mapped to the String UNKNOWN.

  • Create a new YAML-specific OpInfo implementation YAMLOpMethodInfo to read Op parameters directly from YAML. This allows us to scrape parameter names and descriptions right away (instead of baking them in after OpInfo creation)

    This change is not particularly necessary for solving Optionality of parameters is not embedded in Op YAML #200, but it is much easier to lump this change in with the fixes for it, because the in-javadoc nullable markers are not easily visible without this new OpInfo implementation. This new implementation is designed to lazily load all Classes relevant to the Op (the Op itself, parameter types, etc) as late as possible to save some computation, as well as to take advantage of the YAML data directly.

TODO

  • Clean up changeset
  • Document any new changes.
    * [ ] Update scijava-ops-image to utilize the new changes (e.g. declaring nullable parameters with the javadoc parenthetical instead of the annotation). Not going to do this right now, it's an internal change that doesn't need to be done right now.
  • Add YAMLOpFieldInfo and YAMLOpClassInfo.
    * [ ] Consider an AbstractOpMethodInfo to house common functionality between current OpMethodInfo and YAMLOpMethodInfo. Also doesn't need to be done right now.
  • Update scijava-ops-ext-parser?

@gselzer gselzer requested a review from hinerm May 13, 2024 19:24
@gselzer gselzer force-pushed the scijava-ops-indexer/yaml-param-nullability branch 18 times, most recently from 1965737 to deacfe7 Compare May 14, 2024 21:08
This commit makes many different changes/bugfixes, all tied to enabling
richer YAML output by the scijava-ops-indexer, and to enabling richer
usage within the scijava-ops-engine.
@gselzer gselzer force-pushed the scijava-ops-indexer/yaml-param-nullability branch from deacfe7 to d6a8539 Compare May 14, 2024 21:38
@gselzer gselzer marked this pull request as ready for review May 14, 2024 21:39
Copy link
Copy Markdown
Member

@hinerm hinerm left a comment

Choose a reason for hiding this comment

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

Thanks @gselzer. Given that things seem to still be working with these changes I gave it a fairly cursory look. Aside from these minor points, consider re-testing the paper use-cases just to make sure everything is still good there.

And we don't need to resolve the scijava-ext-parser at this time given that its output YAML is still working (as I tested the OpenCV use case)

@hinerm hinerm merged commit 953a54a into main May 16, 2024
@hinerm hinerm deleted the scijava-ops-indexer/yaml-param-nullability branch May 16, 2024 13:54
@gselzer gselzer mentioned this pull request May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optionality of parameters is not embedded in Op YAML

2 participants