You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Replace "Any" enum types with explicit types. #117
I'm unable to validate the CWL schema (in Avro form) due to the implementation of the "Any" enum. As far as I can tell, the "Any" enum is used to designate fields that allow for any data type, including nested objects. However, this feature goes beyond the scope of an Avro schema and makes it impossible to utilize validation tools in Avro libraries.
Can we refactor the schema to specifically list out data types so that we can have a schema that can be validated with Avro tools?
Here's a list of portions of the schema that are impacted:
Parameter#default
Process#hints
WorkflowStepInput#default
WorkflowStep#hints
For each of those record fields, I think we can get away with representing the types as a union of standard Avro datatypes, as to not introduce any circular dependencies with other records.
You are right, I forgot about that. CWL currently gets around this by using a custom validation method that recognizes "Any".
I don't think a union of regular data types works because you can't directly express nested complex types such as lists of lists, and as far as I know you can't have named union types. If you can figure out a way to do this I will happily use it.
On August 26, 2015 5:15:38 PM EDT, Stefan Novak [email protected] wrote:
I'm unable to validate the CWL schema (in Avro form) due to the
implementation of the "Any" enum. As far as I can tell, the "Any" enum
is used to designate fields that allow for any data type, including
nested objects. However, this feature goes beyond the scope of an Avro
schema and makes it impossible to utilize validation tools in Avro
libraries.
Can we refactor the schema to specifically list out data types so that
we can have a schema that can be validated with Avro tools?
Here's a list of portions of the schema that are impacted:
Parameter#default
Process#hints
WorkflowStepInput#default
WorkflowStep#hints
For each of those record fields, I think we can get away with
representing the types as a union of standard Avro datatypes, as to not
introduce any circular dependencies with other records.
Reply to this email directly or view it on GitHub: #117
So far the least bad idea I have is to preprocess the JSON to pull out the "Any" fields and store them on the side before handing the document to Avro for loading. What do you think?
Well -- since there are only two types of fields that use Any, it might be easier to refactor the schema to remove that enum instead of introducing an additional preprocessor step.
For example, is it safe to assume that the #hints field is an array of various Requirement records?
As for WorkflowStepInput#default -- is it possible to just use a union of all types?
It is not safe to assume that hints only contains known ProcessRequirement records. Both hints and requirements are for specifying CWL extensions, the difference is that it is an error if a requirement is unrecognized or can't be fulfilled, but hints express extensions can be safely ignored if they are unrecognized. So for example conformance/draft-2/cat5-tool.cwl contains the hint BlibberBlubberFakeRequirement, if the validation is limited to known ProcessRequirements, it will fail validation when the correct behavior is to just ignore it. (The requirements field doesn't have this problem, because it is invalid to try and run a CWL document with unknown requirements.)
In the case of default this is used to specify default values for workflow input parameters. Workflow input parameters can be arbitrarily nested complex types (including arrays and records), so a union of primitive types is insufficient and it is impossible to create a "matches all types" schema in Avro 1.7.7 (but don't take my word for it, try it yourself).
Someone from the Avro mailing list suggested there might be a way using the unreleased logicalType feature, I haven't looked into it at all so I don't know how it works, so if you are able to look into it and report back, that would be very helpful.
It's in the specification for 1.7.7 but a grep of the Avro 1.7.7 source code does not seem to turn up any code that uses "logicalType". It's also not clear what Json.Reader does if the underlying type is "bytes" but you want to hold a json object.
In the mean time, I think it is going to be necessary to take some kind of hybrid approach that uses Avro to read most of the fields, but also looks at document separately to collect the remaining fields that are unknown or unhandled by Avro.
This remains unresolved. It's not intractable, but it requires someone invest the time to either work with the Avro code to get the behavior we need, or implement a workaround. It's waiting for a volunteer.
Activity
tetron commentedon Aug 26, 2015
You are right, I forgot about that. CWL currently gets around this by using a custom validation method that recognizes "Any".
I don't think a union of regular data types works because you can't directly express nested complex types such as lists of lists, and as far as I know you can't have named union types. If you can figure out a way to do this I will happily use it.
On August 26, 2015 5:15:38 PM EDT, Stefan Novak [email protected] wrote:
tetron commentedon Aug 28, 2015
I have posted to the Avro mailing list about this:
https://mail-archives.apache.org/mod_mbox/avro-user/201508.mbox/browser
So far the least bad idea I have is to preprocess the JSON to pull out the "Any" fields and store them on the side before handing the document to Avro for loading. What do you think?
stefan-pdx commentedon Aug 28, 2015
Well -- since there are only two types of fields that use
Any, it might be easier to refactor the schema to remove that enum instead of introducing an additional preprocessor step.For example, is it safe to assume that the
#hintsfield is an array of variousRequirementrecords?As for
WorkflowStepInput#default-- is it possible to just use a union of all types?stefan-pdx commentedon Aug 28, 2015
Ah -- the
logicalTypefeature in Avro looks pretty neat!tetron commentedon Aug 28, 2015
It is not safe to assume that
hintsonly contains knownProcessRequirementrecords. Bothhintsandrequirementsare for specifying CWL extensions, the difference is that it is an error if a requirement is unrecognized or can't be fulfilled, but hints express extensions can be safely ignored if they are unrecognized. So for exampleconformance/draft-2/cat5-tool.cwlcontains the hintBlibberBlubberFakeRequirement, if the validation is limited to known ProcessRequirements, it will fail validation when the correct behavior is to just ignore it. (Therequirementsfield doesn't have this problem, because it is invalid to try and run a CWL document with unknown requirements.)In the case of
defaultthis is used to specify default values for workflow input parameters. Workflow input parameters can be arbitrarily nested complex types (including arrays and records), so a union of primitive types is insufficient and it is impossible to create a "matches all types" schema in Avro 1.7.7 (but don't take my word for it, try it yourself).Someone from the Avro mailing list suggested there might be a way using the unreleased
logicalTypefeature, I haven't looked into it at all so I don't know how it works, so if you are able to look into it and report back, that would be very helpful.kellrott commentedon Sep 3, 2015
Is logicalType unreleased? I think its part of 1.7.7 ( https://avro.apache.org/docs/current/spec.html#Logical+Types )
tetron commentedon Sep 3, 2015
It's in the specification for 1.7.7 but a grep of the Avro 1.7.7 source code does not seem to turn up any code that uses "logicalType". It's also not clear what Json.Reader does if the underlying type is "bytes" but you want to hold a json object.
In the mean time, I think it is going to be necessary to take some kind of hybrid approach that uses Avro to read most of the fields, but also looks at document separately to collect the remaining fields that are unknown or unhandled by Avro.
mr-c commentedon Sep 15, 2015
I do see 'logicalType' in the head of their development tree.
http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/LogicalTypes.java
mr-c commentedon Oct 26, 2015
@tetron, what is the status of this issue?
tetron commentedon Oct 29, 2015
This remains unresolved. It's not intractable, but it requires someone invest the time to either work with the Avro code to get the behavior we need, or implement a workaround. It's waiting for a volunteer.
Merge pull request #117 from common-workflow-language/better-bump
Squashed 'v1.1.0-dev1/salad/' changes from 98a5bea..27c20e8