commit/galaxy-central: 5 new changesets
5 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/315465b38434/ Changeset: 315465b38434 User: nsoranzo Date: 2014-01-15 17:51:36 Summary: PEP-8 and unused variables fixes. Affected #: 1 file diff -r 8deba81aad81fd565a7e33bad10bb8e741a6172b -r 315465b38434aff44e8863c6f2ea7e9ab549beb2 lib/galaxy/webapps/galaxy/api/workflows.py --- a/lib/galaxy/webapps/galaxy/api/workflows.py +++ b/lib/galaxy/webapps/galaxy/api/workflows.py @@ -241,7 +241,7 @@ outputs = util.odict.odict() rval['history'] = trans.security.encode_id(history.id) rval['outputs'] = [] - for i, step in enumerate( workflow.steps ): + for step in workflow.steps: job = None if step.type == 'tool' or step.type is None: tool = self.app.toolbox.get_tool( step.tool_id ) @@ -285,7 +285,7 @@ """ try: stored_workflow = trans.sa_session.query(self.app.model.StoredWorkflow).get(trans.security.decode_id(workflow_id)) - except Exception,e: + except Exception, e: return ("Workflow with ID='%s' can not be found\n Exception: %s") % (workflow_id, str( e )) # check to see if user has permissions to selected workflow if stored_workflow.user != trans.user and not trans.user_is_admin(): @@ -293,7 +293,7 @@ trans.response.status = 400 return("Workflow is not owned by or shared with current user") - ret_dict = self._workflow_to_dict( trans, stored_workflow ); + ret_dict = self._workflow_to_dict( trans, stored_workflow ) if not ret_dict: #This workflow has a tool that's missing from the distribution trans.response.status = 400 @@ -309,7 +309,7 @@ copied from galaxy.web.controllers.workflows.py (delete) """ - workflow_id = id; + workflow_id = id try: stored_workflow = trans.sa_session.query(self.app.model.StoredWorkflow).get(trans.security.decode_id(workflow_id)) @@ -341,23 +341,23 @@ # currently assumes payload['workflow'] is a json representation of a workflow to be inserted into the database """ - data = payload['workflow']; + data = payload['workflow'] workflow, missing_tool_tups = self._workflow_from_dict( trans, data, source="API" ) # galaxy workflow newly created id - workflow_id = workflow.id; + workflow_id = workflow.id # api encoded, id - encoded_id = trans.security.encode_id(workflow_id); + encoded_id = trans.security.encode_id(workflow_id) # return list - rval= []; + rval = [] item = workflow.to_dict(value_mapper={'id':trans.security.encode_id}) item['url'] = url_for('workflow', id=encoded_id) - rval.append(item); + rval.append(item) - return item; + return item def _workflow_from_dict( self, trans, data, source=None ): """ @@ -386,7 +386,7 @@ # will be ( tool_id, tool_name, tool_version ). missing_tool_tups = [] # First pass to build step objects and populate basic values - for key, step_dict in data[ 'steps' ].iteritems(): + for step_dict in data[ 'steps' ].itervalues(): # Create the model class for the step step = model.WorkflowStep() steps.append( step ) @@ -530,7 +530,7 @@ step_dict['inputs'].append( { "name" : name, "description" : "runtime parameter for tool %s" % module.get_name() } ) elif input_type == dict: # Input type is described by a dict, e.g. indexed parameters. - for partname, partval in val.items(): + for partval in val.values(): if type( partval ) == RuntimeValue: step_dict['inputs'].append( { "name" : name, "description" : "runtime parameter for tool %s" % module.get_name() } ) # User outputs https://bitbucket.org/galaxy/galaxy-central/commits/4fb2ce004601/ Changeset: 4fb2ce004601 User: nsoranzo Date: 2014-01-15 18:04:33 Summary: Let /api/workflows show() method display also importable workflows. Affected #: 1 file diff -r 315465b38434aff44e8863c6f2ea7e9ab549beb2 -r 4fb2ce004601f50d63c4884006d453eee580a85a lib/galaxy/webapps/galaxy/api/workflows.py --- a/lib/galaxy/webapps/galaxy/api/workflows.py +++ b/lib/galaxy/webapps/galaxy/api/workflows.py @@ -60,10 +60,10 @@ 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.user != trans.user and not trans.user_is_admin(): + if stored_workflow.importable == 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 not owned by or shared with current user") + return("Workflow is neither importable, nor owned by or shared with current user") except: trans.response.status = 400 return "That workflow does not exist." https://bitbucket.org/galaxy/galaxy-central/commits/33af32773cba/ Changeset: 33af32773cba User: nsoranzo Date: 2014-01-15 18:22:51 Summary: Add show_published param to /api/workflows index() method to display also published workflows. Affected #: 1 file diff -r 4fb2ce004601f50d63c4884006d453eee580a85a -r 33af32773cba309fde44ced5fba78ce8fc64078b lib/galaxy/webapps/galaxy/api/workflows.py --- a/lib/galaxy/webapps/galaxy/api/workflows.py +++ b/lib/galaxy/webapps/galaxy/api/workflows.py @@ -5,7 +5,7 @@ """ import logging -from sqlalchemy import desc +from sqlalchemy import desc, or_ from galaxy import util from galaxy import web from galaxy import model @@ -26,10 +26,17 @@ GET /api/workflows Displays a collection of workflows. + + :param show_published: if True, show also published workflows + :type show_published: boolean """ + show_published = util.string_as_bool( kwd.get( 'show_published', 'False' ) ) rval = [] - for wf in trans.sa_session.query(trans.app.model.StoredWorkflow).filter_by( - user=trans.user, deleted=False).order_by( + filter1 = ( trans.app.model.StoredWorkflow.user == trans.user ) + if show_published: + filter1 = or_( filter1, ( trans.app.model.StoredWorkflow.published == True ) ) + for wf in trans.sa_session.query(trans.app.model.StoredWorkflow).filter( + filter1, trans.app.model.StoredWorkflow.table.c.deleted == False ).order_by( 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) https://bitbucket.org/galaxy/galaxy-central/commits/f4be6a4360b6/ Changeset: f4be6a4360b6 User: nsoranzo Date: 2014-01-15 18:17:24 Summary: Move core code for importing a shared workflow to UsesStoredWorkflowMixin. Affected #: 4 files diff -r 33af32773cba309fde44ced5fba78ce8fc64078b -r f4be6a4360b6c8c12f7eeed363c0dfe29dc8db41 lib/galaxy/web/base/controller.py --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -33,7 +33,7 @@ from galaxy.model.orm import eagerload, eagerload_all, desc from galaxy.security.validate_user_input import validate_publicname from galaxy.util.sanitize_html import sanitize_html -from galaxy.model.item_attrs import Dictifiable +from galaxy.model.item_attrs import Dictifiable, UsesAnnotations from galaxy.datatypes.interval import ChromatinInteractions from galaxy.datatypes.data import Text @@ -1497,7 +1497,7 @@ return return_message -class UsesStoredWorkflowMixin( SharableItemSecurityMixin ): +class UsesStoredWorkflowMixin( SharableItemSecurityMixin, UsesAnnotations ): """ Mixin for controllers that use StoredWorkflow objects. """ def get_stored_workflow( self, trans, id, check_ownership=True, check_accessible=False ): @@ -1539,6 +1539,26 @@ # Connections by input name step.input_connections_by_name = dict( ( conn.input_name, conn ) for conn in step.input_connections ) + def _import_shared_workflow( self, trans, stored): + """ """ + # Copy workflow. + imported_stored = model.StoredWorkflow() + imported_stored.name = "imported: " + stored.name + imported_stored.latest_workflow = stored.latest_workflow + imported_stored.user = trans.user + # Save new workflow. + session = trans.sa_session + session.add( imported_stored ) + session.flush() + + # Copy annotations. + self.copy_item_annotation( session, stored.user, stored, imported_stored.user, imported_stored ) + for order_index, step in enumerate( stored.latest_workflow.steps ): + self.copy_item_annotation( session, stored.user, step, \ + imported_stored.user, imported_stored.latest_workflow.steps[order_index] ) + session.flush() + return imported_stored + class UsesFormDefinitionsMixin: """Mixin for controllers that use Galaxy form objects.""" diff -r 33af32773cba309fde44ced5fba78ce8fc64078b -r f4be6a4360b6c8c12f7eeed363c0dfe29dc8db41 lib/galaxy/webapps/galaxy/api/annotations.py --- a/lib/galaxy/webapps/galaxy/api/annotations.py +++ b/lib/galaxy/webapps/galaxy/api/annotations.py @@ -3,14 +3,13 @@ """ import logging from galaxy import web -from galaxy.model.item_attrs import UsesAnnotations from galaxy.util.sanitize_html import sanitize_html from galaxy.web.base.controller import BaseAPIController, HTTPNotImplemented, UsesHistoryDatasetAssociationMixin, UsesHistoryMixin, UsesStoredWorkflowMixin log = logging.getLogger( __name__ ) -class BaseAnnotationsController( BaseAPIController, UsesAnnotations, UsesHistoryMixin, UsesHistoryDatasetAssociationMixin, UsesStoredWorkflowMixin ): +class BaseAnnotationsController( BaseAPIController, UsesHistoryMixin, UsesHistoryDatasetAssociationMixin, UsesStoredWorkflowMixin ): @web.expose_api def index( self, trans, **kwd ): diff -r 33af32773cba309fde44ced5fba78ce8fc64078b -r f4be6a4360b6c8c12f7eeed363c0dfe29dc8db41 lib/galaxy/webapps/galaxy/controllers/page.py --- a/lib/galaxy/webapps/galaxy/controllers/page.py +++ b/lib/galaxy/webapps/galaxy/controllers/page.py @@ -1,7 +1,7 @@ from sqlalchemy import desc, and_ from galaxy import model, web from galaxy.web import error, url_for -from galaxy.model.item_attrs import UsesAnnotations, UsesItemRatings +from galaxy.model.item_attrs import UsesItemRatings from galaxy.web.base.controller import BaseUIController, SharableMixin, UsesHistoryMixin, UsesStoredWorkflowMixin, UsesVisualizationMixin from galaxy.web.framework.helpers import time_ago, grids from galaxy import util @@ -274,7 +274,7 @@ # Default behavior: _BaseHTMLProcessor.unknown_endtag( self, tag ) -class PageController( BaseUIController, SharableMixin, UsesAnnotations, UsesHistoryMixin, +class PageController( BaseUIController, SharableMixin, UsesHistoryMixin, UsesStoredWorkflowMixin, UsesVisualizationMixin, UsesItemRatings ): _page_list = PageListGrid() diff -r 33af32773cba309fde44ced5fba78ce8fc64078b -r f4be6a4360b6c8c12f7eeed363c0dfe29dc8db41 lib/galaxy/webapps/galaxy/controllers/workflow.py --- a/lib/galaxy/webapps/galaxy/controllers/workflow.py +++ b/lib/galaxy/webapps/galaxy/controllers/workflow.py @@ -19,7 +19,7 @@ from galaxy import web from galaxy.datatypes.data import Data from galaxy.jobs.actions.post import ActionBox -from galaxy.model.item_attrs import UsesAnnotations, UsesItemRatings +from galaxy.model.item_attrs import UsesItemRatings from galaxy.model.mapping import desc from galaxy.tools.parameters import RuntimeValue, visit_input_values from galaxy.tools.parameters.basic import DataToolParameter, DrillDownSelectToolParameter, SelectToolParameter, UnvalidatedValue @@ -132,7 +132,7 @@ self.tag_content += text -class WorkflowController( BaseUIController, SharableMixin, UsesStoredWorkflowMixin, UsesAnnotations, UsesItemRatings ): +class WorkflowController( BaseUIController, SharableMixin, UsesStoredWorkflowMixin, UsesItemRatings ): stored_list_grid = StoredWorkflowListGrid() published_list_grid = StoredWorkflowAllPublishedGrid() @@ -372,34 +372,17 @@ referer_message = "<a href='%s'>go to Galaxy's start page</a>" % url_for( '/' ) # Do import. - session = trans.sa_session stored = self.get_stored_workflow( trans, id, check_ownership=False ) if stored.importable == False: return trans.show_error_message( "The owner of this workflow has disabled imports via this link.<br>You can %s" % referer_message, use_panels=True ) elif stored.deleted: return trans.show_error_message( "You can't import this workflow because it has been deleted.<br>You can %s" % referer_message, use_panels=True ) - else: - # Copy workflow. - imported_stored = model.StoredWorkflow() - imported_stored.name = "imported: " + stored.name - imported_stored.latest_workflow = stored.latest_workflow - imported_stored.user = trans.user - # Save new workflow. - session = trans.sa_session - session.add( imported_stored ) - session.flush() + self._import_shared_workflow( trans, stored ) - # Copy annotations. - self.copy_item_annotation( session, stored.user, stored, imported_stored.user, imported_stored ) - for order_index, step in enumerate( stored.latest_workflow.steps ): - self.copy_item_annotation( session, stored.user, step, \ - imported_stored.user, imported_stored.latest_workflow.steps[order_index] ) - session.flush() - - # Redirect to load galaxy frames. - return trans.show_ok_message( - message="""Workflow "%s" has been imported. <br>You can <a href="%s">start using this workflow</a> or %s.""" - % ( stored.name, web.url_for( controller='workflow' ), referer_message ), use_panels=True ) + # Redirect to load galaxy frames. + return trans.show_ok_message( + message="""Workflow "%s" has been imported. <br>You can <a href="%s">start using this workflow</a> or %s.""" + % ( stored.name, web.url_for( controller='workflow' ), referer_message ), use_panels=True ) @web.expose @web.require_login( "use Galaxy workflows" ) https://bitbucket.org/galaxy/galaxy-central/commits/2f7781fc4ce9/ Changeset: 2f7781fc4ce9 User: nsoranzo Date: 2014-01-15 18:28:21 Summary: Add /api/workflows/import method to import a workflow shared by other users. Affected #: 2 files diff -r f4be6a4360b6c8c12f7eeed363c0dfe29dc8db41 -r 2f7781fc4ce9dbb1768fd345621ec2a62000f2ae lib/galaxy/webapps/galaxy/api/workflows.py --- a/lib/galaxy/webapps/galaxy/api/workflows.py +++ b/lib/galaxy/webapps/galaxy/api/workflows.py @@ -6,20 +6,21 @@ import logging from sqlalchemy import desc, or_ +from galaxy import exceptions from galaxy import util from galaxy import web from galaxy import model from galaxy.tools.parameters import visit_input_values, DataToolParameter, RuntimeValue -from galaxy.web.base.controller import BaseAPIController, url_for +from galaxy.web import _future_expose_api as expose_api +from galaxy.web.base.controller import BaseAPIController, url_for, UsesStoredWorkflowMixin from galaxy.workflow.modules import module_factory, ToolModule from galaxy.jobs.actions.post import ActionBox -from galaxy.model.item_attrs import UsesAnnotations from ..controllers.workflow import attach_ordered_steps log = logging.getLogger(__name__) -class WorkflowsAPIController(BaseAPIController, UsesAnnotations): +class WorkflowsAPIController(BaseAPIController, UsesStoredWorkflowMixin): @web.expose_api def index(self, trans, **kwd): """ @@ -584,3 +585,31 @@ data['steps'][step.order_index] = step_dict return data + @expose_api + def import_shared_worflow(self, trans, payload, **kwd): + """ + POST /api/workflows/import + Import a workflow shared by other users. + + :param workflow_id: the workflow id (required) + :type workflow_id: str + + :raises: exceptions.MessageException, exceptions.ObjectNotFound + """ + # Pull parameters out of payload. + workflow_id = payload.get('workflow_id', None) + if workflow_id == None: + raise exceptions.ObjectAttributeMissingException( "Missing required parameter 'workflow_id'." ) + try: + 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: + 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." ) + imported_workflow = self._import_shared_workflow( trans, stored_workflow ) + item = imported_workflow.to_dict(value_mapper={'id':trans.security.encode_id}) + encoded_id = trans.security.encode_id(imported_workflow.id) + item['url'] = url_for('workflow', id=encoded_id) + return item diff -r f4be6a4360b6c8c12f7eeed363c0dfe29dc8db41 -r 2f7781fc4ce9dbb1768fd345621ec2a62000f2ae lib/galaxy/webapps/galaxy/buildapp.py --- a/lib/galaxy/webapps/galaxy/buildapp.py +++ b/lib/galaxy/webapps/galaxy/buildapp.py @@ -163,10 +163,11 @@ # "POST /api/workflows/import" => ``workflows.import_workflow()``. # Defines a named route "import_workflow". - webapp.mapper.connect("import_workflow", "/api/workflows/upload", controller="workflows", action="import_new_workflow", conditions=dict(method=["POST"])) - webapp.mapper.connect("workflow_dict", '/api/workflows/{workflow_id}/download', controller='workflows', action='workflow_dict', conditions=dict(method=['GET'])) + webapp.mapper.connect( 'import_workflow', '/api/workflows/upload', controller='workflows', action='import_new_workflow', conditions=dict( method=['POST'] ) ) + webapp.mapper.connect( 'workflow_dict', '/api/workflows/{workflow_id}/download', controller='workflows', action='workflow_dict', conditions=dict( method=['GET'] ) ) # Preserve the following download route for now for dependent applications -- deprecate at some point - webapp.mapper.connect("workflow_dict", '/api/workflows/download/{workflow_id}', controller='workflows', action='workflow_dict', conditions=dict(method=['GET'])) + webapp.mapper.connect( 'workflow_dict', '/api/workflows/download/{workflow_id}', controller='workflows', action='workflow_dict', conditions=dict( method=['GET'] ) ) + webapp.mapper.connect( 'import_shared_workflow', '/api/workflows/import', controller='workflows', action='import_shared_worflow', conditions=dict( method=['POST'] ) ) # ======================= # ===== LIBRARY API ===== 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