commit/galaxy-central: 4 new changesets
4 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/0705fc913ef5/ Changeset: 0705fc913ef5 Branch: provenance User: kellrott Date: 2013-05-27 22:03:58 Summary: Starting the provenance API. Provides information about the source of datasets. Affected #: 2 files diff -r 31714646a7b441f34a43748065278a1b08940c3c -r 0705fc913ef53e19f41ca6b0b8351f1335bcc597 lib/galaxy/webapps/galaxy/api/provenance.py --- /dev/null +++ b/lib/galaxy/webapps/galaxy/api/provenance.py @@ -0,0 +1,92 @@ +""" +API operations provenance +""" +import logging +from galaxy import web +from galaxy.web.base.controller import BaseAPIController +from paste.httpexceptions import HTTPNotImplemented, HTTPBadRequest + +log = logging.getLogger( __name__ ) + + +class BaseProvenanceController( BaseAPIController ): + """ + """ + @web.expose_api + def index( self, trans, **kwd ): + value = self._get_provenance( trans, self.provenance_item_class, kwd[self.provenance_item_id] ) + return value + + @web.expose_api + def show( self, trans, elem_name, **kwd ): + value = self._get_provenance( trans, self.provenance_item_class, kwd[self.provenance_item_id] ) + return value + + @web.expose_api + def create( self, trans, tag_name, payload={}, **kwd ): + raise HTTPNotImplemented() + + @web.expose_api + def delete( self, trans, tag_name, **kwd ): + raise HTTPBadRequest("Cannot Delete Provenance") + + def _get_provenance(self, trans, item_class_name, item_id, follow=True): + out = [] + provenance_item = self.get_object( trans, item_id, item_class_name, check_ownership=False, check_accessible=True ) + out.append( + { + "dataset" : { + "id" : trans.security.encode_id(provenance_item.id), + "uuid" : provenance_item.dataset.uuid + }, + "tool_id" : provenance_item.creating_job.tool_id, + "parameters" : self._get_job_record(trans, provenance_item.creating_job) + } + ) + if follow: + depends = self._get_dataset_depends(provenance_item) + recorded = {} + for rec in depends: + if rec.id not in recorded: + recorded[rec.id] = True + out.append( + { + "dataset" : { + "id" : trans.security.encode_id(rec.id), + "uuid" : rec.dataset.uuid + }, + "tool_id" : rec.creating_job.tool_id, + "parameters" : self._get_job_record(trans, rec.creating_job) + } + ) + return out + + def _get_dataset_depends(self, item): + out = [] + for d in item.creating_job.input_datasets: + out.append(d.dataset) + for c in self._get_dataset_depends(d.dataset): + out.append(c) + return out + + def _get_job_record(self, trans, job): + out = {} + for p in job.parameters: + out[p.name] = p.value + for in_d in job.input_datasets: + out[in_d.name] = { "dataset_id" : trans.security.encode_id(in_d.dataset.id), "uuid" : in_d.dataset.dataset.uuid } + return out + + +class HDAProvenanceController( BaseProvenanceController ): + controller_name = "history_content_provenance" + provenance_item_class = "HistoryDatasetAssociation" + provenance_item_id = "history_content_id" + + +class LDDAProvenanceController( BaseProvenanceController ): + controller_name = "ldda_provenance" + provenance_item_class = "LibraryDatasetDatasetAssociation" + provenance_item_id = "library_content_id" + + diff -r 31714646a7b441f34a43748065278a1b08940c3c -r 0705fc913ef53e19f41ca6b0b8351f1335bcc597 lib/galaxy/webapps/galaxy/buildapp.py --- a/lib/galaxy/webapps/galaxy/buildapp.py +++ b/lib/galaxy/webapps/galaxy/buildapp.py @@ -128,6 +128,10 @@ name_prefix="workflow_", path_prefix='/api/workflows/:workflow_id' ) + _add_item_provenance_controller( webapp, + name_prefix="history_content_", + path_prefix='/api/histories/:history_id/contents/:history_content_id' ) + webapp.mapper.resource( 'dataset', 'datasets', path_prefix='/api' ) webapp.mapper.resource_with_deleted( 'library', 'libraries', path_prefix='/api' ) webapp.mapper.resource( 'sample', 'samples', path_prefix='/api' ) @@ -234,6 +238,12 @@ name = "%sannotation" % name_prefix webapp.mapper.resource(name, "annotation", path_prefix=path_prefix, controller=controller) +def _add_item_provenance_controller( webapp, name_prefix, path_prefix, **kwd ): + controller = "%sprovenance" % name_prefix + name = "%sprovenance" % name_prefix + webapp.mapper.resource(name, "provenance", path_prefix=path_prefix, controller=controller) + + def wrap_in_middleware( app, global_conf, **local_conf ): """ Based on the configuration wrap `app` in a set of common and useful https://bitbucket.org/galaxy/galaxy-central/commits/cc89e2320856/ Changeset: cc89e2320856 Branch: provenance User: kellrott Date: 2013-05-28 09:05:35 Summary: Adding source following in provenance tracing Affected #: 1 file diff -r 0705fc913ef53e19f41ca6b0b8351f1335bcc597 -r cc89e2320856b256e224fd08b38b43782d0659d6 lib/galaxy/webapps/galaxy/api/provenance.py --- a/lib/galaxy/webapps/galaxy/api/provenance.py +++ b/lib/galaxy/webapps/galaxy/api/provenance.py @@ -14,12 +14,14 @@ """ @web.expose_api def index( self, trans, **kwd ): - value = self._get_provenance( trans, self.provenance_item_class, kwd[self.provenance_item_id] ) + follow = kwd.get('follow', False) + value = self._get_provenance( trans, self.provenance_item_class, kwd[self.provenance_item_id], follow ) return value @web.expose_api def show( self, trans, elem_name, **kwd ): - value = self._get_provenance( trans, self.provenance_item_class, kwd[self.provenance_item_id] ) + follow = kwd.get('follow', False) + value = self._get_provenance( trans, self.provenance_item_class, kwd[self.provenance_item_id], follow ) return value @web.expose_api @@ -31,50 +33,35 @@ raise HTTPBadRequest("Cannot Delete Provenance") def _get_provenance(self, trans, item_class_name, item_id, follow=True): - out = [] provenance_item = self.get_object( trans, item_id, item_class_name, check_ownership=False, check_accessible=True ) - out.append( - { - "dataset" : { - "id" : trans.security.encode_id(provenance_item.id), - "uuid" : provenance_item.dataset.uuid - }, - "tool_id" : provenance_item.creating_job.tool_id, - "parameters" : self._get_job_record(trans, provenance_item.creating_job) - } - ) - if follow: - depends = self._get_dataset_depends(provenance_item) - recorded = {} - for rec in depends: - if rec.id not in recorded: - recorded[rec.id] = True - out.append( - { - "dataset" : { - "id" : trans.security.encode_id(rec.id), - "uuid" : rec.dataset.uuid - }, - "tool_id" : rec.creating_job.tool_id, - "parameters" : self._get_job_record(trans, rec.creating_job) - } - ) + out = self._get_record(trans, provenance_item, follow) return out - def _get_dataset_depends(self, item): - out = [] - for d in item.creating_job.input_datasets: - out.append(d.dataset) - for c in self._get_dataset_depends(d.dataset): - out.append(c) - return out + def _get_record(self, trans, item, follow): + if item is not None: + if follow: + if item.copied_from_library_dataset_dataset_association: + item = item.copied_from_library_dataset_dataset_association + return { + "id" : trans.security.encode_id(item.id), + "uuid" : item.dataset.uuid, + "tool_id" : item.creating_job.tool_id, + "parameters" : self._get_job_record(trans, item.creating_job, follow) + } + else: + return { + "id" : trans.security.encode_id(item.id), + "uuid" : item.dataset.uuid + } + return None - def _get_job_record(self, trans, job): + def _get_job_record(self, trans, job, follow): out = {} for p in job.parameters: out[p.name] = p.value for in_d in job.input_datasets: - out[in_d.name] = { "dataset_id" : trans.security.encode_id(in_d.dataset.id), "uuid" : in_d.dataset.dataset.uuid } + if follow: + out[in_d.name] = self._get_record(trans, in_d.dataset, follow) return out https://bitbucket.org/galaxy/galaxy-central/commits/fb220d538abb/ Changeset: fb220d538abb Branch: provenance User: Kyle Ellrott Date: 2013-05-28 19:22:01 Summary: Fixing provenance output Affected #: 1 file diff -r cc89e2320856b256e224fd08b38b43782d0659d6 -r fb220d538abb5d3e34e36149779758b0384bfc33 lib/galaxy/webapps/galaxy/api/provenance.py --- a/lib/galaxy/webapps/galaxy/api/provenance.py +++ b/lib/galaxy/webapps/galaxy/api/provenance.py @@ -39,20 +39,14 @@ def _get_record(self, trans, item, follow): if item is not None: - if follow: - if item.copied_from_library_dataset_dataset_association: - item = item.copied_from_library_dataset_dataset_association - return { - "id" : trans.security.encode_id(item.id), - "uuid" : item.dataset.uuid, - "tool_id" : item.creating_job.tool_id, - "parameters" : self._get_job_record(trans, item.creating_job, follow) - } - else: - return { - "id" : trans.security.encode_id(item.id), - "uuid" : item.dataset.uuid - } + if item.copied_from_library_dataset_dataset_association: + item = item.copied_from_library_dataset_dataset_association + return { + "id" : trans.security.encode_id(item.id), + "uuid" : item.dataset.uuid, + "tool_id" : item.creating_job.tool_id, + "parameters" : self._get_job_record(trans, item.creating_job, follow) + } return None def _get_job_record(self, trans, job, follow): @@ -62,6 +56,11 @@ for in_d in job.input_datasets: if follow: out[in_d.name] = self._get_record(trans, in_d.dataset, follow) + else: + out[in_d.name] = { + "id" : trans.security.encode_id(in_d.dataset.id), + "uuid" : in_d.dataset.dataset.uuid + } return out https://bitbucket.org/galaxy/galaxy-central/commits/5b1f643e9ea4/ Changeset: 5b1f643e9ea4 User: dannon Date: 2013-06-17 18:07:20 Summary: Merged in kellrott/galaxy-central/provenance (pull request #174) Adding provenance output to the API Affected #: 2 files diff -r cac2f16e960c698101f16f9cb6191f63eb03e6a8 -r 5b1f643e9ea4da1dfda2859ef96d734f455c8972 lib/galaxy/webapps/galaxy/api/provenance.py --- /dev/null +++ b/lib/galaxy/webapps/galaxy/api/provenance.py @@ -0,0 +1,78 @@ +""" +API operations provenance +""" +import logging +from galaxy import web +from galaxy.web.base.controller import BaseAPIController +from paste.httpexceptions import HTTPNotImplemented, HTTPBadRequest + +log = logging.getLogger( __name__ ) + + +class BaseProvenanceController( BaseAPIController ): + """ + """ + @web.expose_api + def index( self, trans, **kwd ): + follow = kwd.get('follow', False) + value = self._get_provenance( trans, self.provenance_item_class, kwd[self.provenance_item_id], follow ) + return value + + @web.expose_api + def show( self, trans, elem_name, **kwd ): + follow = kwd.get('follow', False) + value = self._get_provenance( trans, self.provenance_item_class, kwd[self.provenance_item_id], follow ) + return value + + @web.expose_api + def create( self, trans, tag_name, payload={}, **kwd ): + raise HTTPNotImplemented() + + @web.expose_api + def delete( self, trans, tag_name, **kwd ): + raise HTTPBadRequest("Cannot Delete Provenance") + + def _get_provenance(self, trans, item_class_name, item_id, follow=True): + provenance_item = self.get_object( trans, item_id, item_class_name, check_ownership=False, check_accessible=True ) + out = self._get_record(trans, provenance_item, follow) + return out + + def _get_record(self, trans, item, follow): + if item is not None: + if item.copied_from_library_dataset_dataset_association: + item = item.copied_from_library_dataset_dataset_association + return { + "id" : trans.security.encode_id(item.id), + "uuid" : item.dataset.uuid, + "tool_id" : item.creating_job.tool_id, + "parameters" : self._get_job_record(trans, item.creating_job, follow) + } + return None + + def _get_job_record(self, trans, job, follow): + out = {} + for p in job.parameters: + out[p.name] = p.value + for in_d in job.input_datasets: + if follow: + out[in_d.name] = self._get_record(trans, in_d.dataset, follow) + else: + out[in_d.name] = { + "id" : trans.security.encode_id(in_d.dataset.id), + "uuid" : in_d.dataset.dataset.uuid + } + return out + + +class HDAProvenanceController( BaseProvenanceController ): + controller_name = "history_content_provenance" + provenance_item_class = "HistoryDatasetAssociation" + provenance_item_id = "history_content_id" + + +class LDDAProvenanceController( BaseProvenanceController ): + controller_name = "ldda_provenance" + provenance_item_class = "LibraryDatasetDatasetAssociation" + provenance_item_id = "library_content_id" + + diff -r cac2f16e960c698101f16f9cb6191f63eb03e6a8 -r 5b1f643e9ea4da1dfda2859ef96d734f455c8972 lib/galaxy/webapps/galaxy/buildapp.py --- a/lib/galaxy/webapps/galaxy/buildapp.py +++ b/lib/galaxy/webapps/galaxy/buildapp.py @@ -128,6 +128,10 @@ name_prefix="workflow_", path_prefix='/api/workflows/:workflow_id' ) + _add_item_provenance_controller( webapp, + name_prefix="history_content_", + path_prefix='/api/histories/:history_id/contents/:history_content_id' ) + webapp.mapper.resource( 'dataset', 'datasets', path_prefix='/api' ) webapp.mapper.resource_with_deleted( 'library', 'libraries', path_prefix='/api' ) webapp.mapper.resource( 'sample', 'samples', path_prefix='/api' ) @@ -234,6 +238,12 @@ name = "%sannotation" % name_prefix webapp.mapper.resource(name, "annotation", path_prefix=path_prefix, controller=controller) +def _add_item_provenance_controller( webapp, name_prefix, path_prefix, **kwd ): + controller = "%sprovenance" % name_prefix + name = "%sprovenance" % name_prefix + webapp.mapper.resource(name, "provenance", path_prefix=path_prefix, controller=controller) + + def wrap_in_middleware( app, global_conf, **local_conf ): """ Based on the configuration wrap `app` in a set of common and useful 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