commit/galaxy-central: greg: Fixes for viewing tool metadata in a tool shed repository for tools the require data index (.loc) files.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/dd1711a3518a/ changeset: dd1711a3518a user: greg date: 2012-09-20 19:43:42 summary: Fixes for viewing tool metadata in a tool shed repository for tools the require data index (.loc) files. affected #: 3 files diff -r 3184303c13918a8b4734e46e1ac956d0e44ecba2 -r dd1711a3518a27f6426cdf4d9def2efae29149c0 lib/galaxy/util/shed_util.py --- a/lib/galaxy/util/shed_util.py +++ b/lib/galaxy/util/shed_util.py @@ -341,6 +341,17 @@ correction_msg += "Upload a file named <b>%s.sample</b> to the repository to correct this error." % str( index_file_name ) invalid_files_and_errors_tups.append( ( tool_config_name, correction_msg ) ) return invalid_files_and_errors_tups +def concat_messages( msg1, msg2 ): + if msg1: + if msg2: + message = '%s %s' % ( msg1, msg2 ) + else: + message = msg1 + elif msg2: + message = msg2 + else: + message = '' + return message def config_elems_to_xml_file( app, config_elems, config_filename, tool_path ): # Persist the current in-memory list of config_elems to a file named by the value of config_filename. fd, filename = tempfile.mkstemp() @@ -352,6 +363,16 @@ os.close( fd ) shutil.move( filename, os.path.abspath( config_filename ) ) os.chmod( config_filename, 0644 ) +def copy_disk_sample_files_to_dir( trans, repo_files_dir, dest_path ): + sample_files = [] + for root, dirs, files in os.walk( repo_files_dir ): + if root.find( '.hg' ) < 0: + for name in files: + if name.endswith( '.sample' ): + relative_path = os.path.join( root, name ) + copy_sample_file( trans.app, relative_path, dest_path=dest_path ) + sample_files.append( name ) + return sample_files def clean_repository_clone_url( repository_clone_url ): if repository_clone_url.find( '@' ) > 0: # We have an url that includes an authenticated user, something like: @@ -1399,12 +1420,13 @@ if missing_data_table_entry: # The repository must contain a tool_data_table_conf.xml.sample file that includes all required entries for all tools in the repository. sample_tool_data_table_conf = get_config_from_disk( 'tool_data_table_conf.xml.sample', relative_install_dir ) - # Add entries to the ToolDataTableManager's in-memory data_tables dictionary as well as the list of data_table_elems and the list of - # data_table_elem_names. - error, correction_msg = handle_sample_tool_data_table_conf_file( app, sample_tool_data_table_conf, persist=True ) - if error: - # TODO: Do more here than logging an exception. - log.debug( correction_msg ) + if sample_tool_data_table_conf: + # Add entries to the ToolDataTableManager's in-memory data_tables dictionary as well as the list of data_table_elems and the list of + # data_table_elem_names. + error, message = handle_sample_tool_data_table_conf_file( app, sample_tool_data_table_conf, persist=True ) + if error: + # TODO: Do more here than logging an exception. + log.debug( message ) # Reload the tool into the local list of repository_tools_tups. repository_tool = app.toolbox.load_tool( os.path.join( tool_path, tup_path ), guid=guid ) repository_tools_tups[ index ] = ( tup_path, guid, repository_tool ) @@ -1436,9 +1458,21 @@ repository_tool = app.toolbox.load_tool( os.path.join( tool_path, tup_path ), guid=guid ) repository_tools_tups[ index ] = ( tup_path, guid, repository_tool ) return repository_tools_tups, sample_files_copied +def handle_sample_files_and_load_tool_from_disk( trans, repo_files_dir, tool_config_filepath, work_dir ): + # Copy all sample files from disk to a temporary directory since the sample files may be in multiple directories. + message = '' + sample_files = copy_disk_sample_files_to_dir( trans, repo_files_dir, work_dir ) + if sample_files: + if 'tool_data_table_conf.xml.sample' in sample_files: + # Load entries into the tool_data_tables if the tool requires them. + tool_data_table_config = os.path.join( work_dir, 'tool_data_table_conf.xml' ) + error, message = handle_sample_tool_data_table_conf_file( trans.app, tool_data_table_config ) + tool, valid, message2 = load_tool_from_config( trans.app, tool_config_filepath ) + message = concat_messages( message, message2 ) + return tool, valid, message def handle_sample_files_and_load_tool_from_tmp_config( trans, repo, changeset_revision, tool_config_filename, work_dir ): tool = None - message = None + message = '' ctx = get_changectx_for_changeset( repo, changeset_revision ) # We're not currently doing anything with the returned list of deleted_sample_files here. It is intended to help handle sample files that are in # the manifest, but have been deleted from disk. @@ -1448,13 +1482,14 @@ if 'tool_data_table_conf.xml.sample' in sample_files: # Load entries into the tool_data_tables if the tool requires them. tool_data_table_config = os.path.join( work_dir, 'tool_data_table_conf.xml' ) - error, correction_msg = handle_sample_tool_data_table_conf_file( trans.app, tool_data_table_config ) - if error: - # TODO: Do more here than logging an exception. - log.debug( correction_msg ) + if tool_data_table_config: + error, message = handle_sample_tool_data_table_conf_file( trans.app, tool_data_table_config ) + if error: + log.debug( message ) manifest_ctx, ctx_file = get_ctx_file_path_from_manifest( tool_config_filename, repo, changeset_revision ) if manifest_ctx and ctx_file: - tool, message = load_tool_from_tmp_config( trans, repo, manifest_ctx, ctx_file, work_dir ) + tool, message2 = load_tool_from_tmp_config( trans, repo, manifest_ctx, ctx_file, work_dir ) + message = concat_messages( message, message2 ) return tool, message def handle_sample_tool_data_table_conf_file( app, filename, persist=False ): """ diff -r 3184303c13918a8b4734e46e1ac956d0e44ecba2 -r dd1711a3518a27f6426cdf4d9def2efae29149c0 lib/galaxy/webapps/community/controllers/common.py --- a/lib/galaxy/webapps/community/controllers/common.py +++ b/lib/galaxy/webapps/community/controllers/common.py @@ -7,8 +7,9 @@ from galaxy.util.hash_util import * from galaxy.util.shed_util import check_tool_input_params, clone_repository, copy_sample_file, generate_metadata_for_changeset_revision from galaxy.util.shed_util import get_changectx_for_changeset, get_config_from_disk, get_configured_ui, get_file_context_from_ctx, get_named_tmpfile_from_ctx -from galaxy.util.shed_util import handle_sample_files_and_load_tool_from_tmp_config, handle_sample_tool_data_table_conf_file, INITIAL_CHANGELOG_HASH -from galaxy.util.shed_util import load_tool_from_config, reset_tool_data_tables, reversed_upper_bounded_changelog, strip_path +from galaxy.util.shed_util import handle_sample_files_and_load_tool_from_disk, handle_sample_files_and_load_tool_from_tmp_config +from galaxy.util.shed_util import handle_sample_tool_data_table_conf_file, INITIAL_CHANGELOG_HASH, load_tool_from_config, reset_tool_data_tables +from galaxy.util.shed_util import reversed_upper_bounded_changelog, strip_path from galaxy.web.base.controller import * from galaxy.webapps.community import model from galaxy.model.orm import * @@ -258,16 +259,6 @@ else: return 'subset' return 'not equal and not subset' -def copy_disk_sample_files_to_dir( trans, repo_files_dir, dest_path ): - sample_files = [] - for root, dirs, files in os.walk( repo_files_dir ): - if root.find( '.hg' ) < 0: - for name in files: - if name.endswith( '.sample' ): - relative_path = os.path.join( root, name ) - copy_sample_file( trans.app, relative_path, dest_path=dest_path ) - sample_files.append( name ) - return sample_files def copy_file_from_disk( filename, repo_dir, dir ): file_path = None found = False @@ -628,15 +619,8 @@ work_dir = tempfile.mkdtemp() can_use_disk_file = can_use_tool_config_disk_file( trans, repository, repo, tool_config_filepath, changeset_revision ) if can_use_disk_file: - # Copy all sample files from disk to a temporary directory since the sample files may be in multiple directories. - sample_files = copy_disk_sample_files_to_dir( trans, repo_files_dir, work_dir ) - if sample_files: - trans.app.config.tool_data_path = work_dir - if 'tool_data_table_conf.xml.sample' in sample_files: - # Load entries into the tool_data_tables if the tool requires them. - tool_data_table_config = os.path.join( work_dir, 'tool_data_table_conf.xml' ) - error, correction_msg = handle_sample_tool_data_table_conf_file( trans.app, tool_data_table_config ) - tool, valid, message = load_tool_from_config( trans.app, tool_config_filepath ) + trans.app.config.tool_data_path = work_dir + tool, valid, message = handle_sample_files_and_load_tool_from_disk( trans, repo_files_dir, tool_config_filepath, work_dir ) if tool is not None: invalid_files_and_errors_tups = check_tool_input_params( trans.app, repo_files_dir, @@ -645,11 +629,12 @@ sample_files, webapp='community' ) if invalid_files_and_errors_tups: - message = generate_message_for_invalid_tools( invalid_files_and_errors_tups, - repository, - metadata_dict=None, - as_html=True, - displaying_invalid_tool=True ) + message2 = generate_message_for_invalid_tools( invalid_files_and_errors_tups, + repository, + metadata_dict=None, + as_html=True, + displaying_invalid_tool=True ) + message = concat_messages( message, message2 ) status = 'error' else: tool, message = handle_sample_files_and_load_tool_from_tmp_config( trans, repo, changeset_revision, tool_config_filename, work_dir ) diff -r 3184303c13918a8b4734e46e1ac956d0e44ecba2 -r dd1711a3518a27f6426cdf4d9def2efae29149c0 lib/galaxy/webapps/community/controllers/repository.py --- a/lib/galaxy/webapps/community/controllers/repository.py +++ b/lib/galaxy/webapps/community/controllers/repository.py @@ -10,9 +10,9 @@ from galaxy.util.json import from_json_string, to_json_string from galaxy.model.orm import * from galaxy.util.shed_util import create_repo_info_dict, get_changectx_for_changeset, get_configured_ui, get_repository_file_contents -from galaxy.util.shed_util import handle_sample_files_and_load_tool_from_tmp_config, INITIAL_CHANGELOG_HASH, load_tool_from_config, NOT_TOOL_CONFIGS -from galaxy.util.shed_util import open_repository_files_folder, reversed_lower_upper_bounded_changelog, reversed_upper_bounded_changelog, strip_path -from galaxy.util.shed_util import to_html_escaped, update_repository, url_join +from galaxy.util.shed_util import handle_sample_files_and_load_tool_from_disk, handle_sample_files_and_load_tool_from_tmp_config, INITIAL_CHANGELOG_HASH +from galaxy.util.shed_util import load_tool_from_config, NOT_TOOL_CONFIGS, open_repository_files_folder, reversed_lower_upper_bounded_changelog +from galaxy.util.shed_util import reversed_upper_bounded_changelog, strip_path, to_html_escaped, update_repository, url_join from galaxy.tool_shed.encoding_util import * from common import * @@ -2293,20 +2293,21 @@ if 'tools' in metadata: for tool_metadata_dict in metadata[ 'tools' ]: if tool_metadata_dict[ 'id' ] == tool_id: + work_dir = tempfile.mkdtemp() relative_path_to_tool_config = tool_metadata_dict[ 'tool_config' ] guid = tool_metadata_dict[ 'guid' ] full_path_to_tool_config = os.path.abspath( relative_path_to_tool_config ) - full_path_to_dir, tool_tool_config_filename = os.path.split( full_path_to_tool_config ) + full_path_to_dir, tool_config_filename = os.path.split( full_path_to_tool_config ) can_use_disk_file = can_use_tool_config_disk_file( trans, repository, repo, full_path_to_tool_config, changeset_revision ) if can_use_disk_file: - trans.app.config.tool_data_path = full_path_to_dir - # Load entries into the tool_data_tables if the tool requires them. - tool_data_table_config = get_config_from_disk( 'tool_data_table_conf.xml.sample', full_path_to_dir ) - error, correction_msg = handle_sample_tool_data_table_conf_file( trans.app, tool_data_table_config ) - tool, valid, message = load_tool_from_config( trans.app, full_path_to_tool_config ) + trans.app.config.tool_data_path = work_dir + tool, valid, message = handle_sample_files_and_load_tool_from_disk( trans, repo_files_dir, full_path_to_tool_config, work_dir ) + if message: + status = 'error' else: - work_dir = tempfile.mkdtemp() tool, message = handle_sample_files_and_load_tool_from_tmp_config( trans, repo, changeset_revision, tool_config_filename, work_dir ) + if message: + status = 'error' break if guid: tool_lineage = self.get_versions_of_tool( trans, repository, repository_metadata, guid ) 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)
-
Bitbucket