Skip to content
Snippets Groups Projects
Commit 9e9728d2 authored by Hannes Feldt's avatar Hannes Feldt
Browse files

fix linting

parent f98493ab
No related branches found
No related tags found
1 merge request!89L2SS-1740: Move modules to prepare for statistics metadata
Pipeline #81932 passed
# Copyright (C) 2023 ASTRON (Netherlands Institute for Radio Astronomy) # Copyright (C) 2024 ASTRON (Netherlands Institute for Radio Astronomy)
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
""" """
General utils General utils
""" """
from typing import Optional, Type, get_type_hints from typing import Optional, Type, get_type_hints, get_args, get_origin
from numpy import ndarray from numpy import ndarray
from ._compat_utils import get_args, get_origin
from ._monitoring import MonitoredWrapper from ._monitoring import MonitoredWrapper
......
# Copyright (C) 2022 ASTRON (Netherlands Institute for Radio Astronomy) # Copyright (C) 2024 ASTRON (Netherlands Institute for Radio Astronomy)
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
""" """
...@@ -6,11 +6,11 @@ Utils to handle transformation of HDF5 specific classes to pythonic objects ...@@ -6,11 +6,11 @@ Utils to handle transformation of HDF5 specific classes to pythonic objects
""" """
import inspect import inspect
from collections.abc import MutableMapping from collections.abc import MutableMapping
from typing import Type, TypeVar from typing import Type, TypeVar, get_origin
from numpy import ndarray from numpy import ndarray
from .._compat_utils import get_origin, get_annotations from .._compat_utils import get_annotations
T = TypeVar("T") T = TypeVar("T")
......
# Copyright (C) 2023 ASTRON (Netherlands Institute for Radio Astronomy) # Copyright (C) 2024 ASTRON (Netherlands Institute for Radio Astronomy)
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
""" """
...@@ -7,7 +7,7 @@ Contains classes to handle file reading ...@@ -7,7 +7,7 @@ Contains classes to handle file reading
import inspect import inspect
import weakref import weakref
from inspect import getattr_static from inspect import getattr_static
from typing import TypeVar, Type, List, Dict from typing import TypeVar, Type, List, Dict, get_origin
import h5py import h5py
from numpy import ndarray, zeros from numpy import ndarray, zeros
...@@ -17,7 +17,6 @@ from ._hdf5_utils import ( ...@@ -17,7 +17,6 @@ from ._hdf5_utils import (
_assert_is_dataset, _assert_is_dataset,
) )
from .._attribute_def import AttributeDef from .._attribute_def import AttributeDef
from .._compat_utils import get_origin
from .._lazy_dict import lazy_dict from .._lazy_dict import lazy_dict
from .._member_def import MemberDef from .._member_def import MemberDef
from .._readers import FileReader, DataReader from .._readers import FileReader, DataReader
...@@ -169,7 +168,7 @@ class HdfDataReader(DataReader): ...@@ -169,7 +168,7 @@ class HdfDataReader(DataReader):
reader = cls.detect_reader(target_type, data_reader) reader = cls.detect_reader(target_type, data_reader)
result = lazy_dict(dict_type, lambda k: reader(value[k])) result = lazy_dict(dict_type, lambda k: reader(value[k]))
for k in value.keys(): for k in value.keys():
result[k] = lambda k=k: reader(value[k]) result[k] = lambda n=k: reader(value[n])
if dict_type is not dict: if dict_type is not dict:
setattr(result, "_data_reader", cls(data_reader.file_reader, value)) setattr(result, "_data_reader", cls(data_reader.file_reader, value))
return result return result
......
# Copyright (C) 2023 ASTRON (Netherlands Institute for Radio Astronomy) # Copyright (C) 2024 ASTRON (Netherlands Institute for Radio Astronomy)
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
""" """
Contains classes to handle file writing Contains classes to handle file writing
""" """
from inspect import getattr_static from inspect import getattr_static
from typing import TypeVar, Type, Dict from typing import TypeVar, Type, Dict, get_origin
import h5py import h5py
from numpy import ndarray from numpy import ndarray
...@@ -17,7 +17,6 @@ from ._hdf5_utils import ( ...@@ -17,7 +17,6 @@ from ._hdf5_utils import (
_assert_is_dataset, _assert_is_dataset,
) )
from ._hdf_readers import HdfFileReader, HdfDataReader from ._hdf_readers import HdfFileReader, HdfDataReader
from .._compat_utils import get_origin
from .._lazy_dict import LazyDict from .._lazy_dict import LazyDict
from .._utils import _wrap, _extract_base_type from .._utils import _wrap, _extract_base_type
from .._writers import FileWriter, DataWriter from .._writers import FileWriter, DataWriter
......
...@@ -16,15 +16,13 @@ class ZeroMQReceiver: ...@@ -16,15 +16,13 @@ class ZeroMQReceiver:
"""ZeroMQ Receiver""" """ZeroMQ Receiver"""
def __init__(self, uri: str): def __init__(self, uri: str):
o = urlsplit(uri) o = urlsplit(uri)
self._ctx: zmq.Context = zmq.Context.instance()
self._subscriber: zmq.Socket = self._ctx.socket(zmq.SUB)
self._topic: bytes = o.path.strip("/").encode()
self._subscriber.connect(f"{o.scheme}://{o.netloc}") self._topic: bytes = o.path.strip("/").encode()
self._subscriber.setsockopt(zmq.SUBSCRIBE, self._topic) self._uri = f"{o.scheme}://{o.netloc}"
self._content_type = "application/octet-stream" self._content_type = "application/octet-stream"
self._ctx: zmq.Context = zmq.Context.instance()
self._subscriber: zmq.Socket = self._ctx.socket(zmq.SUB)
qs = parse_qs(o.query) qs = parse_qs(o.query)
if "content-type" in qs: if "content-type" in qs:
...@@ -34,6 +32,8 @@ class ZeroMQReceiver: ...@@ -34,6 +32,8 @@ class ZeroMQReceiver:
def __iter__(self): def __iter__(self):
"""Iterates over all packets in the stream.""" """Iterates over all packets in the stream."""
self._subscriber.connect(self._uri)
self._subscriber.setsockopt(zmq.SUBSCRIBE, self._topic)
return self return self
def __next__(self) -> Union[str, dict, bytes]: def __next__(self) -> Union[str, dict, bytes]:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment