From b304eb811c4ca9d8beb87047ea9f90e3487715fe Mon Sep 17 00:00:00 2001
From: mattloose <matt.loose@nottingham.ac.uk>
Date: Wed, 24 Apr 2024 16:46:39 +0100
Subject: [PATCH 01/12] Initial validation of minknow version and guppy dorado
 versions

---
 src/readfish/__about__.py            |  5 +++
 src/readfish/__compatability__.py    | 11 +++++++
 src/readfish/_utils.py               | 48 +++++++++++++++++++++++++++-
 src/readfish/entry_points/targets.py |  5 +++
 src/readfish/plugins/dorado.py       | 13 ++++++++
 src/readfish/plugins/guppy.py        | 13 ++++++++
 6 files changed, 94 insertions(+), 1 deletion(-)
 create mode 100644 src/readfish/__compatability__.py

diff --git a/src/readfish/__about__.py b/src/readfish/__about__.py
index 24efc747..499bc028 100644
--- a/src/readfish/__about__.py
+++ b/src/readfish/__about__.py
@@ -3,3 +3,8 @@
 """
 
 __version__ = "2024.0.0"
+# Warning is the last supported version of MinKNOW for this version of readfish
+# Users running this version will receive the warning shown if they are running this version of readfish.
+__warning__ = [["5.9", f"Readfish {__version__} will not be supported in the next version of MinKNOW. Please update to the latest version of Readfish or do not update MinKNOW if you are concerned about version control."]]
+# Compatability is either the maximum or minimum version of MinKNOW that this version of readfish is compatible with.
+__compatability__ = [["6.0","lte"]]
diff --git a/src/readfish/__compatability__.py b/src/readfish/__compatability__.py
new file mode 100644
index 00000000..54f00996
--- /dev/null
+++ b/src/readfish/__compatability__.py
@@ -0,0 +1,11 @@
+"""__compatability__.py
+This file allows us to check versions of MinKNOW against versions of readfish.
+"""
+
+from readfish.__about__ import __version__
+
+# Warning is the last supported version of MinKNOW for this version of readfish
+# Users running this version will receive the warning shown if they are running this version of readfish.
+__warning__ = [["5.9", f"Readfish {__version__} will not be supported in the next version of MinKNOW. Please update to the latest version of Readfish or do not update MinKNOW if you are concerned about version control."]]
+# Compatability is either the maximum or minimum version of MinKNOW that this version of readfish is compatible with.
+__compatability__ = [["6.0","lte"]]
\ No newline at end of file
diff --git a/src/readfish/_utils.py b/src/readfish/_utils.py
index 991ac160..e0549b46 100644
--- a/src/readfish/_utils.py
+++ b/src/readfish/_utils.py
@@ -10,6 +10,7 @@
 from enum import IntEnum
 import re
 import base64
+from packaging.version import parse as parse_version
 from typing import Any, Mapping, Sequence
 import zlib
 
@@ -18,11 +19,14 @@
 from minknow_api.manager import Manager, FlowCellPosition
 from minknow_api import Connection
 
+
 if sys.version_info < (3, 11):
     from exceptiongroup import BaseExceptionGroup
 
 from readfish._channels import FLONGLE_CHANNELS, MINION_CHANNELS
-
+from readfish.__about__ import __version__ as readfish_version
+from readfish.__compatability__ import __compatability__ as compatible_version
+from readfish.__compatability__ import __warning__ as warning_version
 
 MODULE_LOGGER = logging.getLogger(__name__)
 
@@ -449,6 +453,48 @@ def get_device(
             return position
     raise ValueError(f"Could not find device {device!r}")
 
+def get_version(
+        host: str = "127.0.0.1", port: int = None, logger: logging.Logger = None
+) -> str:
+    """Get the version of MinKNOW
+
+    :param host: The host the RPC is listening on, defaults to "127.0.0.1"
+    :param port: The port the RPC is listening on, defaults to None
+    :raises ValueError: If the version of Readfish is incompatible with the version of MinKNOW.
+    :raises Warning: If the version of Readfish may need to be updated soon.
+    :return: The version of MinKNOW
+    """
+    manager = Manager(host=host, port=port)
+    minknow_version = parse_version(manager.core_version)
+    # Check compatability
+    for cv, direction in compatible_version:
+        ver_cv = parse_version(cv)
+        if direction == "gte":
+            if minknow_version <= ver_cv:
+                raise ValueError(
+                    f"Compatability check failed. Readfish version {readfish_version} is not compatible with MinKNOW version {minknow_version}. You need to update readfish."
+                )
+        elif direction == "lte":
+            if minknow_version >= ver_cv:
+                raise ValueError(
+                    f"Compatability check failed. Readfish version {readfish_version} is not compatible with MinKNOW version {minknow_version}. You need to downgrade readfish."
+                )
+    for wv, message in warning_version:
+        warn = False
+        ver_wv = parse_version(wv)
+        if ver_wv.major == minknow_version.major:
+            if ver_wv.minor == minknow_version.minor:
+                if ver_wv.micro == minknow_version.micro:
+                    warn=True
+                else:
+                    warn=True
+            else:
+                warn=True
+        if warn:
+            logger.info(
+                f"Warning: {message}"
+            )
+    return None
 
 if __name__ == "__main__":
     import doctest
diff --git a/src/readfish/entry_points/targets.py b/src/readfish/entry_points/targets.py
index 3257be69..bcd1f752 100644
--- a/src/readfish/entry_points/targets.py
+++ b/src/readfish/entry_points/targets.py
@@ -88,6 +88,7 @@
 from readfish._statistics import ReadfishStatistics
 from readfish._utils import (
     get_device,
+    get_version,
     send_message,
     ChunkTracker,
     Severity,
@@ -485,6 +486,10 @@ def run(
     # Setup logger used in this entry point, this one should be passed through
     logger = logging.getLogger(f"readfish.{args.command}")
 
+    # Check MinKNOW version
+
+    minKNOW_version = get_version(host=args.host, port=args.port, logger=logger)
+
     # Fetch sequencing device
     position = get_device(args.device, host=args.host, port=args.port)
 
diff --git a/src/readfish/plugins/dorado.py b/src/readfish/plugins/dorado.py
index 34a0acd1..d35a40b0 100644
--- a/src/readfish/plugins/dorado.py
+++ b/src/readfish/plugins/dorado.py
@@ -10,6 +10,7 @@
 from collections import namedtuple
 from pathlib import Path
 from typing import Iterable, TYPE_CHECKING
+from packaging.version import parse as parse_version
 
 import numpy as np
 import numpy.typing as npt
@@ -66,6 +67,18 @@ def __init__(
         self.supported_barcode_kits = None
         self.supported_basecall_models = None
         self.run_information = run_information
+        if self.run_information:
+            self.guppy_version = self.run_information.software_versions.guppy_connected_version
+
+            if parse_version(self.guppy_version) >= parse_version("7.3.9"):
+                logging.info(
+                    f"Connected to caller version {self.guppy_version}."
+                )
+            else:
+                raise RuntimeError(
+                    f"Connected to caller version {self.guppy_version}. This plugin requires a version of Dorado >= 7.3.9."
+                )
+
         if sample_rate:
             self.sample_rate = float(sample_rate)
         else:
diff --git a/src/readfish/plugins/guppy.py b/src/readfish/plugins/guppy.py
index 5cadf1d4..a79a6b24 100644
--- a/src/readfish/plugins/guppy.py
+++ b/src/readfish/plugins/guppy.py
@@ -10,6 +10,7 @@
 from collections import namedtuple
 from pathlib import Path
 from typing import Iterable, TYPE_CHECKING
+from packaging.version import parse as parse_version
 
 import numpy as np
 import numpy.typing as npt
@@ -62,6 +63,18 @@ def __init__(
         self.supported_basecall_models = None
         self.run_information = run_information
 
+        if self.run_information:
+            self.guppy_version = self.run_information.software_versions.guppy_connected_version
+
+            if parse_version(self.guppy_version) < parse_version("7.3.9"):
+                logging.info(
+                    f"Connected to caller version {self.guppy_version}."
+                )
+            else:
+                raise RuntimeError(
+                    f"Connected to caller version {self.guppy_version}. This plugin requires a version of Dorado or Guppy < 7.3.9. Try changing [caller_settings.guppy] to [caller_settings.dorado]."
+                )
+
         # Set our own priority
         self.guppy_params = kwargs
         self.guppy_params["priority"] = PyGuppyClient.high_priority

From 40760a8db191c196b552af97af3c06ef46cf5baf Mon Sep 17 00:00:00 2001
From: Adoni5 <roryjmunro1@gmail.com>
Date: Mon, 29 Apr 2024 14:05:23 +0100
Subject: [PATCH 02/12] MinKNOW compatibility check function Base-caller
 compatibiity check

---
 src/readfish/__about__.py            |   4 --
 src/readfish/__compatability__.py    |  11 ---
 src/readfish/_utils.py               |  48 +------------
 src/readfish/compatibility.py        | 102 +++++++++++++++++++++++++++
 src/readfish/entry_points/targets.py |  19 +++--
 5 files changed, 118 insertions(+), 66 deletions(-)
 delete mode 100644 src/readfish/__compatability__.py
 create mode 100644 src/readfish/compatibility.py

diff --git a/src/readfish/__about__.py b/src/readfish/__about__.py
index 499bc028..b515e68f 100644
--- a/src/readfish/__about__.py
+++ b/src/readfish/__about__.py
@@ -4,7 +4,3 @@
 
 __version__ = "2024.0.0"
 # Warning is the last supported version of MinKNOW for this version of readfish
-# Users running this version will receive the warning shown if they are running this version of readfish.
-__warning__ = [["5.9", f"Readfish {__version__} will not be supported in the next version of MinKNOW. Please update to the latest version of Readfish or do not update MinKNOW if you are concerned about version control."]]
-# Compatability is either the maximum or minimum version of MinKNOW that this version of readfish is compatible with.
-__compatability__ = [["6.0","lte"]]
diff --git a/src/readfish/__compatability__.py b/src/readfish/__compatability__.py
deleted file mode 100644
index 54f00996..00000000
--- a/src/readfish/__compatability__.py
+++ /dev/null
@@ -1,11 +0,0 @@
-"""__compatability__.py
-This file allows us to check versions of MinKNOW against versions of readfish.
-"""
-
-from readfish.__about__ import __version__
-
-# Warning is the last supported version of MinKNOW for this version of readfish
-# Users running this version will receive the warning shown if they are running this version of readfish.
-__warning__ = [["5.9", f"Readfish {__version__} will not be supported in the next version of MinKNOW. Please update to the latest version of Readfish or do not update MinKNOW if you are concerned about version control."]]
-# Compatability is either the maximum or minimum version of MinKNOW that this version of readfish is compatible with.
-__compatability__ = [["6.0","lte"]]
\ No newline at end of file
diff --git a/src/readfish/_utils.py b/src/readfish/_utils.py
index e0549b46..b1476073 100644
--- a/src/readfish/_utils.py
+++ b/src/readfish/_utils.py
@@ -1,6 +1,7 @@
 """utils.py
 functions and utilities used internally.
 """
+
 from __future__ import annotations
 import sys
 import logging
@@ -10,7 +11,6 @@
 from enum import IntEnum
 import re
 import base64
-from packaging.version import parse as parse_version
 from typing import Any, Mapping, Sequence
 import zlib
 
@@ -24,9 +24,7 @@
     from exceptiongroup import BaseExceptionGroup
 
 from readfish._channels import FLONGLE_CHANNELS, MINION_CHANNELS
-from readfish.__about__ import __version__ as readfish_version
-from readfish.__compatability__ import __compatability__ as compatible_version
-from readfish.__compatability__ import __warning__ as warning_version
+
 
 MODULE_LOGGER = logging.getLogger(__name__)
 
@@ -453,48 +451,6 @@ def get_device(
             return position
     raise ValueError(f"Could not find device {device!r}")
 
-def get_version(
-        host: str = "127.0.0.1", port: int = None, logger: logging.Logger = None
-) -> str:
-    """Get the version of MinKNOW
-
-    :param host: The host the RPC is listening on, defaults to "127.0.0.1"
-    :param port: The port the RPC is listening on, defaults to None
-    :raises ValueError: If the version of Readfish is incompatible with the version of MinKNOW.
-    :raises Warning: If the version of Readfish may need to be updated soon.
-    :return: The version of MinKNOW
-    """
-    manager = Manager(host=host, port=port)
-    minknow_version = parse_version(manager.core_version)
-    # Check compatability
-    for cv, direction in compatible_version:
-        ver_cv = parse_version(cv)
-        if direction == "gte":
-            if minknow_version <= ver_cv:
-                raise ValueError(
-                    f"Compatability check failed. Readfish version {readfish_version} is not compatible with MinKNOW version {minknow_version}. You need to update readfish."
-                )
-        elif direction == "lte":
-            if minknow_version >= ver_cv:
-                raise ValueError(
-                    f"Compatability check failed. Readfish version {readfish_version} is not compatible with MinKNOW version {minknow_version}. You need to downgrade readfish."
-                )
-    for wv, message in warning_version:
-        warn = False
-        ver_wv = parse_version(wv)
-        if ver_wv.major == minknow_version.major:
-            if ver_wv.minor == minknow_version.minor:
-                if ver_wv.micro == minknow_version.micro:
-                    warn=True
-                else:
-                    warn=True
-            else:
-                warn=True
-        if warn:
-            logger.info(
-                f"Warning: {message}"
-            )
-    return None
 
 if __name__ == "__main__":
     import doctest
diff --git a/src/readfish/compatibility.py b/src/readfish/compatibility.py
new file mode 100644
index 00000000..0b22e347
--- /dev/null
+++ b/src/readfish/compatibility.py
@@ -0,0 +1,102 @@
+"""compatibility.py
+
+Contains utilities for checking readfish compatibility with various versions of MinKNOW and Dorado.
+
+Throws a warning for the last supported version of MinKNOW for this version of readfish
+
+Checks ranges of `readfish` against the `MinKNOW` version
+
+"""
+
+from readfish.__about__ import __version__
+from minknow_api.manager import Manager
+from packaging.version import parse as parse_version
+from packaging.version import Version
+from minknow_api.protocol_pb2 import ProtocolRunInfo
+from enum import Enum
+import operator
+
+
+LATEST_TESTED = 5.9
+# Warning is the last tested version of MinKNOW for this version of readfish
+# Users running a higher version of MinKNOW will receive the warning shown if they are running this version of readfish.
+latest_tested_version_warning = (
+    LATEST_TESTED,
+    f"Readfish {__version__} has only been tested up to MinKNOW {LATEST_TESTED}. Please check for an update to readfish!",
+)
+# The versions of MinKNOW which this version of readfish can connect to
+# Format - (lowest minknow, version of minknow not supported as an upper bound)
+MINKNOW_COMPATIBILITY_RANGE = (
+    Version("5.0.0"),
+    Version("6.0"),
+)
+
+
+class DIRECTION(Enum):
+    """
+    Upgrade, downgrade or just right
+
+    """
+
+    UPGRADE = "Upgrade"
+    DOWNGRADE = "Downgrade"
+    JUST_RIGHT = "Do nothing"
+
+
+def _get_minknow_version(host: str = "127.0.0.1", port: int = None) -> Version:
+    """
+    Get the version of MinKNOW
+
+    :param host: The host the RPC is listening on, defaults to "127.0.0.1"
+    :param port: The port the RPC is listening on, defaults to None
+
+    :return: The version of MinKNOW readfish is connected to
+    """
+    manager = Manager(host=host, port=port)
+    minknow_version = parse_version(manager.core_version)
+    return minknow_version
+
+
+def check_compatibility(
+    comparator: Version,
+    version_range: tuple[Version, Version],
+) -> bool:
+    """
+    Check the compatibility of a given software version, between a given range.
+
+    :param comparator: Version of the provided software, for example MinKNOW 5.9.7
+    :param version_ranges: A tuple of lowest supported version, highest supported version
+    """
+    (
+        lowest_supported_version,
+        highest_supported_version,
+    ) = version_range
+    if comparator < lowest_supported_version:
+        return (
+            False,
+            DIRECTION.DOWNGRADE,
+        )
+    return (
+        (True, DIRECTION.JUST_RIGHT)
+        if comparator < highest_supported_version
+        else (False, DIRECTION.UPGRADE)
+    )
+
+
+def check_basecaller_compatibility(
+    run_information: ProtocolRunInfo, op, version: str, extra_error: str | None = None
+):
+    symbol = {
+        operator.lt: "<",
+        operator.gt: ">",
+        operator.le: "<=",
+        operator.ge: ">=",
+        operator.eq: "==",
+        operator.ne: "!=",
+    }
+    guppy_version = run_information.software_versions.guppy_connected_version
+    if not op(parse_version(guppy_version), parse_version(version)):
+        extra_error = extra_error if extra_error is not None else ""
+        raise RuntimeError(
+            f"Cannot connect to base-caller {guppy_version}. This plugin requires a version of Dorado or Guppy {symbol[op]} {version}. {extra_error}"
+        )
diff --git a/src/readfish/entry_points/targets.py b/src/readfish/entry_points/targets.py
index bcd1f752..8a92787a 100644
--- a/src/readfish/entry_points/targets.py
+++ b/src/readfish/entry_points/targets.py
@@ -86,9 +86,14 @@
 from readfish._read_until_client import RUClient
 from readfish._config import Action, Conf, make_decision, _Condition
 from readfish._statistics import ReadfishStatistics
+from readfish.__about__ import __version__
+from readfish.compatibility import (
+    _get_minknow_version,
+    check_compatibility,
+    MINKNOW_COMPATIBILITY_RANGE,
+)
 from readfish._utils import (
     get_device,
-    get_version,
     send_message,
     ChunkTracker,
     Severity,
@@ -488,7 +493,14 @@ def run(
 
     # Check MinKNOW version
 
-    minKNOW_version = get_version(host=args.host, port=args.port, logger=logger)
+    minknow_version = _get_minknow_version(host=args.host, port=args.port)
+    if not (
+        action := check_compatibility(minknow_version, MINKNOW_COMPATIBILITY_RANGE)
+    )[0]:
+        lower_bound, upper_bound = MINKNOW_COMPATIBILITY_RANGE
+        raise SystemExit(
+            f"This readfish version ({__version__}) is compatible with MinKNOW v{lower_bound} to v{upper_bound}. Please {action[1].value} readfish."
+        )
 
     # Fetch sequencing device
     position = get_device(args.device, host=args.host, port=args.port)
@@ -521,9 +533,6 @@ def run(
 
     # start the client running
     read_until_client.run(
-        # TODO: Set correct channel range
-        # first_channel=186,
-        # last_channel=187,
         first_channel=1,
         last_channel=read_until_client.channel_count,
         max_unblock_read_length_seconds=args.max_unblock_read_length_seconds,

From 4298da9230e92e700ed0446e5bc590d259d1f36d Mon Sep 17 00:00:00 2001
From: Adoni5 <roryjmunro1@gmail.com>
Date: Mon, 29 Apr 2024 14:06:02 +0100
Subject: [PATCH 03/12] Compatibility checks

---
 src/readfish/plugins/dorado.py | 29 +++++++++++++----------------
 src/readfish/plugins/guppy.py  | 23 +++++++++--------------
 2 files changed, 22 insertions(+), 30 deletions(-)

diff --git a/src/readfish/plugins/dorado.py b/src/readfish/plugins/dorado.py
index d35a40b0..d9dda87d 100644
--- a/src/readfish/plugins/dorado.py
+++ b/src/readfish/plugins/dorado.py
@@ -10,12 +10,14 @@
 from collections import namedtuple
 from pathlib import Path
 from typing import Iterable, TYPE_CHECKING
-from packaging.version import parse as parse_version
 
 import numpy as np
 import numpy.typing as npt
 from minknow_api.protocol_pb2 import ProtocolRunInfo
 from minknow_api.device_pb2 import GetSampleRateResponse
+from operator import ge
+
+from readfish.compatibility import check_basecaller_compatibility
 
 try:
     from pybasecall_client_lib.helper_functions import package_read
@@ -68,22 +70,17 @@ def __init__(
         self.supported_basecall_models = None
         self.run_information = run_information
         if self.run_information:
-            self.guppy_version = self.run_information.software_versions.guppy_connected_version
-
-            if parse_version(self.guppy_version) >= parse_version("7.3.9"):
-                logging.info(
-                    f"Connected to caller version {self.guppy_version}."
-                )
-            else:
-                raise RuntimeError(
-                    f"Connected to caller version {self.guppy_version}. This plugin requires a version of Dorado >= 7.3.9."
-                )
-
-        if sample_rate:
-            self.sample_rate = float(sample_rate)
-        else:
-            self.sample_rate = float(5000)
+            check_basecaller_compatibility(
+                self.run_information,
+                ge,
+                "7.3.9",
+                (
+                    "For Dorado >= 7.3.9, Try changing [caller_settings.guppy]"
+                    " to [caller_settings.dorado]."
+                ),
+            )
 
+        self.sample_rate = float(sample_rate) if sample_rate else float(5000)
         # Set our own priority
         self.dorado_params = kwargs
         self.dorado_params["priority"] = PyBasecallClient.high_priority
diff --git a/src/readfish/plugins/guppy.py b/src/readfish/plugins/guppy.py
index a79a6b24..decac3ea 100644
--- a/src/readfish/plugins/guppy.py
+++ b/src/readfish/plugins/guppy.py
@@ -7,10 +7,11 @@
 import logging
 import os
 import time
+from operator import lt
 from collections import namedtuple
 from pathlib import Path
 from typing import Iterable, TYPE_CHECKING
-from packaging.version import parse as parse_version
+from readfish.compatibility import check_basecaller_compatibility
 
 import numpy as np
 import numpy.typing as npt
@@ -56,30 +57,24 @@ def __getitem__(self, _):
 
 class Caller(CallerABC):
     def __init__(
-        self, run_information: ProtocolRunInfo = None, debug_log=None, **kwargs
+        self,
+        run_information: ProtocolRunInfo = None,
+        debug_log=None,
+        sample_rate: int | None = None,
+        **kwargs,
     ):
-        self.logger = setup_logger("readfish_guppy_logger", log_file=debug_log)
         self.supported_barcode_kits = None
         self.supported_basecall_models = None
         self.run_information = run_information
 
         if self.run_information:
-            self.guppy_version = self.run_information.software_versions.guppy_connected_version
-
-            if parse_version(self.guppy_version) < parse_version("7.3.9"):
-                logging.info(
-                    f"Connected to caller version {self.guppy_version}."
-                )
-            else:
-                raise RuntimeError(
-                    f"Connected to caller version {self.guppy_version}. This plugin requires a version of Dorado or Guppy < 7.3.9. Try changing [caller_settings.guppy] to [caller_settings.dorado]."
-                )
-
+            check_basecaller_compatibility(self.run_information, lt, "7.3.9")
         # Set our own priority
         self.guppy_params = kwargs
         self.guppy_params["priority"] = PyGuppyClient.high_priority
         # Set our own client name to appear in the guppy server logs
         self.guppy_params["client_name"] = "Readfish_connection"
+        self.logger = setup_logger("readfish_guppy_logger", log_file=debug_log)
         self.validate()
         self.caller = PyGuppyClient(**self.guppy_params)
         self.caller.connect()

From 246e69c96dabf2bba215c58e4a28f61ee20dc487 Mon Sep 17 00:00:00 2001
From: Adoni5 <roryjmunro1@gmail.com>
Date: Mon, 29 Apr 2024 14:07:14 +0100
Subject: [PATCH 04/12] Remove rogue comment

---
 src/readfish/__about__.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/readfish/__about__.py b/src/readfish/__about__.py
index b515e68f..24efc747 100644
--- a/src/readfish/__about__.py
+++ b/src/readfish/__about__.py
@@ -3,4 +3,3 @@
 """
 
 __version__ = "2024.0.0"
-# Warning is the last supported version of MinKNOW for this version of readfish

From 46a3d9efe7342055fc271efefa1ae71f33efe742 Mon Sep 17 00:00:00 2001
From: Adoni5 <roryjmunro1@gmail.com>
Date: Mon, 29 Apr 2024 14:13:50 +0100
Subject: [PATCH 05/12] edit insanely long string multiline string example fo
 sub tags

---
 src/readfish/plugins/dorado.py | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/src/readfish/plugins/dorado.py b/src/readfish/plugins/dorado.py
index d9dda87d..ce40bd7a 100644
--- a/src/readfish/plugins/dorado.py
+++ b/src/readfish/plugins/dorado.py
@@ -256,19 +256,26 @@ def basecall(
             for res_batch in results:
                 for res in res_batch:
                     read_id = res["metadata"]["read_id"]
-                    '''
-                    Dorado sometimes returns two sub_tags for a read.
+                    # Dorado sometimes returns two sub_tags for a read.
+
+                    # An example result:
+                    # RF-17774e44-8d3c-4bdd-8730-aaf8addd3e6c
+                    # {'read_tag': 3605, 'sub_tag': 0, ..,
+                    #   'metadata': {'sequence_length': 340, ...},
+                    #   'datasets': {'raw_data': array([306, 289, 300, ..., 526, 537, 540], dtype=int16),
+                    #   'sequence': 'CTACAGTGGTCGTCAATACTATTGCAACTCCAGCCTGGGCAACAGAGTGAGACCCTGTCTCAAAAAAAAACAGAAGGA...',
+                    #   ...}
+                    # }
+                    # RF-17774e44-8d3c-4bdd-8730-aaf8addd3e6c
+                    # {'read_tag': 3605, 'sub_tag': 1, ..,
+                    #   'metadata': {'sequence_length': 16, ...},
+                    #   'datasets': {'raw_data': array([306, 289, 300, ..., 526, 537, 540], dtype=int16),
+                    #   'sequence': 'TTTTTGTGGGCTTTTA',
+                    #   ...}
+                    # }
+                    # The second sub_tag will cause the code to fail as it is not expected and we have already popped the read from the cache.
+                    # Therefore we need to check for the sub_tag and if it is not 0, we need to skip the read.
 
-                    An example result:
-                    RF-17774e44-8d3c-4bdd-8730-aaf8addd3e6c
-                    {'read_tag': 3605, 'sub_tag': 0, 'priority': <read_priority.high_priority: 0>, 'metadata': {'adapter_front_begin_index': -1, 'adapter_front_foundseq': 'NA', 'adapter_front_foundseq_length': 2, 'adapter_front_id': 'NA', 'adapter_front_refseq': 'NA', 'adapter_front_score': 0.0, 'adapter_mid_end_index': -1, 'adapter_mid_id': 'NA', 'adapter_mid_score': 0.0, 'adapter_rear_end_index': -1, 'adapter_rear_foundseq': 'NA', 'adapter_rear_foundseq_length': 2, 'adapter_rear_id': 'NA', 'adapter_rear_refseq': 'NA', 'adapter_rear_score': 0.0, 'barcode_arrangement': '', 'barcode_front_begin_index': 0, 'barcode_front_foundseq': 'NA', 'barcode_front_foundseq_length': 2, 'barcode_front_id': 'NA', 'barcode_front_id_inner': 'NA', 'barcode_front_refseq': 'NA', 'barcode_front_score': 0.0, 'barcode_front_score_inner': 0.0, 'barcode_full_arrangement': '', 'barcode_kit': '', 'barcode_mid_front_end_index': 0, 'barcode_mid_front_id': 'NA', 'barcode_mid_front_score': 0.0, 'barcode_mid_rear_end_index': 0, 'barcode_mid_rear_id': 'NA', 'barcode_mid_rear_score': 0.0, 'barcode_rear_end_index': 0, 'barcode_rear_foundseq': 'NA', 'barcode_rear_foundseq_length': 2, 'barcode_rear_id': 'NA', 'barcode_rear_id_inner': 'NA', 'barcode_rear_refseq': 'NA', 'barcode_rear_score': 0.0, 'barcode_rear_score_inner': 0.0, 'barcode_score': 0.0, 'barcode_variant': '', 'basecall_type': 'beam search', 'daq_offset': 0.0, 'daq_scaling': 0.25, 'duration': 8592, 'lamp_barcode_id': 'NA', 'lamp_barcode_score': 0.0, 'lamp_target_id': 'NA', 'lamp_target_score': 0.0, 'mean_qscore': 10.297822952270508, 'med_abs_dev': 0.01067463681101799, 'median': -373.5199890136719, 'model_stride': 6, 'model_version_id': 'dna_r10.4.1_e8.2_400bps_fast@v4.3.0', 'num_events': 1432, 'num_minknow_events': 0, 'primer_front_begin_index': -1, 'primer_front_foundseq': 'NA', 'primer_front_foundseq_length': 2, 'primer_front_id': 'NA', 'primer_front_refseq': 'NA', 'primer_front_score': 0.0, 'primer_rear_end_index': -1, 'primer_rear_foundseq': 'NA', 'primer_rear_foundseq_length': 2, 'primer_rear_id': 'NA', 'primer_rear_refseq': 'NA', 'primer_rear_score': 0.0, 'read_id': 'RF-17774e44-8d3c-4bdd-8730-aaf8addd3e6c', 'sampling_rate': 5000.0, 'scaling_med_abs_dev': 0.01067463681101799, 'scaling_median': -373.5199890136719, 'scaling_version': '', 'sequence_length': 340, 'start_time': 12462912, 'state_size': 0, 'strand_id': '441174ae-e18f-4612-bc46-0c86d301cb4d', 'trim_front': 0, 'trim_rear': 0, 'trimmed_duration': 8592, 'trimmed_events': 1432, 'trimmed_samples': 0}, 'datasets': {'raw_data': array([306, 289, 300, ..., 526, 537, 540], dtype=int16), 'sequence': 'CTACAGTGGTCGTCAATACTATTGCAACTCCAGCCTGGGCAACAGAGTGAGACCCTGTCTCAAAAAAAAACAGAAGGAAGCCAAAGCCCACAAAGACGCTGAGTATTTTACATTCCTTTTTTGTACGAATGCTTCAAAATCTGGTGTGTATCTTACAGTTATAAAATCTCTCAATTTAGCCACCAAATTTTCACCAGAAATGCATGAACTGTGTTCAGATTTCATAAACTTTCAGTTGATAAAGTAGATTCACATACTGAAGGTGTTCCAAACGTACTGGAAGACTTTCTAAAATGGATTTGAACACCAGTTTCCAGGTTTACATTTAAGTTAATTCAAA', 'qstring': '#(&&%(\'\'%&(#"""$\'%%$%$%*,)+()\'(\'\'*+AEHHH.-0410)200BGC4HKJJGGB77<DC3-\'.,,+\'&&%%+*(*1-778:C76+,=A.,-./*)+##9:JSGGGHD6432,5>H(\'(+,1-(,//:3640==6504C><357>4448FAFCIGI64-/9660=12HISOBGKLA@?1/59EGM>:::DEJSOM1D?>=GI11775:930,;;>H9/7122)*0:**-===>B55878&#+"#&\',,?@EIJBCLSM964\'(376528:5/-*)21\'##+-&$"#%+&#&%\'-./49?B=A960@7;ABB@6CIEFDD>H7)&45:DC5158B'}}
-                    RF-17774e44-8d3c-4bdd-8730-aaf8addd3e6c
-                    {'read_tag': 3605, 'sub_tag': 1, 'priority': <read_priority.high_priority: 0>, 'metadata': {'adapter_front_begin_index': -1, 'adapter_front_foundseq': 'NA', 'adapter_front_foundseq_length': 2, 'adapter_front_id': 'NA', 'adapter_front_refseq': 'NA', 'adapter_front_score': 0.0, 'adapter_mid_end_index': -1, 'adapter_mid_id': 'NA', 'adapter_mid_score': 0.0, 'adapter_rear_end_index': -1, 'adapter_rear_foundseq': 'NA', 'adapter_rear_foundseq_length': 2, 'adapter_rear_id': 'NA', 'adapter_rear_refseq': 'NA', 'adapter_rear_score': 0.0, 'barcode_arrangement': '', 'barcode_front_begin_index': 0, 'barcode_front_foundseq': 'NA', 'barcode_front_foundseq_length': 2, 'barcode_front_id': 'NA', 'barcode_front_id_inner': 'NA', 'barcode_front_refseq': 'NA', 'barcode_front_score': 0.0, 'barcode_front_score_inner': 0.0, 'barcode_full_arrangement': '', 'barcode_kit': '', 'barcode_mid_front_end_index': 0, 'barcode_mid_front_id': 'NA', 'barcode_mid_front_score': 0.0, 'barcode_mid_rear_end_index': 0, 'barcode_mid_rear_id': 'NA', 'barcode_mid_rear_score': 0.0, 'barcode_rear_end_index': 0, 'barcode_rear_foundseq': 'NA', 'barcode_rear_foundseq_length': 2, 'barcode_rear_id': 'NA', 'barcode_rear_id_inner': 'NA', 'barcode_rear_refseq': 'NA', 'barcode_rear_score': 0.0, 'barcode_rear_score_inner': 0.0, 'barcode_score': 0.0, 'barcode_variant': '', 'basecall_type': 'beam search', 'daq_offset': 0.0, 'daq_scaling': 0.25, 'duration': 321, 'lamp_barcode_id': 'NA', 'lamp_barcode_score': 0.0, 'lamp_target_id': 'NA', 'lamp_target_score': 0.0, 'mean_qscore': 12.145367622375488, 'med_abs_dev': 0.01067463681101799, 'median': -373.5199890136719, 'model_stride': 6, 'model_version_id': 'dna_r10.4.1_e8.2_400bps_fast@v4.3.0', 'num_events': 53, 'num_minknow_events': 0, 'primer_front_begin_index': -1, 'primer_front_foundseq': 'NA', 'primer_front_foundseq_length': 2, 'primer_front_id': 'NA', 'primer_front_refseq': 'NA', 'primer_front_score': 0.0, 'primer_rear_end_index': -1, 'primer_rear_foundseq': 'NA', 'primer_rear_foundseq_length': 2, 'primer_rear_id': 'NA', 'primer_rear_refseq': 'NA', 'primer_rear_score': 0.0, 'read_id': 'RF-17774e44-8d3c-4bdd-8730-aaf8addd3e6c', 'sampling_rate': 5000.0, 'scaling_med_abs_dev': 0.01067463681101799, 'scaling_median': -373.5199890136719, 'scaling_version': '', 'sequence_length': 16, 'start_time': 12477610, 'state_size': 0, 'strand_id': '3b536c09-3f73-4c59-a332-2a0f6cad4ed9', 'trim_front': 0, 'trim_rear': 0, 'trimmed_duration': 321, 'trimmed_events': 53, 'trimmed_samples': 0}, 'datasets': {'raw_data': array([306, 289, 300, ..., 526, 537, 540], dtype=int16), 'sequence': 'TTTTTGTGGGCTTTTA', 'qstring': "21;;B98'-213,*2&"}}
-
-                    The second sub_tag will cause the code to gail as it is not expected.
-
-                    Therefore we need to check for the sub_tag and if it is not 0, we need to skip the read.
-                    '''
                     if res["sub_tag"] > 0:
                         continue
 

From d46b53b6f42f12a064ccb734f524954a0bc6f8a1 Mon Sep 17 00:00:00 2001
From: mattloose <matt.loose@nottingham.ac.uk>
Date: Tue, 30 Apr 2024 09:22:30 +0100
Subject: [PATCH 06/12] Local updates

---
 src/readfish/__about__.py                                | 6 +-----
 src/readfish/{__compatability__.py => _compatability.py} | 0
 src/readfish/_utils.py                                   | 4 ++--
 src/readfish/plugins/dorado.py                           | 2 +-
 src/readfish/plugins/guppy.py                            | 2 +-
 5 files changed, 5 insertions(+), 9 deletions(-)
 rename src/readfish/{__compatability__.py => _compatability.py} (100%)

diff --git a/src/readfish/__about__.py b/src/readfish/__about__.py
index 499bc028..d48c4ea9 100644
--- a/src/readfish/__about__.py
+++ b/src/readfish/__about__.py
@@ -3,8 +3,4 @@
 """
 
 __version__ = "2024.0.0"
-# Warning is the last supported version of MinKNOW for this version of readfish
-# Users running this version will receive the warning shown if they are running this version of readfish.
-__warning__ = [["5.9", f"Readfish {__version__} will not be supported in the next version of MinKNOW. Please update to the latest version of Readfish or do not update MinKNOW if you are concerned about version control."]]
-# Compatability is either the maximum or minimum version of MinKNOW that this version of readfish is compatible with.
-__compatability__ = [["6.0","lte"]]
+
diff --git a/src/readfish/__compatability__.py b/src/readfish/_compatability.py
similarity index 100%
rename from src/readfish/__compatability__.py
rename to src/readfish/_compatability.py
diff --git a/src/readfish/_utils.py b/src/readfish/_utils.py
index e0549b46..d4e92541 100644
--- a/src/readfish/_utils.py
+++ b/src/readfish/_utils.py
@@ -25,8 +25,8 @@
 
 from readfish._channels import FLONGLE_CHANNELS, MINION_CHANNELS
 from readfish.__about__ import __version__ as readfish_version
-from readfish.__compatability__ import __compatability__ as compatible_version
-from readfish.__compatability__ import __warning__ as warning_version
+from readfish._compatability import compatible_version
+from readfish._compatability import warning_version
 
 MODULE_LOGGER = logging.getLogger(__name__)
 
diff --git a/src/readfish/plugins/dorado.py b/src/readfish/plugins/dorado.py
index d35a40b0..a47df5cc 100644
--- a/src/readfish/plugins/dorado.py
+++ b/src/readfish/plugins/dorado.py
@@ -76,7 +76,7 @@ def __init__(
                 )
             else:
                 raise RuntimeError(
-                    f"Connected to caller version {self.guppy_version}. This plugin requires a version of Dorado >= 7.3.9."
+                    f"Trying to use caller version {self.guppy_version}. This plugin requires a version of Dorado >= 7.3.9."
                 )
 
         if sample_rate:
diff --git a/src/readfish/plugins/guppy.py b/src/readfish/plugins/guppy.py
index a79a6b24..f4dd3f5d 100644
--- a/src/readfish/plugins/guppy.py
+++ b/src/readfish/plugins/guppy.py
@@ -72,7 +72,7 @@ def __init__(
                 )
             else:
                 raise RuntimeError(
-                    f"Connected to caller version {self.guppy_version}. This plugin requires a version of Dorado or Guppy < 7.3.9. Try changing [caller_settings.guppy] to [caller_settings.dorado]."
+                    f"Trying to connect to caller version {self.guppy_version}. This plugin requires a version of Dorado or Guppy < 7.3.9. Try changing [caller_settings.guppy] to [caller_settings.dorado]."
                 )
 
         # Set our own priority

From 3571012059075d0a8a0861c583ae5a985778c45e Mon Sep 17 00:00:00 2001
From: mattloose <matt.loose@nottingham.ac.uk>
Date: Fri, 3 May 2024 11:51:04 +0100
Subject: [PATCH 07/12] Error checking and minor corrections to address
 compatibility. We no longer raiseException when a version issue is
 encountered. This means that readfish will continue to function with future
 versions of minKNOW if compatible.

---
 src/readfish/__about__.py             |  1 -
 src/readfish/_compatibility.py        |  5 +--
 src/readfish/_utils.py                | 45 +--------------------------
 src/readfish/entry_points/validate.py |  8 +++--
 src/readfish/plugins/dorado.py        |  8 ++---
 src/readfish/plugins/guppy.py         | 13 +++-----
 6 files changed, 19 insertions(+), 61 deletions(-)

diff --git a/src/readfish/__about__.py b/src/readfish/__about__.py
index d48c4ea9..24efc747 100644
--- a/src/readfish/__about__.py
+++ b/src/readfish/__about__.py
@@ -3,4 +3,3 @@
 """
 
 __version__ = "2024.0.0"
-
diff --git a/src/readfish/_compatibility.py b/src/readfish/_compatibility.py
index d35422be..314e1d57 100644
--- a/src/readfish/_compatibility.py
+++ b/src/readfish/_compatibility.py
@@ -8,7 +8,6 @@
 
 """
 
-from readfish.__about__ import __version__
 from minknow_api.manager import Manager
 from packaging.version import parse as parse_version
 from packaging.version import Version
@@ -78,7 +77,9 @@ def check_compatibility(
     )
 
 
-def check_basecaller_compatibility(run_information: ProtocolRunInfo, op, version: str, extra_error: str = None):
+def check_basecaller_compatibility(
+    run_information: ProtocolRunInfo, op, version: str, extra_error: str = None
+):
     symbol = {
         operator.lt: "<",
         operator.gt: ">",
diff --git a/src/readfish/_utils.py b/src/readfish/_utils.py
index 529c8d6c..458584e9 100644
--- a/src/readfish/_utils.py
+++ b/src/readfish/_utils.py
@@ -10,7 +10,6 @@
 from enum import IntEnum
 import re
 import base64
-from packaging.version import parse as parse_version
 from typing import Any, Mapping, Sequence
 import zlib
 
@@ -24,7 +23,7 @@
     from exceptiongroup import BaseExceptionGroup
 
 from readfish._channels import FLONGLE_CHANNELS, MINION_CHANNELS
-from readfish.__about__ import __version__ as readfish_version
+
 
 MODULE_LOGGER = logging.getLogger(__name__)
 
@@ -451,48 +450,6 @@ def get_device(
             return position
     raise ValueError(f"Could not find device {device!r}")
 
-def get_version(
-        host: str = "127.0.0.1", port: int = None, logger: logging.Logger = None
-) -> str:
-    """Get the version of MinKNOW
-
-    :param host: The host the RPC is listening on, defaults to "127.0.0.1"
-    :param port: The port the RPC is listening on, defaults to None
-    :raises ValueError: If the version of Readfish is incompatible with the version of MinKNOW.
-    :raises Warning: If the version of Readfish may need to be updated soon.
-    :return: The version of MinKNOW
-    """
-    manager = Manager(host=host, port=port)
-    minknow_version = parse_version(manager.core_version)
-    # Check compatability
-    for cv, direction in compatible_version:
-        ver_cv = parse_version(cv)
-        if direction == "gte":
-            if minknow_version <= ver_cv:
-                raise ValueError(
-                    f"Compatability check failed. Readfish version {readfish_version} is not compatible with MinKNOW version {minknow_version}. You need to update readfish."
-                )
-        elif direction == "lte":
-            if minknow_version >= ver_cv:
-                raise ValueError(
-                    f"Compatability check failed. Readfish version {readfish_version} is not compatible with MinKNOW version {minknow_version}. You need to downgrade readfish."
-                )
-    for wv, message in warning_version:
-        warn = False
-        ver_wv = parse_version(wv)
-        if ver_wv.major == minknow_version.major:
-            if ver_wv.minor == minknow_version.minor:
-                if ver_wv.micro == minknow_version.micro:
-                    warn=True
-                else:
-                    warn=True
-            else:
-                warn=True
-        if warn:
-            logger.info(
-                f"Warning: {message}"
-            )
-    return None
 
 if __name__ == "__main__":
     import doctest
diff --git a/src/readfish/entry_points/validate.py b/src/readfish/entry_points/validate.py
index eabd9942..f98cc0ea 100644
--- a/src/readfish/entry_points/validate.py
+++ b/src/readfish/entry_points/validate.py
@@ -82,8 +82,12 @@ def run(parser, args, extras) -> int:
             _ = conf.caller_settings.load_object("Caller")
         except Exception as exc:
             logger.error("Caller could not be initialised.")
-            logger.error("Possible reasons for this include a mismatch between the ont basecaller client and the versions of guppy or dorado you are connecting to.")
-            logger.error("Additional information is available here: https://looselab.github.io/readfish/FAQ.html#connection-error-bad-reply-could-not-interpret-message-from-server-for-request-load-config-reply-invalid-protocol")
+            logger.error(
+                "Possible reasons for this include a mismatch between the ont basecaller client and the versions of guppy or dorado you are connecting to."
+            )
+            logger.error(
+                "Additional information is available here: https://looselab.github.io/readfish/FAQ.html#connection-error-bad-reply-could-not-interpret-message-from-server-for-request-load-config-reply-invalid-protocol"
+            )
             logger.error("See below for further details on this specific error.")
             logger.error(str(exc))
             errors += 1
diff --git a/src/readfish/plugins/dorado.py b/src/readfish/plugins/dorado.py
index 9950127f..aa4f6802 100644
--- a/src/readfish/plugins/dorado.py
+++ b/src/readfish/plugins/dorado.py
@@ -68,12 +68,12 @@ def __init__(
         self.supported_basecall_models = None
         self.run_information = run_information
         if self.run_information:
-            self.guppy_version = self.run_information.software_versions.guppy_connected_version
+            self.guppy_version = (
+                self.run_information.software_versions.guppy_connected_version
+            )
 
             if parse_version(self.guppy_version) >= parse_version("7.3.9"):
-                logging.info(
-                    f"Connected to caller version {self.guppy_version}."
-                )
+                logging.info(f"Connected to caller version {self.guppy_version}.")
             else:
                 logging.info(
                     f"Trying to use minKNOW with a caller version {self.guppy_version}. If this is causing readfish to crash, try using a version of Dorado >= 7.3.9. You should also check for any updates available to readfish."
diff --git a/src/readfish/plugins/guppy.py b/src/readfish/plugins/guppy.py
index c8c7e730..7d2cadca 100644
--- a/src/readfish/plugins/guppy.py
+++ b/src/readfish/plugins/guppy.py
@@ -56,10 +56,7 @@ def __getitem__(self, _):
 
 class Caller(CallerABC):
     def __init__(
-        self,
-        run_information: ProtocolRunInfo = None,
-        debug_log=None,
-        **kwargs
+        self, run_information: ProtocolRunInfo = None, debug_log=None, **kwargs
     ):
         self.logger = setup_logger("readfish_guppy_logger", log_file=debug_log)
         self.supported_barcode_kits = None
@@ -67,12 +64,12 @@ def __init__(
         self.run_information = run_information
 
         if self.run_information:
-            self.guppy_version = self.run_information.software_versions.guppy_connected_version
+            self.guppy_version = (
+                self.run_information.software_versions.guppy_connected_version
+            )
 
             if parse_version(self.guppy_version) < parse_version("7.3.9"):
-                logging.info(
-                    f"Connected to caller version {self.guppy_version}."
-                )
+                logging.info(f"Connected to caller version {self.guppy_version}.")
             else:
                 logging.info(
                     f"Trying to connect to minKNOW with caller version {self.guppy_version}. This plugin requires a version of Dorado or Guppy < 7.3.9. If this is stopping readfish from running try changing [caller_settings.guppy] to [caller_settings.dorado]. You should also check for any updates available to readfish."

From d56042aa2982beeec8c07e99ba24b3a85e4ad32a Mon Sep 17 00:00:00 2001
From: Adoni5 <roryjmunro1@gmail.com>
Date: Tue, 7 May 2024 11:11:20 +0100
Subject: [PATCH 08/12] Add default when popping `sample_rate` from guppy
 params Prevents `KeyError` from being raised if `sample_rate`isn't listed as
 a `kwarg`

---
 src/readfish/plugins/guppy.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/readfish/plugins/guppy.py b/src/readfish/plugins/guppy.py
index 7d2cadca..de9f5fde 100644
--- a/src/readfish/plugins/guppy.py
+++ b/src/readfish/plugins/guppy.py
@@ -79,7 +79,7 @@ def __init__(
         self.guppy_params = kwargs
 
         # Remove the sample rate from the guppy params as it isn't required for the PyGuppyClient
-        self.guppy_params.pop("sample_rate")
+        self.guppy_params.pop("sample_rate", None)
         self.guppy_params["priority"] = PyGuppyClient.high_priority
         # Set our own client name to appear in the guppy server logs
         self.guppy_params["client_name"] = "Readfish_connection"

From 6cb85e3d0cd9252c3141e11d4053f872a03b3af8 Mon Sep 17 00:00:00 2001
From: Adoni5 <roryjmunro1@gmail.com>
Date: Tue, 7 May 2024 11:16:16 +0100
Subject: [PATCH 09/12] Remove unused basecaller compatibilty function We now
 just check in `dorado.py` and warn if there is a mismatch

---
 src/readfish/_compatibility.py | 22 ----------------------
 1 file changed, 22 deletions(-)

diff --git a/src/readfish/_compatibility.py b/src/readfish/_compatibility.py
index 314e1d57..afe39276 100644
--- a/src/readfish/_compatibility.py
+++ b/src/readfish/_compatibility.py
@@ -11,10 +11,7 @@
 from minknow_api.manager import Manager
 from packaging.version import parse as parse_version
 from packaging.version import Version
-from minknow_api.protocol_pb2 import ProtocolRunInfo
 from enum import Enum
-import operator
-
 
 LATEST_TESTED = "5.9.7"
 
@@ -75,22 +72,3 @@ def check_compatibility(
         if comparator <= highest_supported_version
         else (False, DIRECTION.UPGRADE)
     )
-
-
-def check_basecaller_compatibility(
-    run_information: ProtocolRunInfo, op, version: str, extra_error: str = None
-):
-    symbol = {
-        operator.lt: "<",
-        operator.gt: ">",
-        operator.le: "<=",
-        operator.ge: ">=",
-        operator.eq: "==",
-        operator.ne: "!=",
-    }
-    guppy_version = run_information.software_versions.guppy_connected_version
-    if not op(parse_version(guppy_version), parse_version(version)):
-        extra_error = extra_error if extra_error is not None else ""
-        raise RuntimeError(
-            f"Cannot connect to base-caller {guppy_version}. This plugin requires a version of Dorado or Guppy {symbol[op]} {version}. {extra_error}"
-        )

From dc6644cef7bf9acfcba3889fa5b7490b23c7240a Mon Sep 17 00:00:00 2001
From: Adoni5 <roryjmunro1@gmail.com>
Date: Tue, 7 May 2024 11:28:55 +0100
Subject: [PATCH 10/12] Correct docstring, add doctests

---
 src/readfish/_compatibility.py | 29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/src/readfish/_compatibility.py b/src/readfish/_compatibility.py
index afe39276..8cd9bc67 100644
--- a/src/readfish/_compatibility.py
+++ b/src/readfish/_compatibility.py
@@ -1,11 +1,14 @@
 """_compatibility.py
 
-Contains utilities for checking readfish compatibility with various versions of MinKNOW and Dorado.
-
-Throws a warning for the last supported version of MinKNOW for this version of readfish
+Contains utilities for checking readfish compatibility with various versions of MinKNOW.
 
 Checks ranges of `readfish` against the `MinKNOW` version
 
+Attributes:
+    LATEST_TESTED (str): The latest tested version of MinKNOW.
+    MINKNOW_COMPATIBILITY_RANGE (tuple): The compatibility range of MinKNOW versions for this version of readfish.
+    DIRECTION (Enum): An enumeration representing upgrade, downgrade, or no change directions.
+
 """
 
 from minknow_api.manager import Manager
@@ -16,7 +19,7 @@
 LATEST_TESTED = "5.9.7"
 
 # The versions of MinKNOW which this version of readfish can connect to
-# Format - (lowest minknow, version of minknow not supported as an upper bound)
+# Format - (lowest minknow version, highest version of minknow supported as an upper bound)
 MINKNOW_COMPATIBILITY_RANGE = (
     Version("5.0.0"),
     Version(LATEST_TESTED),
@@ -50,13 +53,25 @@ def _get_minknow_version(host: str = "127.0.0.1", port: int = None) -> Version:
 
 def check_compatibility(
     comparator: Version,
-    version_range: tuple[Version, Version],
-) -> bool:
+    version_range: tuple[Version, Version] = MINKNOW_COMPATIBILITY_RANGE,
+) -> tuple[bool, DIRECTION]:
     """
-    Check the compatibility of a given software version, between a given range.
+    Check the compatibility of a given software version, between a given range,
+    inclusive of the right edge.
 
     :param comparator: Version of the provided software, for example MinKNOW 5.9.7
     :param version_ranges: A tuple of lowest supported version, highest supported version
+
+    :return: A tuple containing a boolean indicating compatibility and a upgrade direction enum.
+
+    Examples:
+    >>> from packaging.version import Version
+    >>> check_compatibility(Version("5.9.5"), (Version("5.0.0"), Version("5.9.7")))
+    (True, <DIRECTION.JUST_RIGHT: 'do nothing'>)
+    >>> check_compatibility(Version("5.9.8"), (Version("5.0.0"), Version("5.9.7")))
+    (False, <DIRECTION.UPGRADE: 'upgrade'>)
+    >>> check_compatibility(Version("4.9.0"), (Version("5.0.0"), Version("5.9.7")))
+    (False, <DIRECTION.DOWNGRADE: 'downgrade'>)
     """
     (
         lowest_supported_version,

From aaebfca828bdc24cc27dcacf3cb68c35753ed67a Mon Sep 17 00:00:00 2001
From: Adoni5 <roryjmunro1@gmail.com>
Date: Tue, 7 May 2024 16:51:09 +0100
Subject: [PATCH 11/12] Add more complete docstring to `DIRECTION` enum Only
 return Enum variant from `check_compatibility`, not tuple of (bool, variant)

---
 src/readfish/_compatibility.py       | 37 ++++++++++++++++++----------
 src/readfish/entry_points/targets.py | 12 ++++++---
 2 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/src/readfish/_compatibility.py b/src/readfish/_compatibility.py
index 8cd9bc67..e7e30ba2 100644
--- a/src/readfish/_compatibility.py
+++ b/src/readfish/_compatibility.py
@@ -28,8 +28,14 @@
 
 class DIRECTION(Enum):
     """
-    Upgrade, downgrade or just right
-
+    Represents the direction in which the version of the readfish software should be changed
+    to be compatible with the tested version of an external tool (likely MinKNOW).
+
+    Attributes:
+        UPGRADE: Indicates that the readfish software version should be upgraded.
+        DOWNGRADE: Indicates that the readfish software version should be downgraded.
+        JUST_RIGHT: Indicates that the readfish software version is already compatible
+                     with the tested version of the external tool.
     """
 
     UPGRADE = "upgrade"
@@ -54,7 +60,7 @@ def _get_minknow_version(host: str = "127.0.0.1", port: int = None) -> Version:
 def check_compatibility(
     comparator: Version,
     version_range: tuple[Version, Version] = MINKNOW_COMPATIBILITY_RANGE,
-) -> tuple[bool, DIRECTION]:
+) -> DIRECTION:
     """
     Check the compatibility of a given software version, between a given range,
     inclusive of the right edge.
@@ -62,28 +68,33 @@ def check_compatibility(
     :param comparator: Version of the provided software, for example MinKNOW 5.9.7
     :param version_ranges: A tuple of lowest supported version, highest supported version
 
-    :return: A tuple containing a boolean indicating compatibility and a upgrade direction enum.
+    :return: A direction variant indicating if this version of readfish needs to be changed.
 
     Examples:
     >>> from packaging.version import Version
     >>> check_compatibility(Version("5.9.5"), (Version("5.0.0"), Version("5.9.7")))
-    (True, <DIRECTION.JUST_RIGHT: 'do nothing'>)
+    <DIRECTION.JUST_RIGHT: 'do nothing'>
+    >>> check_compatibility(Version("5.9.7"), (Version("5.0.0"), Version("5.9.7")))
+    <DIRECTION.JUST_RIGHT: 'do nothing'>
     >>> check_compatibility(Version("5.9.8"), (Version("5.0.0"), Version("5.9.7")))
-    (False, <DIRECTION.UPGRADE: 'upgrade'>)
+    <DIRECTION.UPGRADE: 'upgrade'>
     >>> check_compatibility(Version("4.9.0"), (Version("5.0.0"), Version("5.9.7")))
-    (False, <DIRECTION.DOWNGRADE: 'downgrade'>)
+    <DIRECTION.DOWNGRADE: 'downgrade'>
+    >>> if (action := check_compatibility(Version("6.0.0"), MINKNOW_COMPATIBILITY_RANGE)) in (
+    ...     DIRECTION.UPGRADE,
+    ...     DIRECTION.DOWNGRADE,
+    ... ):
+    ...     action
+    <DIRECTION.UPGRADE: 'upgrade'>
     """
     (
         lowest_supported_version,
         highest_supported_version,
     ) = version_range
     if comparator < lowest_supported_version:
-        return (
-            False,
-            DIRECTION.DOWNGRADE,
-        )
+        return DIRECTION.DOWNGRADE
     return (
-        (True, DIRECTION.JUST_RIGHT)
+        DIRECTION.JUST_RIGHT
         if comparator <= highest_supported_version
-        else (False, DIRECTION.UPGRADE)
+        else DIRECTION.UPGRADE
     )
diff --git a/src/readfish/entry_points/targets.py b/src/readfish/entry_points/targets.py
index 33287c38..f45ccbb8 100644
--- a/src/readfish/entry_points/targets.py
+++ b/src/readfish/entry_points/targets.py
@@ -91,6 +91,7 @@
     _get_minknow_version,
     check_compatibility,
     MINKNOW_COMPATIBILITY_RANGE,
+    DIRECTION,
 )
 from readfish._utils import (
     get_device,
@@ -494,12 +495,17 @@ def run(
     # Check MinKNOW version
 
     minknow_version = _get_minknow_version(host=args.host, port=args.port)
-    if not (
+    if (
         action := check_compatibility(minknow_version, MINKNOW_COMPATIBILITY_RANGE)
-    )[0]:
+    ) in (
+        DIRECTION.UPGRADE,
+        DIRECTION.DOWNGRADE,
+    ):
         lower_bound, upper_bound = MINKNOW_COMPATIBILITY_RANGE
         logger.warning(
-            f"This readfish version ({__version__}) is tested for compatibility with MinKNOW v{lower_bound} to v{upper_bound}. This version of minknow is {minknow_version}. If readfish fails please try to {action[1].value} readfish."
+            f"This readfish version ({__version__}) is tested for compatibility with MinKNOW v{lower_bound} to v{upper_bound}. "
+            f"This version of minknow is {minknow_version}. "
+            f"If readfish fails please try to {action.value} readfish."
         )
 
     # Fetch sequencing device

From 8fec91ee0559aa6e66e4c0ded3c9eb83255b1c3d Mon Sep 17 00:00:00 2001
From: Adoni5 <roryjmunro1@gmail.com>
Date: Tue, 7 May 2024 17:13:51 +0100
Subject: [PATCH 12/12] Suggest opening an issue if a suitable version of
 readfish doesn't exist

---
 src/readfish/entry_points/targets.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/readfish/entry_points/targets.py b/src/readfish/entry_points/targets.py
index f45ccbb8..5ea96c3d 100644
--- a/src/readfish/entry_points/targets.py
+++ b/src/readfish/entry_points/targets.py
@@ -503,9 +503,11 @@ def run(
     ):
         lower_bound, upper_bound = MINKNOW_COMPATIBILITY_RANGE
         logger.warning(
-            f"This readfish version ({__version__}) is tested for compatibility with MinKNOW v{lower_bound} to v{upper_bound}. "
-            f"This version of minknow is {minknow_version}. "
-            f"If readfish fails please try to {action.value} readfish."
+            f"""This readfish version ({__version__}) is tested for compatibility with MinKNOW v{lower_bound} to v{upper_bound}.
+This version of minknow is {minknow_version}.
+If readfish fails please try to {action.value} readfish.
+If there isn't a newer version of readfish and readfish is failing, please open an issue:
+    https://github.com/LooseLab/readfish/issues"""
         )
 
     # Fetch sequencing device
