Skip to content
Permalink
Browse files
fix: Bugfix tes add files (#1133)
* 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 8892bf25d9d981a4032d5a1b525960ba3bdd1aec
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
@@ -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,
@@ -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

@@ -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
@@ -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,
)
@@ -1,5 +1,11 @@

rule all:
input:
"test_input.txt"
output:
"test_output.txt"
log:
"test_log.txt"
shell:
"""
echo "task submitted to tes"
@@ -0,0 +1 @@
test

0 comments on commit 8892bf2

Please sign in to comment.