Skip to content

Replace "Any" enum types with explicit types. #117

Open

Description

@stefan-pdx

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.

Activity

  1. tetron commented on Aug 26, 2015

    @tetron
    Member

    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

  2. tetron commented on Aug 28, 2015

    @tetron
    Member

    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?

  3. stefan-pdx commented on Aug 28, 2015

    @stefan-pdx
    Author

    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?

  4. stefan-pdx commented on Aug 28, 2015

    @stefan-pdx
    Author

    Ah -- the logicalType feature in Avro looks pretty neat!

  5. tetron commented on Aug 28, 2015

    @tetron
    Member

    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.

  6. kellrott commented on Sep 3, 2015

    @kellrott
    Contributor
  7. tetron commented on Sep 3, 2015

    @tetron
    Member

    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.

  8. mr-c commented on Oct 26, 2015

    @mr-c
    Member

    @tetron, what is the status of this issue?

  9. tetron commented on Oct 29, 2015

    @tetron
    Member

    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.

  10. added this to the unscheduled milestone on Jul 18, 2016
  11. added a commit that references this issue on Jul 20, 2017
  12. added a commit that references this issue on Mar 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions