forked from crs4/rocrate-validator
-
Notifications
You must be signed in to change notification settings - Fork 1
21 referencing a workflow crate mk2 #28
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
Open
douglowe
wants to merge
9
commits into
develop
Choose a base branch
from
21-referencing-a-workflow-crate-mk2
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
47416a8
Implemented SHACL rules for rule set 6 (referencing a workflow crate)
EttoreM f97d3a6
Changed description of SHOULD rule
EttoreM 80b7df7
Added tests for rule-set 6 implemented in SHACL
EttoreM 06303a4
restore root data entity and requesting agent checks
douglowe e012cae
Addressed Alex' comments.
EttoreM a397f38
Removed double colon
EttoreM e6a93fb
test max number of mainEntitys
douglowe 0337d03
clean up conformsTo test description
douglowe 0c11b6d
Added test to check that has cardinality no greater than 1
EttoreM File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
46 changes: 0 additions & 46 deletions
46
rocrate_validator/profiles/five-safes-crate/must/1_root_data_entity.ttl
This file was deleted.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
rocrate_validator/profiles/five-safes-crate/must/6_workflow_reference.ttl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # Copyright (c) 2025 eScience Lab, The University of Manchester | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| @prefix ro: <./> . | ||
| @prefix ro-crate: <https://github.com/crs4/rocrate-validator/profiles/ro-crate/> . | ||
| @prefix five-safes-crate: <https://github.com/eScienceLab/rocrate-validator/profiles/five-safes-crate/> . | ||
| @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
| @prefix schema: <http://schema.org/> . | ||
| @prefix purl: <http://purl.org/dc/terms/> . | ||
| @prefix sh: <http://www.w3.org/ns/shacl#> . | ||
| @prefix validator: <https://github.com/crs4/rocrate-validator/> . | ||
| @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
|
|
||
|
|
||
|
|
||
| five-safes-crate:ReferenceToWorkflowCrate | ||
| a sh:NodeShape ; | ||
| sh:name "RootDataEntity" ; | ||
| sh:targetClass ro-crate:RootDataEntity ; | ||
|
|
||
| # RootDataEntity MUST have an mainEntity property | ||
| sh:property [ | ||
| a sh:PropertyShape ; | ||
| sh:name "mainEntity" ; | ||
| sh:path schema:mainEntity ; | ||
| sh:minCount 1 ; | ||
| sh:maxCount 1 ; | ||
| sh:nodeKind sh:IRI ; | ||
| sh:severity sh:Violation ; | ||
| sh:message "The RootDataEntity MUST have exactly one schema:mainEntity property that is an IRI." ; | ||
| ] ; | ||
|
|
||
| # The mainEntity of a RootDataEntity MUST be a Dataset | ||
| sh:property [ | ||
| a sh:PropertyShape ; | ||
| sh:name "mainEntity" ; | ||
| sh:path schema:mainEntity ; | ||
| sh:class schema:Dataset ; | ||
| sh:severity sh:Violation ; | ||
| sh:message "The mainEntity pointed to by the RootDataEntity MUST be of type schema:Dataset" ; | ||
| ] . | ||
|
|
||
| five-safes-crate:mainEntityHasProperConformsTo | ||
| a sh:NodeShape ; | ||
| sh:name "mainEntity" ; | ||
| sh:description "The mainEntity of the RootDataEntity MUST have a conformsTo property with an IRI starting with https://w3id.org/workflowhub/workflow-ro-crate" ; | ||
| sh:targetObjectsOf schema:mainEntity ; | ||
| sh:sparql [ | ||
| a sh:SPARQLConstraint ; | ||
| sh:name "conformsTo" ; | ||
| sh:message "conformsTo IRI must start with https://w3id.org/workflowhub/workflow-ro-crate" ; | ||
| sh:select """ | ||
| PREFIX schema: <http://schema.org/> | ||
| PREFIX purl: <http://purl.org/dc/terms/> | ||
| SELECT $this WHERE { | ||
| $this purl:conformsTo ?iri . | ||
| FILTER(!STRSTARTS(STR(?iri), "https://w3id.org/workflowhub/workflow-ro-crate")) | ||
| } | ||
| """ ; | ||
| ] . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
161 changes: 161 additions & 0 deletions
161
tests/integration/profiles/five-safes-crate/test_5src_6_workflow_reference.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| # Copyright (c) 2024-2025 CRS4 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import logging | ||
|
|
||
| from rocrate_validator.models import Severity | ||
| from tests.ro_crates import ValidROC | ||
| from tests.shared import do_entity_test, SPARQL_PREFIXES | ||
|
|
||
| # set up logging | ||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| # ----- MUST fails tests | ||
|
|
||
|
|
||
| def test_5src_root_data_entity_no_main_entity(): | ||
| """ | ||
| Remove the RootDataEntity's mainEntity so minCount=1 is violated. | ||
| """ | ||
| sparql = ( | ||
| SPARQL_PREFIXES | ||
| + """ | ||
| DELETE { | ||
| <./> schema:mainEntity ?m . | ||
| } | ||
| WHERE { | ||
| <./> schema:mainEntity ?m . | ||
| } | ||
| """ | ||
| ) | ||
|
|
||
| do_entity_test( | ||
| rocrate_path=ValidROC().five_safes_crate_request, | ||
| requirement_severity=Severity.REQUIRED, | ||
| expected_validation_result=False, | ||
| expected_triggered_requirements=["RootDataEntity"], | ||
| expected_triggered_issues=[ | ||
| "The RootDataEntity MUST have exactly one schema:mainEntity property that is an IRI." | ||
| ], | ||
| profile_identifier="five-safes-crate", | ||
| rocrate_entity_mod_sparql=sparql, | ||
| ) | ||
|
|
||
|
|
||
| def test_5src_root_data_entity_main_entity_not_dataset_iri(): | ||
| """ | ||
| Test a Five Safes Crate where the RootDataEntity's mainEntity is an IRI but not typed as schema:Dataset. | ||
| (We point mainEntity to a new crate-local entity typed as something else.) | ||
| """ | ||
| sparql = ( | ||
| SPARQL_PREFIXES | ||
| + """ | ||
| DELETE { | ||
| <./> schema:mainEntity ?m . | ||
| } | ||
| INSERT { | ||
| # add an IRI that is NOT typed as schema:Dataset (e.g. a schema:SoftwareSourceCode) | ||
| <./> schema:mainEntity <./not-a-dataset> . | ||
| <./not-a-dataset> a schema:SoftwareSourceCode . | ||
| } | ||
| WHERE { | ||
| <./> schema:mainEntity ?m . | ||
| } | ||
| """ | ||
| ) | ||
|
|
||
| do_entity_test( | ||
| rocrate_path=ValidROC().five_safes_crate_request, | ||
| requirement_severity=Severity.REQUIRED, | ||
| expected_validation_result=False, | ||
| expected_triggered_requirements=["RootDataEntity"], | ||
| expected_triggered_issues=[ | ||
| "The mainEntity pointed to by the RootDataEntity MUST be of type schema:Dataset" | ||
| ], | ||
| profile_identifier="five-safes-crate", | ||
| rocrate_entity_mod_sparql=sparql, | ||
| ) | ||
|
|
||
|
|
||
| def test_5src_main_entity_conformsTo_invalid(): | ||
| """ | ||
| Test a Five Safes Crate where the mainEntity's purl:conformsTo IRI does NOT start with | ||
| "https://w3id.org/workflowhub/workflow-ro-crate" (violates the SHACL SPARQL constraint). | ||
| """ | ||
| sparql = ( | ||
| SPARQL_PREFIXES | ||
| + """ | ||
| PREFIX purl: <http://purl.org/dc/terms/> | ||
| DELETE { | ||
| ?dataset purl:conformsTo ?iri . | ||
| } | ||
| INSERT { | ||
| ?dataset purl:conformsTo <http://example.org/not-workflow-ro-crate> . | ||
| } | ||
| WHERE { | ||
| <./> schema:mainEntity ?dataset . | ||
| ?dataset purl:conformsTo ?iri . | ||
| FILTER(STRSTARTS(STR(?iri), "https://w3id.org/workflowhub/workflow-ro-crate")) | ||
| } | ||
| """ | ||
| ) | ||
|
|
||
| do_entity_test( | ||
| rocrate_path=ValidROC().five_safes_crate_request, | ||
| requirement_severity=Severity.REQUIRED, | ||
| expected_validation_result=False, | ||
| expected_triggered_requirements=["mainEntity"], | ||
| expected_triggered_issues=[ | ||
| "conformsTo IRI must start with https://w3id.org/workflowhub/workflow-ro-crate" | ||
| ], | ||
| profile_identifier="five-safes-crate", | ||
| rocrate_entity_mod_sparql=sparql, | ||
| ) | ||
|
|
||
|
|
||
| # ----- SHOULD fails tests | ||
|
|
||
|
|
||
| def test_5src_main_entity_missing_distribution_warning(): | ||
| """ | ||
| Test a Five Safes Crate where a mainEntity has an HTTP(S) IRI but no distribution with an HTTP(S) URL. | ||
| This should trigger the SHACL warning about missing or non-HTTP(S) distributions. | ||
| """ | ||
| sparql = ( | ||
| SPARQL_PREFIXES | ||
| + """ | ||
| DELETE { | ||
| ?dataset schema:distribution ?dist . | ||
| } | ||
| WHERE { | ||
| <./> schema:mainEntity ?dataset . | ||
| ?dataset schema:distribution ?dist . | ||
| FILTER (STRSTARTS(STR(?dataset), "http://") || STRSTARTS(STR(?dataset), "https://")) . | ||
| FILTER (STRSTARTS(STR(?dist), "http://") || STRSTARTS(STR(?dist), "https://")) . | ||
| } | ||
| """ | ||
| ) | ||
|
|
||
| do_entity_test( | ||
| rocrate_path=ValidROC().five_safes_crate_request, | ||
| requirement_severity=Severity.RECOMMENDED, | ||
| expected_validation_result=False, | ||
| expected_triggered_requirements=["mainEntity"], | ||
| expected_triggered_issues=[ | ||
| "If mainEntity has an HTTP(S) @id SHOULD have at least one distribution with an HTTP(S) URL." | ||
| ], | ||
| profile_identifier="five-safes-crate", | ||
| rocrate_entity_mod_sparql=sparql, | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.