commit/galaxy-central: 3 new changesets
3 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/2dc7164b613f/ Changeset: 2dc7164b613f User: dannon Date: 2014-07-10 23:03:11 Summary: Include annotations (toplevel workflow and step) in workflow show via API. Affected #: 1 file diff -r 2d31b83e2a412cbd07d32a842fa1e51d1a8dc033 -r 2dc7164b613f9d9a01c2017fa57d3f6f83ebff9e lib/galaxy/webapps/galaxy/api/workflows.py --- a/lib/galaxy/webapps/galaxy/api/workflows.py +++ b/lib/galaxy/webapps/galaxy/api/workflows.py @@ -9,6 +9,7 @@ from galaxy import exceptions from galaxy import util from galaxy import web +from galaxy.model.item_attrs import UsesAnnotations from galaxy.web import _future_expose_api as expose_api from galaxy.web.base.controller import BaseAPIController, url_for, UsesStoredWorkflowMixin from galaxy.web.base.controller import UsesHistoryMixin @@ -20,7 +21,7 @@ log = logging.getLogger(__name__) -class WorkflowsAPIController(BaseAPIController, UsesStoredWorkflowMixin, UsesHistoryMixin): +class WorkflowsAPIController(BaseAPIController, UsesStoredWorkflowMixin, UsesHistoryMixin, UsesAnnotations): @web.expose_api def index(self, trans, **kwd): @@ -94,12 +95,14 @@ # Eventually, allow regular tool parameters to be inserted and modified at runtime. # p = step.get_required_parameters() item['inputs'] = inputs + item['annotation'] = self.get_item_annotation_str( trans.sa_session, stored_workflow.user, stored_workflow ) steps = {} for step in latest_workflow.steps: steps[step.id] = {'id': step.id, 'type': step.type, 'tool_id': step.tool_id, 'tool_version': step.tool_version, + 'annotation': self.get_item_annotation_str( trans.sa_session, stored_workflow.user, step ), 'tool_inputs': step.tool_inputs, 'input_steps': {}} for conn in step.input_connections: https://bitbucket.org/galaxy/galaxy-central/commits/50f84f60b60b/ Changeset: 50f84f60b60b User: dannon Date: 2014-07-10 23:11:01 Summary: pep8/cleanup in api/workflows Affected #: 1 file diff -r 2dc7164b613f9d9a01c2017fa57d3f6f83ebff9e -r 50f84f60b60b8bfe307994431676a56ae2e97582 lib/galaxy/webapps/galaxy/api/workflows.py --- a/lib/galaxy/webapps/galaxy/api/workflows.py +++ b/lib/galaxy/webapps/galaxy/api/workflows.py @@ -6,17 +6,14 @@ import logging from sqlalchemy import desc, or_ -from galaxy import exceptions -from galaxy import util -from galaxy import web +from galaxy import exceptions, util, web from galaxy.model.item_attrs import UsesAnnotations from galaxy.web import _future_expose_api as expose_api from galaxy.web.base.controller import BaseAPIController, url_for, UsesStoredWorkflowMixin from galaxy.web.base.controller import UsesHistoryMixin +from galaxy.workflow.extract import extract_workflow from galaxy.workflow.run import invoke from galaxy.workflow.run import WorkflowRunConfig -from galaxy.workflow.extract import extract_workflow - log = logging.getLogger(__name__) @@ -37,9 +34,9 @@ rval = [] filter1 = ( trans.app.model.StoredWorkflow.user == trans.user ) if show_published: - filter1 = or_( filter1, ( trans.app.model.StoredWorkflow.published == True ) ) + filter1 = or_( filter1, ( trans.app.model.StoredWorkflow.published == True ) ) #noqa -- sqlalchemy comparison for wf in trans.sa_session.query( trans.app.model.StoredWorkflow ).filter( - filter1, trans.app.model.StoredWorkflow.table.c.deleted == False ).order_by( + filter1, trans.app.model.StoredWorkflow.table.c.deleted == False ).order_by( #noqa -- sqlalchemy comparison desc( trans.app.model.StoredWorkflow.table.c.update_time ) ).all(): item = wf.to_dict( value_mapper={ 'id': trans.security.encode_id } ) encoded_id = trans.security.encode_id(wf.id) @@ -48,7 +45,7 @@ rval.append(item) for wf_sa in trans.sa_session.query( trans.app.model.StoredWorkflowUserShareAssociation ).filter_by( user=trans.user ).join( 'stored_workflow' ).filter( - trans.app.model.StoredWorkflow.deleted == False ).order_by( + trans.app.model.StoredWorkflow.deleted == False ).order_by( #noqa -- sqlalchemy comparison desc( trans.app.model.StoredWorkflow.update_time ) ).all(): item = wf_sa.stored_workflow.to_dict( value_mapper={ 'id': trans.security.encode_id } ) encoded_id = trans.security.encode_id(wf_sa.stored_workflow.id) @@ -72,7 +69,7 @@ return "Malformed workflow id ( %s ) specified, unable to decode." % str(workflow_id) try: stored_workflow = trans.sa_session.query(trans.app.model.StoredWorkflow).get(decoded_workflow_id) - if stored_workflow.importable == False and stored_workflow.user != trans.user and not trans.user_is_admin(): + if stored_workflow.importable is False and stored_workflow.user != trans.user and not trans.user_is_admin(): if trans.sa_session.query(trans.app.model.StoredWorkflowUserShareAssociation).filter_by(user=trans.user, stored_workflow=stored_workflow).count() == 0: trans.response.status = 400 return("Workflow is neither importable, nor owned by or shared with current user") @@ -202,8 +199,7 @@ history_param = payload.get('history', '') # Get workflow + accessibility check. - stored_workflow = trans.sa_session.query(self.app.model.StoredWorkflow).get( - trans.security.decode_id(workflow_id)) + stored_workflow = trans.sa_session.query(self.app.model.StoredWorkflow).get(trans.security.decode_id(workflow_id)) if stored_workflow.user != trans.user and not trans.user_is_admin(): if trans.sa_session.query(trans.app.model.StoredWorkflowUserShareAssociation).filter_by(user=trans.user, stored_workflow=stored_workflow).count() == 0: trans.response.status = 400 @@ -226,9 +222,8 @@ # Get target history. if history_param.startswith('hist_id='): - #Passing an existing history to use. - history = trans.sa_session.query(self.app.model.History).get( - trans.security.decode_id(history_param[8:])) + # Passing an existing history to use. + history = trans.sa_session.query(self.app.model.History).get(trans.security.decode_id(history_param[8:])) if history.user != trans.user and not trans.user_is_admin(): trans.response.status = 400 return "Invalid History specified." @@ -314,7 +309,7 @@ ret_dict = self._workflow_to_dict( trans, stored_workflow ) if not ret_dict: - #This workflow has a tool that's missing from the distribution + # This workflow has a tool that's missing from the distribution trans.response.status = 400 return "Workflow cannot be exported due to missing tools." return ret_dict @@ -341,12 +336,11 @@ trans.response.status = 403 return("Workflow is not owned by current user") - #Mark a workflow as deleted + # Mark a workflow as deleted stored_workflow.deleted = True trans.sa_session.flush() # TODO: Unsure of response message to let api know that a workflow was successfully deleted - #return 'OK' return ( "Workflow '%s' successfully deleted" % stored_workflow.name ) @web.expose_api @@ -397,7 +391,7 @@ stored_workflow = self.get_stored_workflow( trans, workflow_id, check_ownership=False ) except: raise exceptions.ObjectNotFound( "Malformed workflow id ( %s ) specified." % workflow_id ) - if stored_workflow.importable == False: + if stored_workflow.importable is False: raise exceptions.MessageException( 'The owner of this workflow has disabled imports via this link.' ) elif stored_workflow.deleted: raise exceptions.MessageException( "You can't import this workflow because it has been deleted." ) @@ -420,13 +414,13 @@ """ try: stored_workflow = trans.sa_session.query(self.app.model.StoredWorkflow).get(trans.security.decode_id(workflow_id)) - except Exception, e: + except Exception: raise exceptions.ObjectNotFound() # check to see if user has permissions to selected workflow if stored_workflow.user != trans.user and not trans.user_is_admin(): if trans.sa_session.query(trans.app.model.StoredWorkflowUserShareAssociation).filter_by(user=trans.user, stored_workflow=stored_workflow).count() == 0: raise exceptions.ItemOwnershipException() - results = trans.sa_session.query(self.app.model.WorkflowInvocation).filter(self.app.model.WorkflowInvocation.workflow_id==stored_workflow.latest_workflow_id) + results = trans.sa_session.query(self.app.model.WorkflowInvocation).filter(self.app.model.WorkflowInvocation.workflow_id == stored_workflow.latest_workflow_id) out = [] for r in results: out.append( self.encode_all_ids( trans, r.to_dict(), True) ) @@ -449,13 +443,13 @@ try: stored_workflow = trans.sa_session.query(self.app.model.StoredWorkflow).get(trans.security.decode_id(workflow_id)) - except Exception, e: + except Exception: raise exceptions.ObjectNotFound() # check to see if user has permissions to selected workflow if stored_workflow.user != trans.user and not trans.user_is_admin(): if trans.sa_session.query(trans.app.model.StoredWorkflowUserShareAssociation).filter_by(user=trans.user, stored_workflow=stored_workflow).count() == 0: raise exceptions.ItemOwnershipException() - results = trans.sa_session.query(self.app.model.WorkflowInvocation).filter(self.app.model.WorkflowInvocation.workflow_id==stored_workflow.latest_workflow_id) + results = trans.sa_session.query(self.app.model.WorkflowInvocation).filter(self.app.model.WorkflowInvocation.workflow_id == stored_workflow.latest_workflow_id) results = results.filter(self.app.model.WorkflowInvocation.id == trans.security.decode_id(usage_id)) out = results.first() if out is not None: https://bitbucket.org/galaxy/galaxy-central/commits/82a80300b9a1/ Changeset: 82a80300b9a1 User: dannon Date: 2014-07-10 23:22:01 Summary: Update simple filters in workflows api to use filter_by where appropriate, instead of the heavier weight filter. Affected #: 1 file diff -r 50f84f60b60b8bfe307994431676a56ae2e97582 -r 82a80300b9a101072ea614de5424ec76ebae9340 lib/galaxy/webapps/galaxy/api/workflows.py --- a/lib/galaxy/webapps/galaxy/api/workflows.py +++ b/lib/galaxy/webapps/galaxy/api/workflows.py @@ -420,7 +420,7 @@ if stored_workflow.user != trans.user and not trans.user_is_admin(): if trans.sa_session.query(trans.app.model.StoredWorkflowUserShareAssociation).filter_by(user=trans.user, stored_workflow=stored_workflow).count() == 0: raise exceptions.ItemOwnershipException() - results = trans.sa_session.query(self.app.model.WorkflowInvocation).filter(self.app.model.WorkflowInvocation.workflow_id == stored_workflow.latest_workflow_id) + results = trans.sa_session.query(self.app.model.WorkflowInvocation).filter_by(workflow_id=stored_workflow.latest_workflow_id) out = [] for r in results: out.append( self.encode_all_ids( trans, r.to_dict(), True) ) @@ -449,8 +449,8 @@ if stored_workflow.user != trans.user and not trans.user_is_admin(): if trans.sa_session.query(trans.app.model.StoredWorkflowUserShareAssociation).filter_by(user=trans.user, stored_workflow=stored_workflow).count() == 0: raise exceptions.ItemOwnershipException() - results = trans.sa_session.query(self.app.model.WorkflowInvocation).filter(self.app.model.WorkflowInvocation.workflow_id == stored_workflow.latest_workflow_id) - results = results.filter(self.app.model.WorkflowInvocation.id == trans.security.decode_id(usage_id)) + results = trans.sa_session.query(self.app.model.WorkflowInvocation).filter_by(workflow_id=stored_workflow.latest_workflow_id) + results = results.filter_by(id=trans.security.decode_id(usage_id)) out = results.first() if out is not None: return self.encode_all_ids( trans, out.to_dict('element'), True) 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)
-
commits-noreply@bitbucket.org