commit/galaxy-central: greg: Change tool shed repository version to be revision, and some fixes for generating and saving repository metadata.
1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/e43c31f9e64c/ changeset: e43c31f9e64c user: greg date: 2011-07-14 20:25:29 summary: Change tool shed repository version to be revision, and some fixes for generating and saving repository metadata. affected #: 6 files (984 bytes) --- a/lib/galaxy/webapps/community/controllers/common.py Thu Jul 14 12:12:55 2011 +0200 +++ b/lib/galaxy/webapps/community/controllers/common.py Thu Jul 14 14:25:29 2011 -0400 @@ -75,14 +75,14 @@ .filter( and_( trans.model.RepositoryMetadata.table.c.repository_id == trans.security.decode_id( id ), trans.model.RepositoryMetadata.table.c.changeset_revision == changeset_revision ) ) \ .first() -def set_repository_metadata( trans, id, ctx_str, **kwd ): +def set_repository_metadata( trans, id, change_set_revision, **kwd ): """Set repository metadata""" message = '' status = 'done' repository = get_repository( trans, id ) repo_dir = repository.repo_path repo = hg.repository( ui.ui(), repo_dir ) - change_set = get_change_set( trans, repo, ctx_str ) + change_set = get_change_set( trans, repo, change_set_revision ) invalid_files = [] flush_needed = False if change_set is not None: @@ -103,7 +103,6 @@ full_path = os.path.abspath( os.path.join( root, name ) ) tool = load_tool( trans, full_path ) if tool is not None: - repository_metadata = get_repository_metadata( trans, id, repository.tip ) tool_requirements = [] for tr in tool.requirements: requirement_dict = dict( name=tr.name, @@ -126,6 +125,7 @@ tool_config=os.path.join( root, name ), requirements=tool_requirements, tests=tool_tests ) + repository_metadata = get_repository_metadata( trans, id, change_set_revision ) if repository_metadata: metadata = repository_metadata.metadata if metadata and 'tools' in metadata: @@ -161,32 +161,39 @@ # 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 ) + exported_workflow_dict = from_json_string( workflow_text ) + # We'll store everything except the workflow steps in the database. + workflow_dict = { 'a_galaxy_workflow' : exported_workflow_dict[ 'a_galaxy_workflow' ], + 'name' :exported_workflow_dict[ 'name' ], + 'annotation' : exported_workflow_dict[ 'annotation' ], + 'format-version' : exported_workflow_dict[ 'format-version' ] } + repository_metadata = get_repository_metadata( trans, id, change_set_revision ) 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 + if metadata and 'workflows' in metadata: + metadata_workflows = metadata[ 'workflows' ] + found = False + for workflow_metadata_dict in metadata_workflows: + 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' ] == exported_workflow_dict[ 'name' ] and \ + 'annotation' in workflow_metadata_dict and workflow_metadata_dict[ 'annotation' ] == exported_workflow_dict[ 'annotation' ] and \ + 'format-version' in workflow_metadata_dict and workflow_metadata_dict[ 'format-version' ] == exported_workflow_dict[ 'format-version' ]: + found = True + break + if not found: + metadata_workflows.append( workflow_dict ) + else: + if metadata is None: + repository_metadata.metadata = {} + repository_metadata.metadata[ 'workflows' ] = workflow_dict + 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 ) @@ -202,10 +209,10 @@ if not flush_needed: flush_needed = True else: - message = "Repository does not include changeset revision '%s'." % str( ctx_str ) + message = "Repository does not include changeset revision '%s'." % str( change_set_revision ) status = 'error' if invalid_files: - message = "Metadata cannot be defined for change set revision '%s'. Correct the following problems and reset metadata.<br/>" % str( ctx_str ) + message = "Metadata cannot be defined for change set revision '%s'. Correct the following problems and reset metadata.<br/>" % str( change_set_revision ) for itc_tup in invalid_files: message += "<b>%s</b> - %s<br/>" % ( itc_tup[0], itc_tup[1] ) status = 'error' @@ -217,11 +224,11 @@ def get_repository_by_name( trans, name ): """Get a repository from the database via name""" return trans.sa_session.query( app.model.Repository ).filter_by( name=name ).one() -def get_change_set( trans, repo, ctx_str, **kwd ): +def get_change_set( trans, repo, change_set_revision, **kwd ): """Retrieve a specified change set from a repository""" for changeset in repo.changelog: ctx = repo.changectx( changeset ) - if str( ctx ) == ctx_str: + if str( ctx ) == change_set_revision: return ctx return None def get_user( trans, id ): --- a/lib/galaxy/webapps/community/controllers/repository.py Thu Jul 14 12:12:55 2011 +0200 +++ b/lib/galaxy/webapps/community/controllers/repository.py Thu Jul 14 14:25:29 2011 -0400 @@ -74,9 +74,9 @@ class NameColumn( grids.TextColumn ): def get_value( self, trans, grid, repository ): return repository.name - class VersionColumn( grids.TextColumn ): + class RevisionColumn( grids.TextColumn ): def get_value( self, trans, grid, repository ): - return repository.version + return repository.revision class DescriptionColumn( grids.TextColumn ): def get_value( self, trans, grid, repository ): return repository.description @@ -126,8 +126,8 @@ DescriptionColumn( "Synopsis", key="description", attach_popup=False ), - VersionColumn( "Version", - attach_popup=False ), + RevisionColumn( "Revision", + attach_popup=False ), CategoryColumn( "Category", model_class=model.Category, key="Category.name", @@ -878,7 +878,6 @@ folder_contents.append( node ) return folder_contents def __get_files( self, trans, repository, folder_path ): - ok = True def print_ticks( d ): pass cmd = "ls -p '%s'" % folder_path @@ -887,17 +886,22 @@ events={ pexpect.TIMEOUT : print_ticks }, timeout=10 ) if 'No such file or directory' in output: - status = 'error' - message = "No folder named (%s) exists." % folder_path - ok = False - if ok: - return output.split() - return trans.response.send_redirect( web.url_for( controller='repository', - action='browse_repositories', - operation="view_or_manage_repository", - id=trans.security.encode_id( repository.id ), - status=status, - message=message ) ) + if 'root' in output: + # The repository is empty + return [] + else: + # Some strange error occurred, the selected file was displayed, but + # does not exist in the sub-directory from which it was displayed. + # This should not happen... + status = 'error' + message = "No folder named (%s) exists." % folder_path + return trans.response.send_redirect( web.url_for( controller='repository', + action='browse_repositories', + operation="view_or_manage_repository", + id=trans.security.encode_id( repository.id ), + status=status, + message=message ) ) + return output.split() @web.json def get_file_contents( self, trans, file_path ): # Avoid caching --- a/lib/galaxy/webapps/community/model/__init__.py Thu Jul 14 12:12:55 2011 +0200 +++ b/lib/galaxy/webapps/community/model/__init__.py Thu Jul 14 14:25:29 2011 -0400 @@ -114,7 +114,7 @@ return config.get( "paths", option ) raise Exception( "Entry for repository %s missing in %s/hgweb.config file." % ( lhs, os.getcwd() ) ) @property - def version( self ): + def revision( self ): repo = hg.repository( ui.ui(), self.repo_path ) tip_ctx = repo.changectx( repo.changelog.tip() ) return "%s:%s" % ( str( tip_ctx.rev() ), str( repo.changectx( repo.changelog.tip() ) ) ) --- a/templates/webapps/community/repository/manage_repository.mako Thu Jul 14 12:12:55 2011 +0200 +++ b/templates/webapps/community/repository/manage_repository.mako Thu Jul 14 14:25:29 2011 -0400 @@ -122,9 +122,9 @@ <div class="form-row"><label>Version:</label> %if can_view_change_log: - <a href="${h.url_for( controller='repository', action='view_changelog', id=trans.app.security.encode_id( repository.id ) )}">${repository.version}</a> + <a href="${h.url_for( controller='repository', action='view_changelog', id=trans.app.security.encode_id( repository.id ) )}">${repository.revision}</a> %else: - ${repository.version} + ${repository.revision} %endif </div><div class="form-row"> --- a/templates/webapps/community/repository/rate_repository.mako Thu Jul 14 12:12:55 2011 +0200 +++ b/templates/webapps/community/repository/rate_repository.mako Thu Jul 14 14:25:29 2011 -0400 @@ -104,7 +104,7 @@ </div><div class="form-row"><label>Version:</label> - ${repository.version} + ${repository.revision} <div style="clear: both"></div></div><div class="form-row"> --- a/templates/webapps/community/repository/view_repository.mako Thu Jul 14 12:12:55 2011 +0200 +++ b/templates/webapps/community/repository/view_repository.mako Thu Jul 14 14:25:29 2011 -0400 @@ -120,9 +120,9 @@ <div class="form-row"><label>Version:</label> %if can_view_change_log: - <a href="${h.url_for( controller='repository', action='view_changelog', id=trans.app.security.encode_id( repository.id ) )}">${repository.version}</a> + <a href="${h.url_for( controller='repository', action='view_changelog', id=trans.app.security.encode_id( repository.id ) )}">${repository.revision}</a> %else: - ${repository.version} + ${repository.revision} %endif </div><div class="form-row"> 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