Skip to content

Commit

Permalink
Fix for no memory + memory expression (#101)
Browse files Browse the repository at this point in the history
* Fix for no memory + memory expression

* Add miniwdl to base reqs to fix tests

* Fix fromwdl test
  • Loading branch information
illusional authored Sep 1, 2021
1 parent f1bea16 commit ea26d97
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
8 changes: 5 additions & 3 deletions janis_core/ingestion/fromwdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,15 @@ def container_from_runtime(cls, runtime, inputs: List[WDL.Decl]):

def parse_memory_requirement(self, value):
s = self.translate_expr(value)
if isinstance(s, str):
if s is None:
return 1.074
elif isinstance(s, str):
if s.lower().endswith("g"):
return float(s[:-1].strip())
if s.lower().endswith("gb"):
return float(s[:-2].strip())
elif s.lower().endswith("gib"):
return float(s[:-3].strip()) * 0.931323
return float(s[:-3].strip()) * 1.074
elif s.lower().endswith("mb"):
return float(s[:-2].strip()) / 1000
elif s.lower().endswith("mib"):
Expand Down Expand Up @@ -235,7 +237,7 @@ def from_loaded_task(self, obj: WDL.Task):
inputs = obj.inputs

cpus = self.translate_expr(rt.get("cpu"))
if cpus is not None and not isinstance(cpus, (int, float)):
if not isinstance(cpus, j.Selector) and cpus is not None and not isinstance(cpus, (int, float)):
cpus = int(cpus)

c = j.CommandToolBuilder(
Expand Down
2 changes: 1 addition & 1 deletion janis_core/tests/test_from_wdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ class TestFromWdl(unittest.TestCase):

def test_missing_disk(self):
result = self.parser.parse_disk_requirement(None)
self.assertEqual(0.931323, result)
self.assertEqual(2.14748, result)
3 changes: 2 additions & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ tabulate
path
cwlformat >= 2020.5.19
cwl-utils >= 0.6
graphviz
graphviz
miniwdl

0 comments on commit ea26d97

Please sign in to comment.