Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use proper tmpdir for jobfiles #1438

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions planemo/engine/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import abc
import json
import os
import shutil
import tempfile
from typing import (
Callable,
Expand Down Expand Up @@ -97,23 +97,20 @@ def _collect_test_results(self, test_cases, test_timeout):
def _run_test_cases(self, test_cases, test_timeout):
runnables = [test_case.runnable for test_case in test_cases]
job_paths = []
tmp_paths = []
output_collectors = []
test_directory = tempfile.mkdtemp()
for test_case in test_cases:
if test_case.job_path is None:
job = test_case.job
with tempfile.NamedTemporaryFile(
dir=test_case.tests_directory,
dir=test_directory,
suffix=".json",
prefix="plnmotmptestjob",
delete=False,
mode="w+",
) as f:
tmp_path = f.name
job_path = tmp_path
tmp_paths.append(tmp_path)
json.dump(job, f)
job_paths.append(job_path)
job_paths.append(f.name)
else:
job_paths.append(test_case.job_path)
output_collectors.append(
Expand All @@ -122,8 +119,7 @@ def _run_test_cases(self, test_cases, test_timeout):
try:
run_responses = self._run(runnables, job_paths, output_collectors)
finally:
for tmp_path in tmp_paths:
os.remove(tmp_path)
shutil.rmtree(test_directory)
return run_responses


Expand Down
Loading