diff --git a/lib/galaxy/webapps/galaxy/controllers/dataset.py b/lib/galaxy/webapps/galaxy/controllers/dataset.py index e1c2f5b79a9a..d3e770fae928 100644 --- a/lib/galaxy/webapps/galaxy/controllers/dataset.py +++ b/lib/galaxy/webapps/galaxy/controllers/dataset.py @@ -19,7 +19,10 @@ encode_dataset_user, ) from galaxy.datatypes.sniff import guess_ext -from galaxy.exceptions import RequestParameterInvalidException +from galaxy.exceptions import ( + MessageException, + RequestParameterInvalidException, +) from galaxy.managers.hdas import ( HDADeserializer, HDAManager, @@ -158,7 +161,7 @@ def display( trans.response.headers.update(headers) return display_data - @web.legacy_expose_api_anonymous + @web.expose_api_anonymous def get_edit(self, trans, dataset_id=None, **kwd): """Produces the input definitions available to modify dataset attributes""" status = None @@ -168,8 +171,8 @@ def get_edit(self, trans, dataset_id=None, **kwd): if self._can_access_dataset(trans, data): if data.state == trans.model.Dataset.states.UPLOAD: - return self.message_exception( - trans, "Please wait until this dataset finishes uploading before attempting to edit its metadata." + raise MessageException( + "Please wait until this dataset finishes uploading before attempting to edit its metadata." ) # let's not overwrite the imported datatypes module with the variable datatypes? # the built-in 'id' is overwritten in lots of places as well @@ -331,8 +334,8 @@ def get_edit(self, trans, dataset_id=None, **kwd): "permission_disable": permission_disable, } else: - return self.message_exception( - trans, f"You do not have permission to edit this dataset's ( id: {dataset_id} ) information." + raise MessageException( + "You do not have permission to edit this dataset's ( id: {dataset_id} ) information." ) @web.expose_api_anonymous @@ -378,9 +381,8 @@ def set_edit(self, trans, payload=None, **kwd): if data.datatype.is_datatype_change_allowed(): # prevent modifying datatype when dataset is queued or running as input/output if not data.ok_to_edit_metadata(): - return self.message_exception( - trans, - "This dataset is currently being used as input or output. You cannot change datatype until the jobs have completed or you have canceled them.", + raise MessageException( + "This dataset is currently being used as input or output. You cannot change datatype until the jobs have completed or you have canceled them." ) else: path = data.dataset.get_file_name() @@ -397,7 +399,7 @@ def set_edit(self, trans, payload=None, **kwd): trans.app.job_manager.enqueue(job, tool=trans.app.datatypes_registry.set_external_metadata_tool) message = f"Detection was finished and changed the datatype to {datatype}." else: - return self.message_exception(trans, f'Changing datatype "{data.extension}" is not allowed.') + raise MessageException(f'Changing datatype "{data.extension}" is not allowed.') elif operation == "autodetect": # The user clicked the Auto-detect button on the 'Edit Attributes' form self.hda_manager.set_metadata(trans, data, overwrite=True) @@ -408,7 +410,7 @@ def set_edit(self, trans, payload=None, **kwd): try: message = data.datatype.convert_dataset(trans, data, target_type) except DatatypeConverterNotFoundException as e: - return self.message_exception(trans, str(e)) + raise MessageException(str(e)) elif operation == "permission": # Adapt form request to API - style. payload_permissions = {} @@ -425,7 +427,7 @@ def set_edit(self, trans, payload=None, **kwd): ) message = "Your changes completed successfully." else: - return self.message_exception(trans, f"Invalid operation identifier ({operation}).") + raise MessageException(f"Invalid operation identifier ({operation}).") return {"status": status, "message": sanitize_text(message)} def _get_dataset_for_edit(self, trans, dataset_id):