Skip to content

Commit

Permalink
fix: Bugfix tes add files (#1133)
Browse files Browse the repository at this point in the history
* add missing checkdir

* improve test with input/output

* remove

* format

* format

* format

* debug

* remove expected results
  • Loading branch information
svedziok committed Aug 17, 2021
1 parent d25f04d commit 8892bf2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
8 changes: 4 additions & 4 deletions snakemake/executors/ga4gh_tes.py
Expand Up @@ -315,7 +315,7 @@ def _get_task_inputs(self, job, jobscript, checkdir):

return inputs

def _append_task_outputs(self, outputs, files):
def _append_task_outputs(self, outputs, files, checkdir):
for file in files:
obj = self._prepare_file(
filename=file,
Expand All @@ -329,15 +329,15 @@ def _append_task_outputs(self, outputs, files):
def _get_task_outputs(self, job, checkdir):
outputs = []
# add output files to outputs
outputs = self._append_task_outputs(outputs, job.output)
outputs = self._append_task_outputs(outputs, job.output, checkdir)

# add log files to outputs
if job.log:
outputs = self._append_task_outputs(outputs, job.log)
outputs = self._append_task_outputs(outputs, job.log, checkdir)

# add benchmark files to outputs
if hasattr(job, "benchmark") and job.benchmark:
outputs = self._append_task_outputs(outputs, job.benchmark)
outputs = self._append_task_outputs(outputs, job.benchmark, checkdir)

return outputs

Expand Down
18 changes: 17 additions & 1 deletion tests/test_tes.py
Expand Up @@ -23,11 +23,19 @@ def _validate_task(task):


def _post_task(request, context):
outdir = dpath("test_tes")
print("\n>>>> _post_task", file=sys.stderr)
task = json.loads(request.body)
print(task, file=sys.stderr)
if _validate_task(task):
context.status_code = 200
# create output file
print("\n create output files in {}".format(outdir), file=sys.stderr)
with open("{}/test_output.txt".format(outdir), "w+") as f:
f.write("output")
# create log file
with open("{}/test_log.txt".format(outdir), "w+") as f:
f.write("log")
return TEST_POST_RESPONSE
else:
context.status_code = 400
Expand All @@ -46,4 +54,12 @@ def test_tes(requests_mock):
"GET", "{}/v1/tasks/id_1".format(TES_URL), json=_get_task
)
workdir = dpath("test_tes")
run(workdir, snakefile="Snakefile", tes=TES_URL, no_tmpdir=True, cleanup=False)
print("\n>>>> run workflow in {}".format(workdir), file=sys.stderr)
run(
workdir,
snakefile="Snakefile",
tes=TES_URL,
no_tmpdir=True,
cleanup=False,
forceall=True,
)
6 changes: 6 additions & 0 deletions tests/test_tes/Snakefile
@@ -1,5 +1,11 @@

rule all:
input:
"test_input.txt"
output:
"test_output.txt"
log:
"test_log.txt"
shell:
"""
echo "task submitted to tes"
Expand Down
1 change: 1 addition & 0 deletions tests/test_tes/test_input.txt
@@ -0,0 +1 @@
test

0 comments on commit 8892bf2

Please sign in to comment.