Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[24.1] Extend on disk checks to running, queued and error states #18846

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/galaxy/managers/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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():
Expand Down
24 changes: 1 addition & 23 deletions lib/galaxy/webapps/galaxy/controllers/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -108,33 +107,14 @@ 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
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):
Expand Down Expand Up @@ -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)
Expand Down
Loading