commit/galaxy-central: greg: Add support for exproted Galaxy workflows when generating metadata for a tool shed repository.
1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/31dda910849a/ changeset: 31dda910849a user: greg date: 2011-07-13 22:51:51 summary: Add support for exproted Galaxy workflows when generating metadata for a tool shed repository. affected #: 4 files (6.6 KB) --- a/lib/galaxy/webapps/community/controllers/common.py Wed Jul 13 09:39:02 2011 -0400 +++ b/lib/galaxy/webapps/community/controllers/common.py Wed Jul 13 16:51:51 2011 -0400 @@ -83,7 +83,7 @@ repo_dir = repository.repo_path repo = hg.repository( ui.ui(), repo_dir ) change_set = get_change_set( trans, repo, ctx_str ) - invalid_tool_configs = [] + invalid_files = [] flush_needed = False if change_set is not None: metadata_dict = {} @@ -110,12 +110,22 @@ type=tr.type, version=tr.version ) tool_requirements.append( requirement_dict ) - tool_dict = dict( id = tool.id, - name = tool.name, - version = tool.version, - description = tool.description, - tool_config = os.path.join( root, name ), - requirements = tool_requirements ) + tool_tests = [] + if tool.tests: + for ttb in tool.tests: + test_dict = dict( name=ttb.name, + required_files=ttb.required_files, + inputs=ttb.inputs, + outputs=ttb.outputs ) + tool_tests.append( test_dict ) + tool_dict = dict( id=tool.id, + name=tool.name, + version=tool.version, + description=tool.description, + version_string_cmd = tool.version_string_cmd, + tool_config=os.path.join( root, name ), + requirements=tool_requirements, + tests=tool_tests ) if repository_metadata: metadata = repository_metadata.metadata if metadata and 'tools' in metadata: @@ -127,8 +137,10 @@ found = True tool_metadata_dict[ 'name' ] = tool.name tool_metadata_dict[ 'description' ] = tool.description + tool_metadata_dict[ 'version_string_cmd' ] = tool.version_string_cmd tool_metadata_dict[ 'tool_config' ] = os.path.join( root, name ) tool_metadata_dict[ 'requirements' ] = tool_requirements + tool_metadata_dict[ 'tests' ] = tool_tests flush_needed = True if not found: metadata_tools.append( tool_dict ) @@ -145,7 +157,43 @@ else: metadata_dict[ 'tools' ] = [ tool_dict ] except Exception, e: - invalid_tool_configs.append( ( name, str( e ) ) ) + invalid_files.append( ( name, str( e ) ) ) + # Find all exported workflows + elif name.endswith( '.ga' ): + try: + repository_metadata = get_repository_metadata( trans, id, repository.tip ) + full_path = os.path.abspath( os.path.join( root, name ) ) + # Convert workflow data from json + fp = open( full_path, 'rb' ) + workflow_text = fp.read() + fp.close() + workflow_dict = from_json_string( workflow_text ) + if repository_metadata: + metadata = repository_metadata.metadata + old_metadata_workflows = metadata[ 'workflows' ] + new_metadata_workflows = [] + for workflow_metadata_dict in old_metadata_workflows: + # TODO: what if 2 exported galaxy workflows have the same name, annotation, format-version? + if 'a_galaxy_workflow' in workflow_metadata_dict and util.string_as_bool( workflow_metadata_dict[ 'a_galaxy_workflow' ] ) and \ + 'name' in workflow_metadata_dict and workflow_metadata_dict[ 'name' ] == workflow_dict[ 'name' ] and \ + 'annotation' in workflow_metadata_dict and workflow_metadata_dict[ 'annotation' ] == workflow_dict[ 'annotation' ] and \ + 'format-version' in workflow_metadata_dict and workflow_metadata_dict[ 'format-version' ] == workflow_dict[ 'format-version' ]: + new_metadata_workflows.append( workflow_dict ) + else: + new_metadata_workflows.append( workflow_metadata_dict ) + if metadata is None: + repository_metadata.metadata = {} + repository_metadata.metadata[ 'workflows' ] = new_metadata_workflows + trans.sa_session.add( repository_metadata ) + if not flush_needed: + flush_needed = True + else: + if 'workflows' in metadata_dict: + metadata_dict[ 'workflows' ].append( workflow_dict ) + else: + metadata_dict[ 'workflows' ] = [ workflow_dict ] + except Exception, e: + invalid_files.append( ( name, str( e ) ) ) if metadata_dict: # The metadata_dict dictionary will contain items only # if the repository did not already have metadata set. @@ -156,9 +204,9 @@ else: message = "Repository does not include changeset revision '%s'." % str( ctx_str ) status = 'error' - if invalid_tool_configs: + if invalid_files: message = "Metadata cannot be defined for change set revision '%s'. Correct the following problems and reset metadata.<br/>" % str( ctx_str ) - for itc_tup in invalid_tool_configs: + for itc_tup in invalid_files: message += "<b>%s</b> - %s<br/>" % ( itc_tup[0], itc_tup[1] ) status = 'error' elif flush_needed: --- a/templates/webapps/community/repository/manage_repository.mako Wed Jul 13 09:39:02 2011 -0400 +++ b/templates/webapps/community/repository/manage_repository.mako Wed Jul 13 16:51:51 2011 -0400 @@ -187,7 +187,13 @@ %if metadata: %if 'tools' in metadata: <div class="form-row"> - <label>Tools:</label> + <table width="100%"> + <tr bgcolor="#D8D8D8" width="100%"> + <td><label>Tools:</label></td> + </tr> + </table> + </div> + <div class="form-row"><% tool_dicts = metadata[ 'tools' ] %><table class="grid"><tr> @@ -226,6 +232,34 @@ </div><div style="clear: both"></div> %endif + %if 'workflows' in metadata: + <div class="form-row"> + <table width="100%"> + <tr bgcolor="#D8D8D8" width="100%"> + <td><label>Workflows:</label></td> + </tr> + </table> + </div> + <div style="clear: both"></div> + <div class="form-row"> + <% workflow_dicts = metadata[ 'workflows' ] %> + <table class="grid"> + <tr> + <td><b>name</b></td> + <td><b>format-version</b></td> + <td><b>annotation</b></td> + </tr> + %for workflow_dict in workflow_dicts: + <tr> + <td>${workflow_dict[ 'name' ]}</td> + <td>${workflow_dict[ 'format-version' ]}</td> + <td>${workflow_dict[ 'annotation' ]}</td> + </tr> + %endfor + </table> + </div> + <div style="clear: both"></div> + %endif %endif <form name="set_metadata" action="${h.url_for( controller='repository', action='set_metadata', id=trans.security.encode_id( repository.id ), ctx_str=repository.tip )}" method="post"><div class="form-row"> --- a/templates/webapps/community/repository/view_changelog.mako Wed Jul 13 09:39:02 2011 -0400 +++ b/templates/webapps/community/repository/view_changelog.mako Wed Jul 13 16:51:51 2011 -0400 @@ -94,7 +94,7 @@ %><% display_date = changeset[ 'display_date' ] %> %if test_date != display_date: - <tr colspan="2"><td bgcolor="#D8D8D8 ">${display_date}</td></tr> + <tr colspan="2"><td bgcolor="#D8D8D8">${display_date}</td></tr> %endif <tr><td> --- a/templates/webapps/community/repository/view_repository.mako Wed Jul 13 09:39:02 2011 -0400 +++ b/templates/webapps/community/repository/view_repository.mako Wed Jul 13 16:51:51 2011 -0400 @@ -166,7 +166,13 @@ <div class="toolFormBody"> %if 'tools' in metadata: <div class="form-row"> - <label>Tools:</label> + <table width="100%"> + <tr bgcolor="#D8D8D8" width="100%"> + <td><label>Tools:</label></td> + </tr> + </table> + </div> + <div class="form-row"><% tool_dicts = metadata[ 'tools' ] %><table class="grid"><tr> @@ -205,6 +211,34 @@ </div><div style="clear: both"></div> %endif + %if 'workflows' in metadata: + <div class="form-row"> + <table width="100%"> + <tr bgcolor="#D8D8D8" width="100%"> + <td><label>Workflows:</label></td> + </tr> + </table> + </div> + <div style="clear: both"></div> + <div class="form-row"> + <% workflow_dicts = metadata[ 'workflows' ] %> + <table class="grid"> + <tr> + <td><b>name</b></td> + <td><b>format-version</b></td> + <td><b>annotation</b></td> + </tr> + %for workflow_dict in workflow_dicts: + <tr> + <td>${workflow_dict[ 'name' ]}</td> + <td>${workflow_dict[ 'format-version' ]}</td> + <td>${workflow_dict[ 'annotation' ]}</td> + </tr> + %endfor + </table> + </div> + <div style="clear: both"></div> + %endif </div></div> %endif 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