diff --git a/lib/galaxy/jobs/__init__.py b/lib/galaxy/jobs/__init__.py index 8b9d67523ca..de3ffa0ec00 100644 --- a/lib/galaxy/jobs/__init__.py +++ b/lib/galaxy/jobs/__init__.py @@ -1113,6 +1113,7 @@ class JobWrapper(HasResourceParameters): # The tool execution is given a working directory beneath the # "job" working directory. safe_makedirs(self.tool_working_directory) + safe_makedirs(os.path.join(working_directory, 'outputs')) log.debug('(%s) Working directory for job is: %s', self.job_id, self.working_directory) except ObjectInvalid: diff --git a/lib/galaxy/jobs/command_factory.py b/lib/galaxy/jobs/command_factory.py index 6714eba68c1..1b2a413b0ad 100644 --- a/lib/galaxy/jobs/command_factory.py +++ b/lib/galaxy/jobs/command_factory.py @@ -101,7 +101,13 @@ def build_command( # Remove the working directory incase this is for instance a SLURM re-submission. # xref https://github.com/galaxyproject/galaxy/issues/3289 - commands_builder.prepend_command("rm -rf working outputs; mkdir -p working outputs; cd working") + commands_builder.prepend_command("""# Delete working/ and outputs/ only if job was resubmitted +if [ -f .job_started ]; then + rm -rf working outputs; mkdir -p working outputs +fi +touch .job_started +cd working +""", sep='') container_monitor_command = job_wrapper.container_monitor_command(container) if container_monitor_command: diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index bbe5cd5195b..80ab77170f7 100755 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -2269,9 +2269,8 @@ class OutputParameterJSONTool(Tool): json_params['output_data'].append(data_dict) if json_filename is None: json_filename = file_name - out = open(json_filename, 'w') - out.write(json.dumps(json_params)) - out.close() + with open(json_filename, 'w') as out: + out.write(json.dumps(json_params)) class ExpressionTool(Tool):