Skip to content

Commit

Permalink
Merge pull request #19 from crs4/data_entity_types
Browse files Browse the repository at this point in the history
Snakemake: add SoftwareSourceCode type to some entities
  • Loading branch information
simleo authored Nov 16, 2023
2 parents 7856d96 + 342a37f commit 789b35f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
9 changes: 6 additions & 3 deletions repo2rocrate/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from pathlib import Path

from rocrate.rocrate import ROCrate
from rocrate.utils import as_list
from .utils import get_ci_wf_endpoint

GH_API_URL = "https://api.github.com"
Expand Down Expand Up @@ -127,11 +128,13 @@ def add_data_entities(self, data_entities=None):
if self.crate.get(str(relpath)):
continue # existing entity is more specific
source = self.root / relpath
properties = {"description": description} if description else None
if type_ == "File":
properties = {"@type": type_}
if description:
properties["description"] = description
if "File" in as_list(type_):
if source.is_file():
self.crate.add_file(source, relpath, properties=properties)
elif type_ == "Dataset":
elif "Dataset" in as_list(type_):
if source.is_dir():
self.crate.add_dataset(source, relpath, properties=properties)
else:
Expand Down
12 changes: 6 additions & 6 deletions repo2rocrate/snakemake.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ def get_lang_version(workflow_path):
class SnakemakeCrateBuilder(CrateBuilder):

DATA_ENTITIES = [
(".tests/integration", "Dataset", "Integration tests for the workflow"),
(".tests/unit", "Dataset", "Unit tests for the workflow"),
("workflow", "Dataset", "Workflow folder"),
(".tests/integration", ["Dataset", "SoftwareSourceCode"], "Integration tests for the workflow"),
(".tests/unit", ["Dataset", "SoftwareSourceCode"], "Unit tests for the workflow"),
("workflow", ["Dataset", "SoftwareSourceCode"], "Workflow folder"),
("config", "Dataset", "Configuration folder"),
("results", "Dataset", "Output files"),
("resources", "Dataset", "Retrieved resources"),
("workflow/rules", "Dataset", "Workflow rule modules"),
("workflow/rules", ["Dataset", "SoftwareSourceCode"], "Workflow rule modules"),
("workflow/envs", "Dataset", "Conda environments"),
("workflow/scripts", "Dataset", "Scripts folder"),
("workflow/notebooks", "Dataset", "Notebooks folder"),
("workflow/scripts", ["Dataset", "SoftwareSourceCode"], "Scripts folder"),
("workflow/notebooks", ["Dataset", "SoftwareSourceCode"], "Notebooks folder"),
("workflow/report", "Dataset", "Report caption files"),
("workflow/schemas", "Dataset", "Validation files"),
]
Expand Down
6 changes: 3 additions & 3 deletions test/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ def test_default(data_dir, tmpdir, monkeypatch, to_zip):
("LICENSE", "File"),
("README.md", "File"),
("config", "Dataset"),
(".tests/integration", "Dataset"),
("workflow/rules", "Dataset"),
(".tests/integration", ["Dataset", "SoftwareSourceCode"]),
("workflow/rules", ["Dataset", "SoftwareSourceCode"]),
("workflow/schemas", "Dataset"),
("workflow/scripts", "Dataset"),
("workflow/scripts", ["Dataset", "SoftwareSourceCode"]),
]
for relpath, type_ in expected_data_entities:
entity = crate.get(relpath)
Expand Down
6 changes: 3 additions & 3 deletions test/test_snakemake.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ def test_make_crate(data_dir, defaults):
("LICENSE", "File", ""),
("README.md", "File", ""),
("config", "Dataset", "Configuration folder"),
(".tests/integration", "Dataset", "Integration tests for the workflow"),
("workflow/rules", "Dataset", "Workflow rule modules"),
(".tests/integration", ["Dataset", "SoftwareSourceCode"], "Integration tests for the workflow"),
("workflow/rules", ["Dataset", "SoftwareSourceCode"], "Workflow rule modules"),
("workflow/schemas", "Dataset", "Validation files"),
("workflow/scripts", "Dataset", "Scripts folder"),
("workflow/scripts", ["Dataset", "SoftwareSourceCode"], "Scripts folder"),
]
for relpath, type_, desc in expected_data_entities:
entity = crate.get(relpath)
Expand Down

0 comments on commit 789b35f

Please sign in to comment.