details: http://www.bx.psu.edu/hg/galaxy/rev/7cf7b078f890 changeset: 2520:7cf7b078f890 user: Dan Blankenberg <dan@bx.psu.edu> date: Mon Aug 03 15:45:26 2009 -0400 description: Provide datatypes registry location when setting metadata externally. 4 file(s) affected in this change: lib/galaxy/datatypes/metadata.py lib/galaxy/datatypes/registry.py lib/galaxy/jobs/__init__.py scripts/set_metadata.py diffs (94 lines): diff -r a7ba71cade35 -r 7cf7b078f890 lib/galaxy/datatypes/metadata.py --- a/lib/galaxy/datatypes/metadata.py Mon Aug 03 12:02:54 2009 -0400 +++ b/lib/galaxy/datatypes/metadata.py Mon Aug 03 15:45:26 2009 -0400 @@ -497,7 +497,7 @@ return None def get_dataset_metadata_key( self, dataset ): return "%s_%d" % ( dataset.__class__.__name__, dataset.id ) #set meta can be called on library items and history items, need to make different keys for them, since ids can overlap - def setup_external_metadata( self, datasets, exec_dir = None, tmp_dir = None, dataset_files_path = None, output_fnames = None, kwds = {} ): + def setup_external_metadata( self, datasets, exec_dir = None, tmp_dir = None, dataset_files_path = None, output_fnames = None, config_root = None, datatypes_config = None, kwds = {} ): #fill in metadata_files_dict and return the command with args required to set metadata def __metadata_files_list_to_cmd_line( metadata_files ): def __get_filename_override(): @@ -515,6 +515,10 @@ tmp_dir = MetadataTempFile.tmp_dir if dataset_files_path is None: dataset_files_path = galaxy.model.Dataset.file_path + if config_root is None: + config_root = os.path.abspath( os.getcwd() ) + if datatypes_config is None: + datatypes_config = 'datatypes_conf.xml' metadata_files_list = [] for dataset in datasets: key = self.get_dataset_metadata_key( dataset ) @@ -547,7 +551,7 @@ metadata_files.flush() metadata_files_list.append( metadata_files ) #return command required to build - return "%s %s %s %s" % ( os.path.join( exec_dir, 'set_metadata.sh' ), dataset_files_path, tmp_dir, " ".join( map( __metadata_files_list_to_cmd_line, metadata_files_list ) ) ) + return "%s %s %s %s %s %s" % ( os.path.join( exec_dir, 'set_metadata.sh' ), dataset_files_path, tmp_dir, config_root, datatypes_config, " ".join( map( __metadata_files_list_to_cmd_line, metadata_files_list ) ) ) def external_metadata_set_successfully( self, dataset ): metadata_files = self.get_output_filenames_by_dataset( dataset ) diff -r a7ba71cade35 -r 7cf7b078f890 lib/galaxy/datatypes/registry.py --- a/lib/galaxy/datatypes/registry.py Mon Aug 03 12:02:54 2009 -0400 +++ b/lib/galaxy/datatypes/registry.py Mon Aug 03 15:45:26 2009 -0400 @@ -71,7 +71,7 @@ # add composite files name = composite_file.get( 'name', None ) if name is None: - log.warning( "You must provide a name for your composite_file (%s)." % composite_file ) + self.log.warning( "You must provide a name for your composite_file (%s)." % composite_file ) optional = composite_file.get( 'optional', False ) mimetype = composite_file.get( 'mimetype', None ) self.datatypes_by_extension[extension].add_composite_file( name, optional=optional, mimetype=mimetype ) diff -r a7ba71cade35 -r 7cf7b078f890 lib/galaxy/jobs/__init__.py --- a/lib/galaxy/jobs/__init__.py Mon Aug 03 12:02:54 2009 -0400 +++ b/lib/galaxy/jobs/__init__.py Mon Aug 03 15:45:26 2009 -0400 @@ -616,14 +616,18 @@ for outfile in [ str( o ) for o in output_paths ]: sizes.append( ( outfile, os.stat( outfile ).st_size ) ) return sizes - def setup_external_metadata( self, exec_dir = None, tmp_dir = None, dataset_files_path = None, **kwds ): + def setup_external_metadata( self, exec_dir = None, tmp_dir = None, dataset_files_path = None, config_root = None, datatypes_config = None, **kwds ): if tmp_dir is None: #this dir should should relative to the exec_dir tmp_dir = self.app.config.new_file_path if dataset_files_path is None: dataset_files_path = self.app.model.Dataset.file_path + if config_root is None: + config_root = self.app.config.root + if datatypes_config is None: + datatypes_config = self.app.config.datatypes_config job = model.Job.get( self.job_id ) - return self.external_output_metadata.setup_external_metadata( [ output_dataset_assoc.dataset for output_dataset_assoc in job.output_datasets ], exec_dir = exec_dir, tmp_dir = tmp_dir, dataset_files_path = dataset_files_path, **kwds ) + return self.external_output_metadata.setup_external_metadata( [ output_dataset_assoc.dataset for output_dataset_assoc in job.output_datasets ], exec_dir = exec_dir, tmp_dir = tmp_dir, dataset_files_path = dataset_files_path, config_root = config_root, datatypes_config = datatypes_config, **kwds ) class DefaultJobDispatcher( object ): def __init__( self, app ): diff -r a7ba71cade35 -r 7cf7b078f890 scripts/set_metadata.py --- a/scripts/set_metadata.py Mon Aug 03 12:02:54 2009 -0400 +++ b/scripts/set_metadata.py Mon Aug 03 15:45:26 2009 -0400 @@ -5,6 +5,9 @@ top level directly. """ + +import logging +logging.basicConfig() import os, sys, cPickle assert sys.version_info[:2] >= ( 2, 4 ) @@ -27,6 +30,12 @@ tmp_dir = sys.argv.pop( 1 ) galaxy.model.Dataset.file_path = file_path galaxy.datatypes.metadata.MetadataTempFile.tmp_dir = tmp_dir + + # Set up datatypes registry + config_root = sys.argv.pop( 1 ) + datatypes_config = sys.argv.pop( 1 ) + galaxy.model.set_datatypes_registry( galaxy.datatypes.registry.Registry( config_root, datatypes_config ) ) + for filenames in sys.argv[1:]: filename_in, filename_kwds, filename_out, filename_results_code, dataset_filename_override = filenames.split( ',' ) try: