commit/galaxy-central: greg: Include invalid tools in repository metadata, and enable the admin to reset all repository metadata.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/e380ade65ea1/ changeset: e380ade65ea1 user: greg date: 2012-04-03 19:52:50 summary: Include invalid tools in repository metadata, and enable the admin to reset all repository metadata. affected #: 5 files diff -r a0f64b544cc6412516a62459808e0026d2897dc0 -r e380ade65ea1684025099e4b3543a77d07f3e3fe lib/galaxy/webapps/community/controllers/admin.py --- a/lib/galaxy/webapps/community/controllers/admin.py +++ b/lib/galaxy/webapps/community/controllers/admin.py @@ -457,6 +457,24 @@ status=status ) ) @web.expose @web.require_admin + def reset_all_repository_metadata( self, trans, **kwd ): + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'done' ) + count = 0 + for repository in trans.sa_session.query( trans.model.Repository ) \ + .filter( trans.model.Repository.table.c.deleted == False ): + reset_all_repository_metadata( trans, trans.security.encode_id( repository.id ) ) + log.debug( "Reset metadata on repository %s" % repository.name ) + count += 1 + message = "Reset metadata on %d repositories" % count + trans.response.send_redirect( web.url_for( controller='admin', + action='browse_repository_metadata', + webapp='community', + message=util.sanitize_text( message ), + status=status ) ) + @web.expose + @web.require_admin def browse_repositories( self, trans, **kwd ): # We add params to the keyword dict in this method in order to rename the param # with an "f-" prefix, simulating filtering by clicking a search link. We have diff -r a0f64b544cc6412516a62459808e0026d2897dc0 -r e380ade65ea1684025099e4b3543a77d07f3e3fe lib/galaxy/webapps/community/controllers/common.py --- a/lib/galaxy/webapps/community/controllers/common.py +++ b/lib/galaxy/webapps/community/controllers/common.py @@ -201,7 +201,7 @@ can_set_metadata = False correction_msg = "This file requires an entry in the tool_data_table_conf.xml file. " correction_msg += "Upload a file named tool_data_table_conf.xml.sample to the repository " - correction_msg += "that includes the required entry to resolve this issue.<br/>" + correction_msg += "that includes the required entry to correct this error.<br/>" invalid_files.append( ( name, correction_msg ) ) if options.index_file or options.missing_index_file: # Make sure the repository contains the required xxx.loc.sample file. @@ -290,6 +290,7 @@ # repository tip, we handle things like .loc.sample files here. metadata_dict = {} invalid_files = [] + invalid_tool_configs = [] sample_files = [] datatypes_config = None # Find datatypes_conf.xml if it exists. @@ -324,6 +325,7 @@ except Exception, e: valid = False invalid_files.append( ( name, str( e ) ) ) + invalid_tool_configs.append( name ) if valid and tool is not None: can_set_metadata, invalid_files = check_tool_input_params( trans, name, tool, sample_files, invalid_files ) if can_set_metadata: @@ -331,6 +333,8 @@ tool_config = os.path.join( root, name ) repository_clone_url = generate_clone_url( trans, id ) metadata_dict = generate_tool_metadata( tool_config, tool, repository_clone_url, metadata_dict ) + else: + invalid_tool_configs.append( name ) # Find all exported workflows elif name.endswith( '.ga' ): try: @@ -344,11 +348,14 @@ metadata_dict = generate_workflow_metadata( relative_path, exported_workflow_dict, metadata_dict ) except Exception, e: invalid_files.append( ( name, str( e ) ) ) + if invalid_tool_configs: + metadata_dict[ 'invalid_tools' ] = invalid_tool_configs return metadata_dict, invalid_files def generate_metadata_for_changeset_revision( trans, id, ctx, changeset_revision, repo_dir ): # Browse repository files within a change set to generate metadata. metadata_dict = {} invalid_files = [] + invalid_tool_configs = [] sample_files = [] tmp_datatypes_config = None # Find datatypes_conf.xml if it exists. @@ -392,6 +399,7 @@ valid = True except Exception, e: invalid_files.append( ( filename, str( e ) ) ) + invalid_tool_configs.append( filename ) valid = False if valid and tool is not None: # Update the list of metadata dictionaries for tools in metadata_dict. Note that filename @@ -403,6 +411,8 @@ # tip, we do not have to handle any .loc.sample files since they would have been handled previously. repository_clone_url = generate_clone_url( trans, id ) metadata_dict = generate_tool_metadata( filename, tool, repository_clone_url, metadata_dict ) + else: + invalid_tool_configs.append( filename ) try: os.unlink( tmp_filename ) except: @@ -417,6 +427,8 @@ metadata_dict = generate_workflow_metadata( '', exported_workflow_dict, metadata_dict ) except Exception, e: invalid_files.append( ( name, str( e ) ) ) + if invalid_tool_configs: + metadata_dict[ 'invalid_tools' ] = invalid_tool_configs return metadata_dict, invalid_files def set_repository_metadata( trans, id, changeset_revision, content_alert_str='', **kwd ): """Set repository metadata""" diff -r a0f64b544cc6412516a62459808e0026d2897dc0 -r e380ade65ea1684025099e4b3543a77d07f3e3fe lib/galaxy/webapps/community/controllers/repository.py --- a/lib/galaxy/webapps/community/controllers/repository.py +++ b/lib/galaxy/webapps/community/controllers/repository.py @@ -770,15 +770,14 @@ """ If the received changeset_revision includes a file named readme (case ignored), return it's contents. """ - name = kwd[ 'name' ] - owner = kwd[ 'owner' ] + repository_name = kwd[ 'name' ] + repository_owner = kwd[ 'owner' ] changeset_revision = kwd[ 'changeset_revision' ] - repository = get_repository_by_name_and_owner( trans, name, owner ) + repository = get_repository_by_name_and_owner( trans, repository_name, repository_owner ) repo_dir = repository.repo_path - repo = hg.repository( get_configured_ui(), repo_dir ) for root, dirs, files in os.walk( repo_dir ): for name in files: - if name.lower() in [ 'readme', 'readme.txt', 'read_me', 'read_me.txt' ]: + if name.lower() in [ 'readme', 'readme.txt', 'read_me', 'read_me.txt', '%s.txt' % repository_name ]: f = open( os.path.join( root, name ), 'r' ) text = f.read() f.close() @@ -1814,6 +1813,81 @@ changeset_revision=changeset_revision, message=message, status='error' ) ) + @web.expose + def load_invalid_tool( self, trans, repository_id, tool_config, changeset_revision, **kwd ): + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'error' ) + webapp = params.get( 'webapp', 'community' ) + repository = get_repository( trans, repository_id ) + repo_dir = repository.repo_path + repo = hg.repository( get_configured_ui(), repo_dir ) + ctx = get_changectx_for_changeset( repo, changeset_revision ) + invalid_message = '' + if changeset_revision == repository.tip: + for root, dirs, files in os.walk( repo_dir ): + found = False + for name in files: + if name == tool_config: + tool_config_path = os.path.join( root, name ) + found = True + break + if found: + break + else: + for filename in ctx: + if filename == tool_config: + fctx = ctx[ filename ] + # Write the contents of datatypes_config.xml to a temporary file. + fh = tempfile.NamedTemporaryFile( 'w' ) + tool_config_path = fh.name + fh.close() + fh = open( tool_config_path, 'w' ) + fh.write( fctx.data() ) + fh.close() + break + metadata_dict, invalid_files = generate_metadata_for_repository_tip( trans, repository_id, ctx, changeset_revision, repo_dir ) + for invalid_file_tup in invalid_files: + invalid_tool_config, invalid_msg = invalid_file_tup + if tool_config == invalid_tool_config: + invalid_message = invalid_msg + break + tool, message = load_tool_from_changeset_revision( trans, repository_id, changeset_revision, tool_config_path ) + tool_state = self.__new_state( trans ) + is_malicious = change_set_is_malicious( trans, repository_id, repository.tip ) + if changeset_revision != repository.tip: + try: + os.unlink( tool_config_path ) + except: + pass + try: + if invalid_message: + message = invalid_message + return trans.fill_template( "/webapps/community/repository/tool_form.mako", + repository=repository, + changeset_revision=changeset_revision, + tool=tool, + tool_state=tool_state, + is_malicious=is_malicious, + webapp=webapp, + message=message, + status='error' ) + except Exception, e: + message = "This tool is invalid because: %s." % str( e ) + if webapp == 'galaxy': + return trans.response.send_redirect( web.url_for( controller='repository', + action='preview_tools_in_changeset', + repository_id=repository_id, + changeset_revision=changeset_revision, + message=message, + status='error' ) ) + return trans.response.send_redirect( web.url_for( controller='repository', + action='browse_repositories', + operation='view_or_manage_repository', + id=repository_id, + changeset_revision=changeset_revision, + message=message, + status='error' ) ) def __new_state( self, trans, all_pages=False ): """ Create a new `DefaultToolState` for this tool. It will not be initialized diff -r a0f64b544cc6412516a62459808e0026d2897dc0 -r e380ade65ea1684025099e4b3543a77d07f3e3fe templates/webapps/community/admin/index.mako --- a/templates/webapps/community/admin/index.mako +++ b/templates/webapps/community/admin/index.mako @@ -55,6 +55,9 @@ <a target="galaxy_main" href="${h.url_for( controller='admin', action='browse_repositories', webapp='community' )}">Browse all repositories</a></div><div class="toolTitle"> + <a target="galaxy_main" href="${h.url_for( controller='admin', action='reset_all_repository_metadata', webapp='community' )}">Reset all metadata</a> + </div> + <div class="toolTitle"><a target="galaxy_main" href="${h.url_for( controller='admin', action='browse_repository_metadata', webapp='community' )}">Browse metadata</a></div></div> diff -r a0f64b544cc6412516a62459808e0026d2897dc0 -r e380ade65ea1684025099e4b3543a77d07f3e3fe templates/webapps/community/repository/common.mako --- a/templates/webapps/community/repository/common.mako +++ b/templates/webapps/community/repository/common.mako @@ -95,7 +95,7 @@ <div class="form-row"><table width="100%"><tr bgcolor="#D8D8D8" width="100%"> - <td><b>Tools</b><i> - click the name to preview the tool and use the pop-up menu to inspect all metadata</i></td> + <td><b>Valid tools</b><i> - click the name to preview the tool and use the pop-up menu to inspect all metadata</i></td></tr></table></div> @@ -147,6 +147,31 @@ </div><div style="clear: both"></div> %endif + %if 'invalid_tools' in metadata: + <div class="form-row"> + <table width="100%"> + <tr bgcolor="#D8D8D8" width="100%"> + <td><b>Invalid tools</b><i> - click the tool config file name to see why the tool is invalid</i></td> + </tr> + </table> + </div> + <div style="clear: both"></div> + <div class="form-row"> + <% invalid_tool_configs = metadata[ 'invalid_tools' ] %> + <table class="grid"> + %for invalid_tool_config in invalid_tool_configs: + <tr> + <td> + <a class="view-info" href="${h.url_for( controller='repository', action='load_invalid_tool', repository_id=trans.security.encode_id( repository.id ), tool_config=invalid_tool_config, changeset_revision=changeset_revision, webapp=webapp )}"> + ${invalid_tool_config} + </a> + </td> + </tr> + %endfor + </table> + </div> + <div style="clear: both"></div> + %endif %if 'workflows' in metadata: ## metadata[ 'workflows' ] is a list of tuples where each contained tuple is ## [ <relative path to the .ga file in the repository>, <exported workflow dict> ] 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