crs4 / rocrate-validator

A Python package to validate RO-Crates
Apache License 2.0
7 stars 7 forks source link

WRROC validation should fail if a referenced workExample does not exist in the crate #45

Open dnlbauer opened 5 days ago

dnlbauer commented 5 days ago

In the example RO Crate below, the FormalParameter "#input_name" references a workExample "#THISDOESNOTEXIST". As the name suggests, there is no corresponding PropertyValue with this name in the crate. I think the validation should fail in this case, but it currently does not account for missing workExamples.

Example

{
  "@context": [
    "https://w3id.org/ro/crate/1.1/context",
    "https://w3id.org/ro/terms/workflow-run/context"
  ],
  "@graph": [
    {
      "@id": "ro-crate-metadata.json",
      "@type": "CreativeWork",
      "about": {
        "@id": "./"
      },
      "conformsTo": [
        {
          "@id": "https://w3id.org/ro/crate/1.1"
        },
        {
          "@id": "https://w3id.org/workflowhub/workflow-ro-crate/1.0"
        }
      ]
    },
    {
      "@id": "./",
      "@type": "Dataset",
      "name": "Example Workflow printing Hello World",
      "author": {
        "@id": "https://orcid.org/0000-0001-9447-460X"
      },
      "conformsTo": [
        {
          "@id": "https://w3id.org/workflowhub/workflow-ro-crate/1.0"
        },
        {
          "@id": "https://w3id.org/ro/wfrun/process/0.5"
        },
        {
          "@id": "https://w3id.org/ro/wfrun/workflow/0.5"
        }
      ],
      "dateCreated": "2024-11-04T14:25:49.698Z",
      "dateModified": "2024-11-04T14:25:48.125Z",
      "datePublished": "2024-11-04T14:25:48.125Z",
      "description": "An example workflow for the FAIR workflow platform",
      "hasPart": [
        {
          "@id": "workflow.yaml"
        }
      ],
      "keywords": [
        "Example",
        "Test",
        "Hello World"
      ],
      "license": {
        "@id": "https://spdx.org/licenses/MIT"
      },
      "mainEntity": {
        "@id": "workflow.yaml"
      }
    },
    {
        "@id": "https://w3id.org/ro/wfrun/process/0.5",
        "@type": "CreativeWork",
        "name": "Process Run Crate",
        "version": "0.1"
    },
    {
        "@id": "https://w3id.org/ro/wfrun/workflow/0.5",
        "@type": "CreativeWork",
        "name": "Workflow Run Crate",
        "version": "0.1"
    },
    {
        "@id": "https://w3id.org/workflowhub/workflow-ro-crate/1.0",
        "@type": "CreativeWork",
        "name": "Workflow RO-Crate",
        "version": "1.0"
    },
    {
      "@id": "https://orcid.org/0000-0001-9447-460X",
      "@type": "Person",
      "name": "Daniel Bauer",
      "url": "https://orcid.org/0000-0001-9447-460X"
    },
    {
      "@id": "workflow.yaml",
      "@type": [
        "File",
        "ComputationalWorkflow",
        "SoftwareSourceCode"
      ],
      "name": "workflow.yaml",
      "description": "Argo workflow that prints hello world into a file",
      "encodingFormat": "text/yaml",
      "input": [
        {
          "@id": "#input_name"
        }
      ],
      "programmingLanguage": {
        "@id": "https://argoproj.github.io/workflows"
      }
    },
    {
      "@id": "#input_name",
      "@type": "FormalParameter",
      "additionalType": "Text",
      "name": "name",
      "description": "Name of the person to greet in the Hello World",
      "valueRequired": "true",
      "workExample": {
        "@id": "#THISDOESNOTEXIST"
      }
    },
    {
        "@id": "https://argoproj.github.io/workflows",
        "@type": "ComputerLanguage",
        "name": "Argo",
        "url": "https://argoproj.github.io/workflows"
    }
  ]
}
> rocrate-validator validate  -nff -p workflow-run-crate-0.5 . --no-paging
(...)
[OK] RO-Crate is a valid workflow-run-crate-0.5 !!!