Skip to content

Commit

Permalink
Fixup metadata collection on workdir outputs for Pulsar.
Browse files Browse the repository at this point in the history
a2e3140 which gave tool's clean working directories made the function get_workdir_outputs a big sloppy. Pulsar would send it the actual remote working directory for jobs and Galaxy would send it the job directory (expecting it to append 'working').
  • Loading branch information
jmchilton committed Aug 3, 2016
1 parent 3206199 commit 48849b8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions lib/galaxy/jobs/runners/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,18 @@ def build_command_line( self, job_wrapper, include_metadata=False, include_work_
container=container
)

def get_work_dir_outputs( self, job_wrapper, job_working_directory=None ):
def get_work_dir_outputs( self, job_wrapper, job_working_directory=None, tool_working_directory=None ):
"""
Returns list of pairs (source_file, destination) describing path
to work_dir output file and ultimate destination.
"""
if not job_working_directory:
job_working_directory = os.path.abspath( job_wrapper.working_directory )
if tool_working_directory is not None and job_working_directory is not None:
raise Exception("get_work_dir_outputs called with both a job and tool working directory, only one may be specified")

if tool_working_directory is None:
if not job_working_directory:
job_working_directory = os.path.abspath( job_wrapper.working_directory )
tool_working_directory = os.path.join(job_working_directory, "working")

# Set up dict of dataset id --> output path; output path can be real or
# false depending on outputs_to_working_directory
Expand All @@ -234,9 +239,9 @@ def get_work_dir_outputs( self, job_wrapper, job_working_directory=None ):
if hda_tool_output and hda_tool_output.from_work_dir:
# Copy from working dir to HDA.
# TODO: move instead of copy to save time?
source_file = os.path.join( job_working_directory, 'working', hda_tool_output.from_work_dir )
source_file = os.path.join( tool_working_directory, hda_tool_output.from_work_dir )
destination = job_wrapper.get_output_destination( output_paths[ dataset.dataset_id ] )
if in_directory( source_file, job_working_directory ):
if in_directory( source_file, tool_working_directory ):
output_pairs.append( ( source_file, destination ) )
else:
# Security violation.
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/jobs/runners/pulsar.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ def __build_metadata_configuration(self, client, job_wrapper, remote_metadata, r
# each work_dir output substitute the effective path on the Pulsar
# server relative to the remote working directory as the
# false_path to send the metadata command generation module.
work_dir_outputs = self.get_work_dir_outputs(job_wrapper, job_working_directory=working_directory)
work_dir_outputs = self.get_work_dir_outputs(job_wrapper, tool_working_directory=working_directory)
outputs = [Bunch(false_path=os.path.join(outputs_directory, os.path.basename(path)), real_path=path) for path in self.get_output_files(job_wrapper)]
for output in outputs:
for pulsar_workdir_path, real_path in work_dir_outputs:
Expand Down

0 comments on commit 48849b8

Please sign in to comment.