Skip to content

Commit

Permalink
runner CLI: permit reading input JSON straight from URI
Browse files Browse the repository at this point in the history
  • Loading branch information
mlin committed Nov 26, 2019
1 parent a1592bc commit 2ea1b25
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
8 changes: 6 additions & 2 deletions WDL/CLI.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import argcomplete
import logging
import urllib
import asyncio
import docker
from shlex import quote as shellquote
from datetime import datetime
Expand Down Expand Up @@ -656,8 +657,11 @@ def runner_input_json_file(available_inputs, namespace, input_file):
elif input_file == "-":
input_json = json.load(sys.stdin)
else:
with open(input_file) as infile:
input_json = json.load(infile)
input_json = json.loads(
asyncio.get_event_loop()
.run_until_complete(read_source(input_file, [], None))
.source_text
)
ans = values_from_json(input_json, available_inputs, namespace=namespace)

# join relative file paths to the cwd
Expand Down
12 changes: 11 additions & 1 deletion WDL/runtime/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def _run(
resources, user, groups = self.misc_config(logger, cpu, memory)

# connect to dockerd
client = docker.from_env()
client = docker.from_env(timeout=900)
svc = None
try:
# run container as a transient docker swarm service, letting docker handle the resource
Expand Down Expand Up @@ -479,6 +479,7 @@ def chown(self, logger: logging.Logger, client: docker.DockerClient) -> None:
alternatives and their problems.
"""
if not self.as_me and (os.geteuid() or os.getegid()):
t_0 = time.monotonic()
script = f"""
chown -RP {os.geteuid()}:{os.getegid()} {shlex.quote(os.path.join(self.container_dir, 'work'))}
""".strip()
Expand All @@ -503,6 +504,15 @@ def chown(self, logger: logging.Logger, client: docker.DockerClient) -> None:
chowner.remove()
except:
logger.exception("post-task chown failed")
finally:
t_delta = time.monotonic() - t_0
if t_delta >= 60:
logger.warning(
_(
"post-task chown was slow (symptomatic of excessive file count and/or IOPS saturation)",
seconds=int(t_delta),
)
)


def run_local_task(
Expand Down
2 changes: 1 addition & 1 deletion stubs/docker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ def swarm(self) -> Swarm:
def services(self) -> Services:
...

def from_env() -> DockerClient:
def from_env(timeout: Optional[int] = None) -> DockerClient:
...

2 changes: 1 addition & 1 deletion tests/applied/DVGLx.t
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ plan tests 1
set +e

$miniwdl run https://raw.githubusercontent.com/mlin/DeepVariant-GLnexus-WDL/master/test/range1KGP.wdl --verbose \
-i <(wget -O - https://raw.githubusercontent.com/mlin/DeepVariant-GLnexus-WDL/master/test/range1KGP.test26.ALDH2.json)
-i https://raw.githubusercontent.com/mlin/DeepVariant-GLnexus-WDL/master/test/range1KGP.test26.ALDH2.json
is "$?" "0" "pipeline success"
2 changes: 1 addition & 1 deletion tests/applied/encode_atac_seq.t
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ plan tests 1
set +e

$miniwdl run https://raw.githubusercontent.com/ENCODE-DCC/atac-seq-pipeline/v1.5.4/atac.wdl \
-i <(wget -O - https://storage.googleapis.com/encode-pipeline-test-samples/encode-atac-seq-pipeline/ENCSR356KRQ_subsampled_caper.json) \
-i https://storage.googleapis.com/encode-pipeline-test-samples/encode-atac-seq-pipeline/ENCSR356KRQ_subsampled_caper.json \
--runtime-defaults '{"docker":"quay.io/encode-dcc/atac-seq-pipeline:v1.5.4"}' \
--no-quant-check --verbose --runtime-memory-max 4G --runtime-cpu-max 2
is "$?" "0" "pipeline success"

0 comments on commit 2ea1b25

Please sign in to comment.