Skip to content

Commit

Permalink
Merge pull request #63 from simleo/add_wf_run_context
Browse files Browse the repository at this point in the history
convert: add whole workflow-run context to the crate
  • Loading branch information
simleo authored Oct 17, 2023
2 parents 3080d51 + 632c000 commit d052f77
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.
7 changes: 0 additions & 7 deletions src/runcrate/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,3 @@
PROVENANCE_PROFILE = f"{PROVENANCE_PROFILE_BASE}/{PROFILES_VERSION}"

TERMS_NAMESPACE = "https://w3id.org/ro/terms/workflow-run"
EXTRA_TERMS = {t: f"{TERMS_NAMESPACE}#{t}" for t in [
"ParameterConnection",
"connection",
"sourceParameter",
"targetParameter",
"sha1",
]}
4 changes: 2 additions & 2 deletions src/runcrate/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from rocrate.model.softwareapplication import SoftwareApplication
from rocrate.rocrate import ROCrate

from .constants import EXTRA_TERMS, PROFILES_BASE, PROFILES_VERSION
from .constants import PROFILES_BASE, PROFILES_VERSION, TERMS_NAMESPACE
from .utils import as_list


Expand Down Expand Up @@ -284,7 +284,7 @@ def get_dict(self, entity):

def build(self):
crate = ROCrate(gen_preview=False)
crate.metadata.extra_terms.update(EXTRA_TERMS)
crate.metadata.extra_contexts.append(TERMS_NAMESPACE)
self.add_root_metadata(crate)
self.add_profiles(crate)
self.add_workflow(crate)
Expand Down
12 changes: 2 additions & 10 deletions tests/test_cwlprov_crate_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import pytest
from rocrate.rocrate import ROCrate

from runcrate.constants import TERMS_NAMESPACE
from runcrate.convert import ProvCrateBuilder


Expand Down Expand Up @@ -180,16 +181,7 @@ def test_revsort(data_dir, tmpdir):
with open(output / "ro-crate-metadata.json") as f:
metadata = json.load(f)
context = metadata['@context']
context_extensions = [_ for _ in context if isinstance(_, dict)]
assert len(context_extensions) == 1
extra_terms = context_extensions[0]
assert extra_terms == {
"ParameterConnection": "https://w3id.org/ro/terms/workflow-run#ParameterConnection",
"connection": "https://w3id.org/ro/terms/workflow-run#connection",
"sha1": "https://w3id.org/ro/terms/workflow-run#sha1",
"sourceParameter": "https://w3id.org/ro/terms/workflow-run#sourceParameter",
"targetParameter": "https://w3id.org/ro/terms/workflow-run#targetParameter"
}
assert TERMS_NAMESPACE in context


def test_no_input(data_dir, tmpdir):
Expand Down

0 comments on commit d052f77

Please sign in to comment.