From c216861c208f5d18460ed067fb0db9c0e089a104 Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Sun, 10 Oct 2021 19:46:00 +0200 Subject: [PATCH 1/5] enable sniffer for fastqillumina --- lib/galaxy/config/sample/datatypes_conf.xml.sample | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/galaxy/config/sample/datatypes_conf.xml.sample b/lib/galaxy/config/sample/datatypes_conf.xml.sample index b97e85c0a46..f4916b9d8a0 100644 --- a/lib/galaxy/config/sample/datatypes_conf.xml.sample +++ b/lib/galaxy/config/sample/datatypes_conf.xml.sample @@ -1065,6 +1065,7 @@ + From 012a7e54f241148a03a9d81eeb914602ee4a1acf Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Fri, 14 Jan 2022 16:31:36 +0100 Subject: [PATCH 2/5] remove fastqillumina sniffer again and disable it forever for fastqillumina and -solexa --- lib/galaxy/config/sample/datatypes_conf.xml.sample | 1 - lib/galaxy/datatypes/sequence.py | 10 ++++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/config/sample/datatypes_conf.xml.sample b/lib/galaxy/config/sample/datatypes_conf.xml.sample index f4916b9d8a0..b97e85c0a46 100644 --- a/lib/galaxy/config/sample/datatypes_conf.xml.sample +++ b/lib/galaxy/config/sample/datatypes_conf.xml.sample @@ -1065,7 +1065,6 @@ - diff --git a/lib/galaxy/datatypes/sequence.py b/lib/galaxy/datatypes/sequence.py index 875c7c5730e..ff8ed57fb9f 100644 --- a/lib/galaxy/datatypes/sequence.py +++ b/lib/galaxy/datatypes/sequence.py @@ -860,6 +860,11 @@ class FastqSolexa(Fastq): return False return True + def sniff_prefix(self, file_prefix: FilePrefix): + # we expicitely do not want to have this sniffed. so we keep this here + # such that it can not be enabled in datatypes_conf + raise NotImplementedError + class FastqIllumina(Fastq): """Class representing a FASTQ sequence ( the Illumina 1.3+ variant ) @@ -880,6 +885,11 @@ class FastqIllumina(Fastq): return False return True + def sniff_prefix(self, file_prefix: FilePrefix): + # we expicitely do not want to have this sniffed. so we keep this here + # such that it can not be enabled in datatypes_conf + raise NotImplementedError + class FastqCSSanger(Fastq): """Class representing a Color Space FASTQ sequence ( e.g a SOLiD variant ) From 304e1cdc385109fc0e894e8d63d7ffa282309eea Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Mon, 17 Jan 2022 14:24:02 +0100 Subject: [PATCH 3/5] catch exceptions in build_sniff_from_prefix if sniff_prefix raises ant exception the sniffer should return False Co-authored-by: Marius van den Beek --- lib/galaxy/datatypes/sniff.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/datatypes/sniff.py b/lib/galaxy/datatypes/sniff.py index 40341e0bc6b..8d0f6192c1e 100644 --- a/lib/galaxy/datatypes/sniff.py +++ b/lib/galaxy/datatypes/sniff.py @@ -664,7 +664,10 @@ def build_sniff_from_prefix(klass): if hasattr(self, "compressed_format"): if self.compressed_format != file_prefix.compressed_format: return False - return self.sniff_prefix(file_prefix) + try: + return self.sniff_prefix(file_prefix) + except Exception: + return False klass.sniff = auto_sniff return klass From 8594b13036be0a595454a3d2c96837f063a60530 Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Wed, 19 Jan 2022 14:12:29 +0100 Subject: [PATCH 4/5] Revert "catch exceptions in build_sniff_from_prefix" This reverts commit 304e1cdc385109fc0e894e8d63d7ffa282309eea. --- lib/galaxy/datatypes/sniff.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/galaxy/datatypes/sniff.py b/lib/galaxy/datatypes/sniff.py index 8d0f6192c1e..40341e0bc6b 100644 --- a/lib/galaxy/datatypes/sniff.py +++ b/lib/galaxy/datatypes/sniff.py @@ -664,10 +664,7 @@ def build_sniff_from_prefix(klass): if hasattr(self, "compressed_format"): if self.compressed_format != file_prefix.compressed_format: return False - try: - return self.sniff_prefix(file_prefix) - except Exception: - return False + return self.sniff_prefix(file_prefix) klass.sniff = auto_sniff return klass From 37a2edf00a7e3b7f96c846969a3ff00be8de88ee Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Wed, 19 Jan 2022 14:14:54 +0100 Subject: [PATCH 5/5] catch sniffing exceptions in handle uploads Co-authored-by: Nicola Soranzo Co-authored-by: Marius van den Beek --- lib/galaxy/datatypes/upload_util.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/galaxy/datatypes/upload_util.py b/lib/galaxy/datatypes/upload_util.py index 963e2bfb96b..c4772c35332 100644 --- a/lib/galaxy/datatypes/upload_util.py +++ b/lib/galaxy/datatypes/upload_util.py @@ -80,9 +80,13 @@ def handle_upload( if requested_ext != 'auto': datatype = registry.get_datatype_by_extension(requested_ext) # Enable sniffer "validate mode" (prevents certain sniffers from disabling themselves) - if check_content and hasattr(datatype, 'sniff') and not datatype.sniff(path): - stdout = ("Warning: The file 'Type' was set to '{ext}' but the file does not appear to be of that" - " type".format(ext=requested_ext)) + if check_content and hasattr(datatype, 'sniff'): + try: + is_of_datatype = datatype.sniff(path) + except Exception: + is_of_datatype = False + if not is_of_datatype: + stdout = f"Warning: The file 'Type' was set to '{requested_ext}' but the file does not appear to be of that type" # Handle unsniffable binaries if is_binary and ext == 'binary':