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 e8cf399
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 19 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"
3 changes: 3 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ authors:
- family-names: Soiland-Reyes
given-names: Stian
orcid: https://orcid.org/0000-0001-9842-9718
- family-names: Crusoe
given-names: Michael R.
orcid: https://orcid.org/0000-0002-2961-9670
title: "runcrate"
version: 0.1.2
doi: 10.5281/zenodo.7762627
Expand Down
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
36 changes: 19 additions & 17 deletions src/runcrate/convert.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2022-2023 CRS4.
# Copyright 2023 Michael R. Crusoe
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -95,16 +96,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 +160,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 +359,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 hasattr(req, "class_") 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 e8cf399

Please sign in to comment.