Skip to content

Commit

Permalink
imrpove ro-crate with eli's review
Browse files Browse the repository at this point in the history
  • Loading branch information
mjosse committed Dec 23, 2024
1 parent e66652e commit f1b404d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/galaxy/model/store/ro_crate_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ def _add_steps_recursive(self, steps, crate: ROCrate, step_entities, position):
"position": position[0],
"name": step.tool_id,
"description": step_description,
"workExample": f"#{step.tool_id}"
},
)
)
Expand Down Expand Up @@ -357,13 +358,12 @@ def _add_tools_recursive(self, steps, crate: ROCrate, tool_entities):
tool_entity = crate.add(
ContextEntity(
crate,
tool_id,
f"#{tool_id}", # Prepend # to tool_id
properties={
"@type": "SoftwareApplication",
"name": tool_name,
"version": tool_version,
"description": tool_description,
"url": "https://toolshed.g2.bx.psu.edu", # URL if relevant
},
)
)
Expand All @@ -373,7 +373,7 @@ def _add_tools_recursive(self, steps, crate: ROCrate, tool_entities):

# Append the tool entity to the workflow (instrument) and store it in the list
tool_entities.append(tool_entity)
crate.mainEntity.append_to("instrument", tool_entity)
crate.mainEntity.append_to("hasPart", tool_entity)

# Handle subworkflows recursively
elif step.type == "subworkflow":
Expand Down
3 changes: 1 addition & 2 deletions test/unit/data/model/test_model_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,15 +518,14 @@ def validate_tools(ro_crate: ROCrate):
"""
Validate that tools (SoftwareApplication) are correctly added.
"""
tools = ro_crate.mainEntity.get("instrument")
tools = ro_crate.mainEntity.get("hasPart")
assert tools, "No tools found in the RO-Crate"

tool_ids = set()
for tool in tools:
assert tool["@type"] == "SoftwareApplication"
assert "name" in tool
assert "version" in tool
assert "url" in tool
assert "description" in tool or tool["description"] is None
assert tool.id not in tool_ids, "Duplicate tool found"
tool_ids.add(tool.id)
Expand Down

0 comments on commit f1b404d

Please sign in to comment.