commit/galaxy-central: jmchilton: Another fix for remotely populated metadata FileParameters.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/e56736a7d9ba/ Changeset: e56736a7d9ba User: jmchilton Date: 2014-06-06 00:08:24 Summary: Another fix for remotely populated metadata FileParameters. Requires update to remote LWR as well. Affected #: 3 files diff -r 5449a8b1c9d531ee2347b2b219ffb7a2e0946590 -r e56736a7d9bafb3fe40379e192634f9ce8eb6d09 lib/galaxy/datatypes/metadata.py --- a/lib/galaxy/datatypes/metadata.py +++ b/lib/galaxy/datatypes/metadata.py @@ -126,13 +126,18 @@ rval[key] = self.spec[key].param.make_copy( value, target_context=self, source_context=to_copy ) return rval - def from_JSON_dict( self, filename ): + def from_JSON_dict( self, filename, path_rewriter=None ): dataset = self.parent log.debug( 'loading metadata from file for: %s %s' % ( dataset.__class__.__name__, dataset.id ) ) JSONified_dict = json.load( open( filename ) ) for name, spec in self.spec.items(): if name in JSONified_dict: - dataset._metadata[ name ] = spec.param.from_external_value( JSONified_dict[ name ], dataset ) + from_ext_kwds = {} + external_value = JSONified_dict[ name ] + param = spec.param + if isinstance( param, FileParameter ): + from_ext_kwds[ 'path_rewriter' ] = path_rewriter + dataset._metadata[ name ] = param.from_external_value( external_value, dataset, **from_ext_kwds ) elif name in dataset._metadata: #if the metadata value is not found in our externally set metadata but it has a value in the 'old' #metadata associated with our dataset, we'll delete it from our dataset's metadata dict @@ -521,7 +526,7 @@ value = value.id return value - def from_external_value( self, value, parent ): + def from_external_value( self, value, parent, path_rewriter=None ): """ Turns a value read from a external dict into its value to be pushed directly into the metadata dict. """ @@ -532,8 +537,13 @@ if mf is None: mf = self.new_file( dataset = parent, **value.kwds ) # Ensure the metadata file gets updated with content - parent.dataset.object_store.update_from_file( mf, file_name=value.file_name, extra_dir='_metadata_files', extra_dir_at_root=True, alt_name=os.path.basename(mf.file_name) ) - os.unlink( value.file_name ) + file_name = value.file_name + if path_rewriter: + # Job may have run with a different (non-local) tmp/working + # directory. Correct. + file_name = path_rewriter( file_name ) + parent.dataset.object_store.update_from_file( mf, file_name=file_name, extra_dir='_metadata_files', extra_dir_at_root=True, alt_name=os.path.basename(mf.file_name) ) + os.unlink( file_name ) value = mf.id return value diff -r 5449a8b1c9d531ee2347b2b219ffb7a2e0946590 -r e56736a7d9bafb3fe40379e192634f9ce8eb6d09 lib/galaxy/jobs/__init__.py --- a/lib/galaxy/jobs/__init__.py +++ b/lib/galaxy/jobs/__init__.py @@ -952,7 +952,7 @@ self.sa_session.add(job) self.sa_session.flush() - def finish( self, stdout, stderr, tool_exit_code=None ): + def finish( self, stdout, stderr, tool_exit_code=None, remote_working_directory=None ): """ Called to indicate that the associated command has been run. Updates the output datasets based on stderr and stdout from the command, and @@ -1070,7 +1070,14 @@ #since if it is edited, the metadata changed on the running output will no longer match #the metadata that was stored to disk for use via the external process, #and the changes made by the user will be lost, without warning or notice - dataset.metadata.from_JSON_dict( self.external_output_metadata.get_output_filenames_by_dataset( dataset, self.sa_session ).filename_out ) + output_filename = self.external_output_metadata.get_output_filenames_by_dataset( dataset, self.sa_session ).filename_out + + def path_rewriter( path ): + if remote_working_directory and path and path.startswith( remote_working_directory ): + return path.replace( remote_working_directory, self.working_directory, 1 ) + return path + + dataset.metadata.from_JSON_dict( output_filename, path_rewriter=path_rewriter ) try: assert context.get( 'line_count', None ) is not None if ( not dataset.datatype.composite_type and dataset.dataset.is_multi_byte() ) or self.tool.is_multi_byte: diff -r 5449a8b1c9d531ee2347b2b219ffb7a2e0946590 -r e56736a7d9bafb3fe40379e192634f9ce8eb6d09 lib/galaxy/jobs/runners/lwr.py --- a/lib/galaxy/jobs/runners/lwr.py +++ b/lib/galaxy/jobs/runners/lwr.py @@ -301,7 +301,7 @@ try: client = self.get_client_from_state(job_state) run_results = client.full_status() - + remote_working_directory = run_results.get("working_directory", None) stdout = run_results.get('stdout', '') stderr = run_results.get('stderr', '') exit_code = run_results.get('returncode', None) @@ -330,7 +330,12 @@ self._handle_metadata_externally( job_wrapper, resolve_requirements=True ) # Finish the job try: - job_wrapper.finish( stdout, stderr, exit_code ) + job_wrapper.finish( + stdout, + stderr, + exit_code, + remote_working_directory=remote_working_directory + ) except Exception: log.exception("Job wrapper finish method failed") job_wrapper.fail("Unable to finish job", exception=True) Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org