diff --git a/lib/galaxy/managers/datasets.py b/lib/galaxy/managers/datasets.py index 0bbb4f4cbaf6..472e6689639e 100644 --- a/lib/galaxy/managers/datasets.py +++ b/lib/galaxy/managers/datasets.py @@ -497,8 +497,8 @@ def ensure_dataset_on_disk(self, trans, dataset): raise exceptions.ItemDeletionException("The dataset you are attempting to view has been deleted.") elif dataset.state == Dataset.states.UPLOAD: raise exceptions.Conflict("Please wait until this dataset finishes uploading before attempting to view it.") - elif dataset.state == Dataset.states.NEW: - raise exceptions.Conflict("The dataset you are attempting to view is new and has no data.") + elif dataset.state in (Dataset.states.NEW, Dataset.states.QUEUED): + raise exceptions.Conflict(f"The dataset you are attempting to view is {dataset.state} and has no data.") elif dataset.state == Dataset.states.DISCARDED: raise exceptions.ItemDeletionException("The dataset you are attempting to view has been discarded.") elif dataset.state == Dataset.states.DEFERRED: @@ -509,6 +509,14 @@ def ensure_dataset_on_disk(self, trans, dataset): raise exceptions.Conflict( "The dataset you are attempting to view is in paused state. One of the inputs for the job that creates this dataset has failed." ) + elif dataset.state == Dataset.states.RUNNING: + if not self.app.object_store.exists(dataset.dataset): + raise exceptions.Conflict( + "The dataset you are attempting to view is still being created and has no data yet." + ) + elif dataset.state == Dataset.states.ERROR: + if not self.app.object_store.exists(dataset.dataset): + raise exceptions.RequestParameterInvalidException("The dataset is in error and has no data.") def ensure_can_change_datatype(self, dataset: model.DatasetInstance, raiseException: bool = True) -> bool: if not dataset.datatype.is_datatype_change_allowed(): diff --git a/lib/galaxy/webapps/galaxy/controllers/dataset.py b/lib/galaxy/webapps/galaxy/controllers/dataset.py index efcfe5ae2c2d..f9ff2a413893 100644 --- a/lib/galaxy/webapps/galaxy/controllers/dataset.py +++ b/lib/galaxy/webapps/galaxy/controllers/dataset.py @@ -25,7 +25,6 @@ HDAManager, ) from galaxy.managers.histories import HistoryManager -from galaxy.model import Dataset from galaxy.model.base import transaction from galaxy.model.item_attrs import ( UsesAnnotations, @@ -108,24 +107,7 @@ def _check_dataset(self, trans, hda_id): raise web.httpexceptions.HTTPNotFound(f"Invalid reference dataset id: {str(hda_id)}.") if not self._can_access_dataset(trans, data): return trans.show_error_message("You are not allowed to access this dataset") - if data.purged or data.dataset.purged: - return trans.show_error_message("The dataset you are attempting to view has been purged.") - elif data.deleted and not (trans.user_is_admin or (data.history and trans.get_user() == data.user)): - return trans.show_error_message("The dataset you are attempting to view has been deleted.") - elif data.state == Dataset.states.UPLOAD: - return trans.show_error_message( - "Please wait until this dataset finishes uploading before attempting to view it." - ) - elif data.state == Dataset.states.DISCARDED: - return trans.show_error_message("The dataset you are attempting to view has been discarded.") - elif data.state == Dataset.states.DEFERRED: - return trans.show_error_message( - "The dataset you are attempting to view has deferred data. You can only use this dataset as input for jobs." - ) - elif data.state == Dataset.states.PAUSED: - return trans.show_error_message( - "The dataset you are attempting to view is in paused state. One of the inputs for the job that creates this dataset has failed." - ) + self.app.hda_manager.ensure_dataset_on_disk(trans, data) return data @web.expose @@ -133,8 +115,6 @@ def display( self, trans, dataset_id=None, preview=False, filename=None, to_ext=None, offset=None, ck_size=None, **kwd ): data = self._check_dataset(trans, dataset_id) - if not isinstance(data, trans.app.model.DatasetInstance): - return data if "hdca" in kwd: raise RequestParameterInvalidException("Invalid request parameter 'hdca' encountered.") if hdca_id := kwd.get("hdca_id", None): @@ -478,8 +458,6 @@ def imp(self, trans, dataset_id=None, **kwd): def display_by_username_and_slug(self, trans, username, slug, filename=None, preview=True, **kwargs): """Display dataset by username and slug; because datasets do not yet have slugs, the slug is the dataset's id.""" dataset = self._check_dataset(trans, slug) - if not isinstance(dataset, trans.app.model.DatasetInstance): - return dataset # Filename used for composite types. if filename: return self.display(trans, dataset_id=slug, filename=filename)