Skip to content
Snippets Groups Projects

Refactoring of arbiter to add flexibility and to allow reuse kernels

Merged Egor Sobolev requested to merge feat/multi-kernels-in-arbiter into master
Files
15
import enum
import numpy as np
class KernelWarning(enum.Enum):
INIT = "init"
MISSINGSOURCE = "missingsource"
MISSINGKEY = "missingkey"
PROCESSING = "processing"
PRESELECTION = "preselection"
class BaseArbiterKernel:
def __init__(self, config):
"""No need for prefix - hosting device should pass us the relevant subnode"""
self._config = config
self._device = None
def __init__(self, device, name, config):
self._device = device
self._name = name
self.reconfigure(config)
@property
def geometry(self):
return self._device._geometry
def warning_context(self, warn_type):
return self._device.warning_context("frameSelection.kernelState", warn_type)
@staticmethod
def extend_device_schema(schema, prefix):
"""Should add configurability to the arbiter (matcher) the kernel will be
running in. Prefix will include node name, so will typically be
"frameSelection.kernels.{class.__name__}". The parent node will not have been
created already (unlike for correction addons)."""
"frameSelection.kernels.{class.__name__}". The parent node will have been
created already (unlike for correction addons), feel free to overwrite the
description."""
pass
@staticmethod
def extend_output_schema(schema, name):
pass
def consider(self, train_id, sources, num_frames):
def consider(self, train_id, sources, num_frames, mask, out_hash):
"""Must return tuple of uint8 mask array of size equal to num_frames
and base output hash or None."""
return np.ones(num_frames, dtype=np.uint8), None
raise NotImplementedError()
def reconfigure(self, config):
pass
class Assign(BaseArbiterKernel):
def consider(self, tid, src, nframes, mask, out):
return mask
Loading