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.0] Never fail dataset serialization if display_peek fails #17937

Merged
merged 4 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions lib/galaxy/datatypes/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,10 @@ def set_peek(self, dataset: DatasetProtocol, **kwd) -> None:

def display_peek(self, dataset: DatasetProtocol) -> str:
"""Create HTML table, used for displaying peek"""
if not dataset.peek:
return "Peek not available"
out = ['<table cellspacing="0" cellpadding="3">']
try:
if not dataset.peek:
dataset.set_peek()
data = dataset.peek
lines = data.splitlines()
for line in lines:
Expand Down
4 changes: 4 additions & 0 deletions lib/galaxy/datatypes/qiime2.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def set_peek(self, dataset: DatasetProtocol, **kwd) -> None:
dataset.peek = "\n".join(map(": ".join, self._peek(dataset)))

def display_peek(self, dataset: DatasetProtocol) -> str:
if dataset.metadata.semantic_type is None:
# Proxy for metadata elements not (yet) set
return "Peek unavailable"

def make_row(pair):
return f"<tr><th>{pair[0]}</th><td>{html.escape(pair[1])}</td></tr>"

Expand Down
6 changes: 5 additions & 1 deletion lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4666,7 +4666,11 @@ def as_display_type(self, type, **kwd):
return self.datatype.as_display_type(self, type, **kwd)

def display_peek(self):
return self.datatype.display_peek(self)
try:
return self.datatype.display_peek(self)
except Exception:
log.exception("Error occurred while generating dataset pee")
mvdbeek marked this conversation as resolved.
Show resolved Hide resolved
return None

def display_name(self):
return self.datatype.display_name(self)
Expand Down
3 changes: 3 additions & 0 deletions test/unit/data/datatypes/test_qiime2.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ def test_qza_set_peek():
with get_input_files("qiime2.qza") as input_files:
dataset = MockDataset(1)
dataset.set_file_name(input_files[0])
dataset.metadata.semantic_type = None
dataset.metadata.uuid = None
assert qza.display_peek(dataset) == "Peek unavailable"

qza.set_meta(dataset)
qza.set_peek(dataset)
Expand Down
Loading