biothings / discovery-app

The Data Discovery Engine project by the CD2H Data working-group
http://discovery.biothings.io
Apache License 2.0
4 stars 9 forks source link

Bug: Issue extending a schema #101

Closed gtsueng closed 2 years ago

gtsueng commented 2 years ago

The bioschemas ComputationalTool schema will be the basis for a new outbreak schema. It has been successfully imported, registered, and visualized in the DDE; however, when you try to extend it--there is an issue with inheriting the properties from Thing. These are key properties like name, url, identifier, and description which are generally needed, but not available as seen below (Thing has 0 properties): cant_inherit

As seen in the screenshot, Thing has nothing to inherit. This is odd, because the Bioschemas:ComputationalTool profile includes properties like name, description, etc. that were inherited from Thing as seen below: image

This is the profile I'd like to extend: https://discovery.biothings.io/view/bioschemas/ComputationalTool

gtsueng commented 2 years ago

Extending from the following profiles has the same issue:

The following profiles don't have this issue:

gtsueng commented 2 years ago

One thing to note is that all schema.org classes were initially thought to not have this issue. However, it appears that heavily nested schema.org classes may also have this issue (eg- schema:Patient).

nsjuty commented 2 years ago

Hi all - just wondering if there is an update on this bug? I'm blocked on a few tasks on Bioschemas extensions at the moment... thanks! Nick

marcodarko commented 2 years ago

Thank you for your patience, issue will be fixed soon I have opened a PR will tag you when it's ready!

Screen Shot 2021-11-17 at 11 48 47 AM
marcodarko commented 2 years ago

@gtsueng @nsjuty Update is live now and it appears to be fixed, please check it out and feel free to close once you confirm this addresses this issue.

gtsueng commented 2 years ago

@marcodarko The inherited properties are now viewable and can be extended via the DDE; however, the resulting extended json is not functional as the inherited properties in the validation are not properly referencing their source.

For example, I created this schema within the DDE by extending the bioschemas:ComputationalTool profile But, as you can see, even the most basic field "name" which is described as:

        "$schema": "http://json-schema.org/draft-07/schema#",
        "type": "object",
        "properties": {
          "name": {
            "description": "Descriptive name of the computational tool",
            "type": "string"
          },

Results in the following error: image

For trouble-shooting purposes, here is a simpler test schema that was created by extending the bioschemas:ComputationalTool schema. https://github.com/gtsueng/niaid-data-portal/blob/DDE_tests/schema/DDE_compToolTest.jsonld For this one, a single property was selected from each class in the hierarchy.

marcodarko commented 2 years ago

I guess there's already an issue for this: https://github.com/biothings/discovery-app/issues/77 so we can close this if the particular issue is resolved.

gtsueng commented 2 years ago

From what I've seen of the issue, it looks like all properties in the validation are affected, and the DDE will whine about the first property on the list, and move downwards if a problematic property is somehow addressed.

For example, I rearranged the order of the properties in the $validation of so that name is first, and the DDE will whine about name instead of codeRepository

Some info that might help diagnose the issue: The Bioschemas Gene class (https://github.com/BioSchemas/specifications/blob/master/Gene/jsonld/Gene_v1.0-RELEASE.json) exhibits this error in the DDE; however, this class is automatically copied into the bioschemas json schema and successfully displays in the DDE (https://github.com/BioSchemas/bioschemas-dde/blob/main/bioschemas.json)

This suggests that the issue is at least partly due to broken referencing. To test this, I applied some potential fixes for our generated schema that has this issue: https://github.com/gtsueng/niaid-data-portal/blob/DDE_tests/schema/DDE_compToolTest.jsonld

These are the potential schema fixes and the results of the test:

  1. Add the missing property codeRepository into the graph as a property to be defined in the schema. Result-- error persists
  2. Add a dummy version of the parent class in hopes it references properly. Result-- error persists
  3. Add a dummy version of the parent class in hopes it references properly AND add the missing property codeRepository into the graph as a property to be defined in the schema. Result-- Fixes error
  4. Add nothing but a reference to the bioschemas class in the @context. Result-- error persists
  5. Add reference to the bioschemas class in the @context and as a $bioschemas. Result--error persists
  6. Add reference to the bioschemas class in the @context and add the missing property codeRepository into the graph. Result-- error persists

From this test it looks like, both the non-schema.org parent class (or at least a dummy version of it) and any non-schema.org properties inherited from that class need to be included in order for it to reference and validate properly. Notice that the addition of the dummy bioschemas:ComputationalTool class and the codeRepository property specific to that class had to be added in order to bypass this issue, but the other properties inherited from schema.org into the bioschemas class no longer raise an issue in this case. Previously, all properties were problematic, even name.

gtsueng commented 2 years ago

closing this issue as the related bug (https://github.com/biothings/discovery-app/issues/77) has its own ticket