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
Iterate on Java codegen #299
Iterate on Java codegen #299
Conversation
Codecov Report
@@ Coverage Diff @@
## master #299 +/- ##
=========================================
+ Coverage 59.64% 62.05% +2.4%
=========================================
Files 14 14
Lines 2622 2630 +8
Branches 727 728 +1
=========================================
+ Hits 1564 1632 +68
+ Misses 890 827 -63
- Partials 168 171 +3
Continue to review full report at Codecov.
|
One thing you will want to figure out early on is how best to represent sum types in Java, eg a |
Seems like Object would at least be a place to start 😅. The yak I'm shaving with this project currently I think would mostly just benefit from the UnionLoader loading types and verifying things. Validation still happens even if the interface to using the beans is crap. Still... if I were going to put time into this... hmm... my first thought is it may be worth building UnionOf2<T1, T2>, UnionOf3<T1, T2, T3> .... and UnionOf2Loader, UnionOf3Loader, ....
The type definitions on the beans could become very ugly but may be somewhat informative. Certainly the potential for a lot more type safety also. Nervous about investing too much time here though. |
This pull request introduces 1 alert when merging d23d056 into 4a3f8ca - view on LGTM.com new alerts:
|
This pull request introduces 2 alerts when merging a04e02d into 4a3f8ca - view on LGTM.com new alerts:
|
@jmchilton you're a beast, thank you so much for working on this |
I got tripped up because schema-salad-tool and codegen modules treat fields with |
142aef9
to
daedf25
Compare
Now with encoded Java formatting (https://github.com/google/google-java-format) and JavaDocs. |
This pull request introduces 4 alerts and fixes 1 when merging daedf25 into 9d1c5e1 - view on LGTM.com new alerts:
fixed alerts:
|
This pull request introduces 3 alerts and fixes 1 when merging ead6ea0 into 9d1c5e1 - view on LGTM.com new alerts:
fixed alerts:
|
This pull request introduces 3 alerts when merging cfbe9e2 into 4806936 - view on LGTM.com new alerts:
|
cfbe9e2
to
7d8c67b
Compare
@jmchilton Super cool! Can you add a |
And while I'm making wishes, it would be nice if the schema docs became javadocs too. I tried your code with both cwl v1.0 and v1.1 's schemas, no crashes :-) |
This pull request introduces 3 alerts when merging 7d8c67b into 4806936 - view on LGTM.com new alerts:
|
A main method that validates a document I assume? Sounds easy enough. Placing the schema docs in the javadocs is a cool idea! I'm not sure... |
I registered the requested validator as the entry point for the jar and I added the maven assembly plugin to build a self contained jar variant that is good for a standalone demo: $ mvn assembly:single
$ java -jar target/gxformat2-0.0.1-SNAPSHOT-jar-with-dependencies.jar ../test-workflow.yml
Exception in thread "main" org.galaxyproject.gxformat2.gxformat2.utils.ValidationException: Failed to match union type
Trying 'RecordField'
the `inputs` field is not valid because:
Failed to match union type
Expected object with Java type of java.util.List but got java.util.HashMap
Trying 'RecordField'
the `type` field is not valid because:
Failed to match union type
Expected null
Expected one of [File, data, collection]
Expected object with Java type of java.util.List but got java.util.LinkedHashMap
at org.galaxyproject.gxformat2.gxformat2.utils.UnionLoader.load(UnionLoader.java:31)
at org.galaxyproject.gxformat2.gxformat2.utils.Loader.documentLoad(Loader.java:41)
at org.galaxyproject.gxformat2.gxformat2.utils.RootLoader.loadDocument(RootLoader.java:19)
at org.galaxyproject.gxformat2.gxformat2.utils.RootLoader.loadDocument(RootLoader.java:85)
at org.galaxyproject.gxformat2.gxformat2.utils.RootLoader.loadDocument(RootLoader.java:73)
at org.galaxyproject.gxformat2.gxformat2.utils.RootLoader.loadDocument(RootLoader.java:65)
at org.galaxyproject.gxformat2.gxformat2.utils.RootLoader.loadDocument(RootLoader.java:31)
at org.galaxyproject.gxformat2.gxformat2.utils.RootLoader.loadDocument(RootLoader.java:48)
at org.galaxyproject.gxformat2.gxformat2.utils.Validator.main(Validator.java:12) |
This pull request introduces 3 alerts when merging 5a6add1 into 4c83be8 - view on LGTM.com new alerts:
|
This pull request introduces 3 alerts when merging 074722b into 4c83be8 - view on LGTM.com new alerts:
|
arguably should be constructors?
6f1311d
to
f50a87f
Compare
This pull request introduces 1 alert and fixes 2 when merging f50a87f into 4c83be8 - view on LGTM.com new alerts:
fixed alerts:
|
This pull request introduces 1 alert and fixes 2 when merging 5841a80 into 4c83be8 - view on LGTM.com new alerts:
fixed alerts:
|
This pull request introduces 1 alert and fixes 2 when merging 57f9252 into 4c83be8 - view on LGTM.com new alerts:
fixed alerts:
|
57f9252
to
284c9e7
Compare
This pull request introduces 1 alert and fixes 2 when merging 284c9e7 into 4c83be8 - view on LGTM.com new alerts:
fixed alerts:
|
This pull request introduces 1 alert and fixes 2 when merging 7c0ac87 into 4c83be8 - view on LGTM.com new alerts:
fixed alerts:
|
7c0ac87
to
e6ca905
Compare
This pull request introduces 1 alert and fixes 2 when merging e6ca905 into 4c83be8 - view on LGTM.com new alerts:
fixed alerts:
|
This pull request introduces 1 alert and fixes 2 when merging 6515752 into 4c83be8 - view on LGTM.com new alerts:
fixed alerts:
|
"--codegen-target", | ||
type=str, | ||
default=None, | ||
help="Defaults to sys.stdout for python (and ./ for hidden Java codegen)", |
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.
Hidden?
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.
"Generate classes in target language, currently supported: python"
I'll add java to the list and remove the word hidden in a follow up.
type=str, | ||
metavar="directory", | ||
default=None, | ||
help="Directory of example documents for test case generation (Java only).", |
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.
Is there an example of how to use this?
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.
I wanted to allow valid and invalid document tests but I never got that far. Currently just assumes all the files in the examples directory are valid documents of this type.
W00t! Shall I merge? |
I have followups in the pipeline - but I'm not touching anything while this is such a pretty shade of green 😆. I'd go ahead an merge now. |
Build maven project containing Java objects for record types, capable of validation, and that can generate JavaDocs with schema docs contained within.
Missing stuff tracked #303.