From 819ee07af36d10734b32474fa832ce9e09e1b376 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Mon, 13 Aug 2018 11:55:39 +0200 Subject: [PATCH] Respect unavilable peek when serializing HDA Also call display_peek() just once. That fixes the following exception that occurs when running the Filter1 tool through the API: ``` galaxy.datatypes.tabular ERROR 2018-08-12 22:53:42,939 make_html_peek_rows failed on HDA 64 Traceback (most recent call last): File "/Users/mvandenb/src/galaxy/lib/galaxy/datatypes/tabular.py", line 186, in make_html_peek_rows dataset.set_peek() File "/Users/mvandenb/src/galaxy/lib/galaxy/model/__init__.py", line 2264, in set_peek return self.datatype.set_peek(self) File "/Users/mvandenb/src/galaxy/lib/galaxy/datatypes/tabular.py", line 57, in set_peek super(TabularData, self).set_peek(dataset, line_count=line_count, WIDTH=WIDTH, skipchars=skipchars, line_wrap=False) File "/Users/mvandenb/src/galaxy/lib/galaxy/datatypes/data.py", line 813, in set_peek dataset.peek = get_file_peek(dataset.file_name, WIDTH=WIDTH, skipchars=skipchars, line_wrap=line_wrap) File "/Users/mvandenb/src/galaxy/lib/galaxy/datatypes/data.py", line 1029, in get_file_peek with compression_utils.get_fileobj(file_name, "U") as temp: File "/Users/mvandenb/src/galaxy/lib/galaxy/util/compression_utils.py", line 29, in get_fileobj return get_fileobj_raw(filename, mode, compressed_formats)[1] File "/Users/mvandenb/src/galaxy/lib/galaxy/util/compression_utils.py", line 58, in get_fileobj_raw return compressed_format, io.open(filename, mode, encoding='utf-8') FileNotFoundError: [Errno 2] No such file or directory: '/private/var/folders/df/6xqpqpcd7h73b6jpx9t6cwhw0000gn/T/tmpan_4qaow/tmpfzus9jhv/tmplqjtbp5c/database/files/000/dataset_40.dat' ``` This is because we serialize the HDA just after the job has been created, meaning the file may not exist yet. --- lib/galaxy/model/__init__.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index 45a35a72c8f..b1af4190839 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -54,7 +54,6 @@ from galaxy.util.sanitize_html import sanitize_html from galaxy.web.form_builder import (AddressField, CheckboxField, HistoryField, PasswordField, SelectField, TextArea, TextField, WorkflowField, WorkflowMappingField) -from galaxy.web.framework.helpers import to_unicode log = logging.getLogger(__name__) @@ -2753,7 +2752,7 @@ class HistoryDatasetAssociation(DatasetInstance, HasTags, Dictifiable, UsesAnnot uuid=(lambda uuid: str(uuid) if uuid else None)(hda.dataset.uuid), hid=hda.hid, file_ext=hda.ext, - peek=(lambda hda: hda.display_peek() if hda.peek and hda.peek != 'no peek' else None)(hda), + peek=unicodify(hda.display_peek()) if hda.peek and hda.peek != 'no peek' else None, model_class=self.__class__.__name__, name=hda.name, deleted=hda.deleted, @@ -2780,8 +2779,6 @@ class HistoryDatasetAssociation(DatasetInstance, HasTags, Dictifiable, UsesAnnot if hda.extended_metadata is not None: rval['extended_metadata'] = hda.extended_metadata.data - rval['peek'] = to_unicode(hda.display_peek()) - for name, spec in hda.metadata.spec.items(): val = hda.metadata.get(name) if isinstance(val, MetadataFile):