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

Feature/check minknow #351

Merged
merged 13 commits into from
May 7, 2024
Merged
5 changes: 5 additions & 0 deletions src/readfish/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
"""

__version__ = "2024.0.0"
# Warning is the last supported version of MinKNOW for this version of readfish
Adoni5 marked this conversation as resolved.
Show resolved Hide resolved
# 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"]]
11 changes: 11 additions & 0 deletions src/readfish/__compatability__.py
Adoni5 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -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"]]
48 changes: 47 additions & 1 deletion src/readfish/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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__)

Expand Down Expand Up @@ -449,6 +453,48 @@ def get_device(
return position
raise ValueError(f"Could not find device {device!r}")

def get_version(
Adoni5 marked this conversation as resolved.
Show resolved Hide resolved
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:
Adoni5 marked this conversation as resolved.
Show resolved Hide resolved
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."
)
Adoni5 marked this conversation as resolved.
Show resolved Hide resolved
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
Adoni5 marked this conversation as resolved.
Show resolved Hide resolved

if __name__ == "__main__":
import doctest
Expand Down
5 changes: 5 additions & 0 deletions src/readfish/entry_points/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
from readfish._statistics import ReadfishStatistics
from readfish._utils import (
get_device,
get_version,
send_message,
ChunkTracker,
Severity,
Expand Down Expand Up @@ -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)

Expand Down
13 changes: 13 additions & 0 deletions src/readfish/plugins/dorado.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."
Adoni5 marked this conversation as resolved.
Show resolved Hide resolved
)

if sample_rate:
self.sample_rate = float(sample_rate)
else:
Expand Down
13 changes: 13 additions & 0 deletions src/readfish/plugins/guppy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -62,6 +63,18 @@ def __init__(
self.supported_basecall_models = None
self.run_information = run_information

if self.run_information:
Adoni5 marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down