common-workflow-language/cwljava

Incomplete $import support

jdidion opened this issue · 5 comments

A first guess is that this has something to do with $import, since that's the only commonality I see between these tests.

[info]   java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map
[info]   at org.w3id.cwl.cwl1_2.utils.YamlUtils.mapFromString(YamlUtils.java:10)
[info]   at org.w3id.cwl.cwl1_2.utils.Loader.documentLoadByUrl(Loader.java:56)
[info]   at org.w3id.cwl.cwl1_2.utils.Loader.loadField(Loader.java:72)
[info]   at org.w3id.cwl.cwl1_2.CommandLineToolImpl.<init>(CommandLineToolImpl.java:444)
[info]   at sun.reflect.GeneratedConstructorAccessor17.newInstance(Unknown Source)
[info]   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[info]   at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
[info]   at org.w3id.cwl.cwl1_2.utils.RecordLoader.load(RecordLoader.java:23)
[info]   at org.w3id.cwl.cwl1_2.utils.RecordLoader.load(RecordLoader.java:6)
[info]   at org.w3id.cwl.cwl1_2.utils.UnionLoader.load(UnionLoader.java:26)
[info]   at org.w3id.cwl.cwl1_2.utils.Loader.documentLoad(Loader.java:41)
[info]   at org.w3id.cwl.cwl1_2.utils.RootLoader.loadDocument(RootLoader.java:20)
[info]   at org.w3id.cwl.cwl1_2.utils.RootLoader.loadDocument(RootLoader.java:86)
[info]   at org.w3id.cwl.cwl1_2.utils.RootLoader.loadDocument(RootLoader.java:45)
mr-c commented

Yes, the python classes have explicit support for $import, but the java classes don't seem to only handle $import in certain places.

The first two will likely also trigger common-workflow-language/schema_salad#349 (not yet supporting default values in the codegen classes)

https://github.com/common-workflow-language/cwl-v1.2/blob/main/tests/schemadef-tool.cwl loads with the python codegen

mr-c commented

@jdidion which CWL document is that stack trace for?

params.cwl

mr-c commented

@jdidion Does the following fix the problem?

diff --git a/src/main/java/org/w3id/cwl/cwl1_2/utils/YamlUtils.java b/src/main/java/org/w3id/cwl/cwl1_2/utils/YamlUtils.java
index 89e12e9..266f43f 100644
--- a/src/main/java/org/w3id/cwl/cwl1_2/utils/YamlUtils.java
+++ b/src/main/java/org/w3id/cwl/cwl1_2/utils/YamlUtils.java
@@ -7,7 +7,7 @@ public class YamlUtils {
 
   public static Map<String, Object> mapFromString(final String text) {
     Yaml yaml = new Yaml();
-    final Map<String, Object> result = yaml.load(text);
+    final Map<String, Object> result = (Map<String, Object>) yaml.load(text);
     return result;
   }
 }
mr-c commented

Note that https://github.com/common-workflow-language/cwl-v1.2/blob/main/tests/import_schema-def.cwl does parse, so it may be the position of the$import that is the problem