Skip to content
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

Cannot deserialize from JSON Cas if child type comes before super type #276

Closed
jcklie opened this issue Feb 9, 2023 · 0 comments
Closed

Comments

@jcklie
Copy link
Collaborator

jcklie commented Feb 9, 2023

Describe the bug
Cannot deserialize from JSON Cas if child type comes before super type.

To Reproduce

with open("test.json") as f:
    load_cas_from_json(f)

Expected behavior
No error and it loads.

Error message
cassis.typesystem.TypeNotFoundError: Type with name [example.ParentType] not found!

Please complete the following information:

  • Version: 0.7.4
  • OS: Windows

Additional context

{
    "%TYPES": {
        "example.ChildType": {
            "%NAME": "example.ChildType",
            "%SUPER_TYPE": "example.ParentType",
            "childFeature": {
                "%NAME": "childFeature",
                "%RANGE": "uima.cas.Integer"
            }
        },
        "example.ParentType": {
            "%NAME": "example.ParentType",
            "%SUPER_TYPE": "uima.tcas.Annotation",
            "parentFeature": {
                "%NAME": "parentFeature",
                "%RANGE": "uima.cas.String"
            }
        }
    },
    "%FEATURE_STRUCTURES": [
        {
            "%ID": 1,
            "%TYPE": "uima.cas.Sofa",
            "sofaNum": 1,
            "sofaID": "_InitialView"
        },
        {
            "%ID": 2,
            "%TYPE": "example.ChildType",
            "childFeature": "child",
            "parentFeature": "parent",
            "@sofa": 1
        }
    ],
    "%VIEWS": {
        "_InitialView": {
            "%SOFA": 1,
            "%MEMBERS": [
                2
            ]
        }
    }
}
@jcklie jcklie added this to the 0.7.5 milestone Feb 9, 2023
jcklie added a commit that referenced this issue Feb 9, 2023
…per type

- Make JSON serializing more deterministic by sorting type system by name
jcklie added a commit that referenced this issue Feb 9, 2023
…per type

- Use toposort when deserializing JSON type systems
jcklie added a commit that referenced this issue Feb 9, 2023
…per type (#277)

* Add is_predefined helper
* Cannot deserialize from JSON Cas if child type comes before super type
* Make JSON serializing more deterministic by sorting type system by name
* Use toposort when deserializing JSON type systems
@jcklie jcklie closed this as completed Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant