Skip to content

Commit

Permalink
Unpin and upgrade cwl-utils version
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-c committed May 26, 2023
1 parent b1c02bb commit f3c55a9
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 20 deletions.
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
bdbag>=1.4.1
click~=8.1
cwl-utils==0.13
cwl-utils>=0.27
cwlprov==0.1.1
networkx==2.8
prov>=1.5.1
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ python_requires=>=3.8, <4
install_requires=
bdbag>=1.4.1
click~=8.1
cwl-utils==0.13
cwl-utils>=0.27
cwlprov==0.1.1
networkx==2.8
prov>=1.5.1
Expand Down
37 changes: 19 additions & 18 deletions src/runcrate/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import networkx as nx
import prov.model
from bdbag.bdbagit import BDBag
from cwl_utils.parser import load_document_by_yaml
from cwl_utils.parser import ProcessRequirement, load_document_by_yaml
from cwlprov.prov import Entity, Provenance
from cwlprov.ro import ResearchObject
from cwlprov.utils import first
Expand Down Expand Up @@ -95,16 +95,12 @@ def is_structured(cwl_type):
if is_structured(cwl_p.type):
properties["multipleValues"] = "True"
if hasattr(cwl_p, "default"):
try:
default_type = cwl_p.default["class"]
except (TypeError, KeyError):
if not is_structured(cwl_p.type) and cwl_p.default is not None:
properties["defaultValue"] = str(cwl_p.default)
else:
if default_type in ("File", "Directory"):
default = cwl_p.default.get("location", cwl_p.default.get("path"))
if default:
properties["defaultValue"] = default
if hasattr(cwl_p.default, "class_") and cwl_p.default.class_ in ("File", "Directory"):
default = cwl_p.default.location or cwl_p.default.path
if default:
properties["defaultValue"] = default
elif not is_structured(cwl_p.type) and cwl_p.default is not None:
properties["defaultValue"] = str(cwl_p.default)
# TODO: support more cases
if getattr(cwl_p.type, "type", None) == "enum":
properties["valuePattern"] = "|".join(_.rsplit("/", 1)[-1] for _ in cwl_p.type.symbols)
Expand Down Expand Up @@ -163,7 +159,7 @@ def get_workflow(wf_path):
ns = n.pop("$namespaces", {})
if ns:
json_wf.setdefault("$namespaces", {}).update(ns)
defs = load_document_by_yaml(json_wf, wf_path.absolute().as_uri())
defs = load_document_by_yaml(json_wf, wf_path.absolute().as_uri(), load_all=True)
if not isinstance(defs, list):
defs = [defs]
def_map = {}
Expand Down Expand Up @@ -362,13 +358,18 @@ def add_tool(self, crate, workflow, cwl_tool):
properties["@type"] = "SoftwareApplication"
if hasattr(cwl_tool, "intent") and cwl_tool.intent:
properties["featureList"] = cwl_tool.intent
if hasattr(cwl_tool, "requirements") and cwl_tool.requirements:
for req in cwl_tool.requirements:
if req.class_ == "ResourceRequirement":
ramMin = req.ramMin
if ramMin:
properties["memoryRequirements"] = f"{int(ramMin)} MiB"
if hasattr(cwl_tool, "hints") and cwl_tool.hints:
hints_map = {_["class"]: _ for _ in cwl_tool.hints}
rreq = hints_map.get("ResourceRequirement")
if rreq:
ramMin = rreq.get("ramMin")
if ramMin:
properties["memoryRequirements"] = f"{int(ramMin)} MiB"
for req in cwl_tool.hints:
if isinstance(req, ProcessRequirement) and req.class_ == "ResourceRequirement":
ramMin = req.ramMin
if ramMin:
properties["memoryRequirements"] = f"{int(ramMin)} MiB"
tool = crate.add(ContextEntity(crate, tool_id, properties=properties))
tool["input"] = self.add_params(crate, cwl_tool.inputs)
tool["output"] = self.add_params(crate, cwl_tool.outputs)
Expand Down

0 comments on commit f3c55a9

Please sign in to comment.