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

[pipelines] Convert SDCard to ABC and Pipeline system Vol. 2 #90

Draft
wants to merge 8 commits into
base: pipeline
Choose a base branch
from
28 changes: 28 additions & 0 deletions mio/data/config/wirefree/wirefree-pipeline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
id: wirefree-pipeline
mio_model: mio.devices.wirefree.WireFreePipeline
mio_version: v0.6.0

nodes:
sdcard:
type: "sd-file-source"
config:
layout: "wirefree-sd-layout"
passed:
path: sd_path
outputs:
- source: header
target: merge.header
- source: buffer
target: merge.buffer
merge:
type: "merge-buffers"
fill:
width: file.width
height: file.height
outputs:
- source: frame
target: return
return:
config:
key: frame
type: "return"
5 changes: 5 additions & 0 deletions mio/data/config/wirefree/wirefree.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
id: wirefree-default
mio_model: mio.devices.wirefree.WireFreeConfig
mio_version: 0.6.1
pipeline: wirefree-pipeline
layout: wirefree-sd-layout
39 changes: 17 additions & 22 deletions mio/devices/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,40 @@
ABC for
"""

import sys
from abc import abstractmethod
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any, Optional, Union
from typing import TYPE_CHECKING, Any, Optional

from mio.models import MiniscopeConfig, Pipeline, PipelineConfig
from mio.models import MiniscopeConfig, Pipeline, PipelineConfig, PipelineMixin
from mio.models.mixins import ConfigYAMLMixin

if TYPE_CHECKING:
from mio.models.pipeline import Sink, Source, Transform

if sys.version_info < (3, 11):
from typing_extensions import Self
else:
from typing import Self

class DeviceConfig(MiniscopeConfig):

class DeviceConfig(MiniscopeConfig, ConfigYAMLMixin):
"""
Abstract base class for device configuration
"""

id: Union[str, int]
"""(Locally) unique identifier for this device"""
pipeline: PipelineConfig = PipelineConfig()


@dataclass(kw_only=True)
class Device:
class Device(PipelineMixin):
"""
Abstract base class for devices.

Currently a placeholder to allow room for expansion/renaming in the future
"""

pipeline: Optional[Pipeline] = None
# config: Optional[DeviceConfig] = None
config: Optional[DeviceConfig] = None

@abstractmethod
def init(self) -> None:
Expand Down Expand Up @@ -126,17 +130,8 @@ def set(self, key: str, value: Any) -> None:
key (str): The name of the value to get
"""

@property
def sources(self) -> dict[str, "Source"]:
"""Convenience method to access :attr:`.Pipeline.sources`"""
return self.pipeline.sources

@property
def transforms(self) -> dict[str, "Transform"]:
"""Convenience method to access :attr:`.Pipeline.transforms`"""
return self.pipeline.transforms

@property
def sinks(self) -> dict[str, "Sink"]:
"""Convenience method to access :attr:`.Pipeline.sinks`"""
return self.pipeline.sinks
@classmethod
def from_config(cls, config: DeviceConfig) -> Self:
"""
Instantiate a device from its (yaml) configuration.
"""
Loading
Loading