Exemplo n.º 1
0
"""This module defines messages passed between tasks in a pipeline."""

import json
from six import add_metaclass

from gaia.core.base import GaiaObject
from gaia.core.factory import create_registry


MessageRegistry = create_registry()


@add_metaclass(MessageRegistry)
class Message(GaiaObject, dict):

    """Define an inter-type message specification.

    A message is an arbitrary "dict"-like object used to pass information
    from one task to another.  Subclasses of this class will be added to the
    message registry to provide standard communication models.  For example,
    a slicing message type can be created to tell a file reader that only
    a subset of the full data is needed.  The slice message can be handled
    tasks individually to optimize the pipeline globally.
    """

    pass


class JSONMessage(Message):

    """Define a JSON serializable message.
Exemplo n.º 2
0
"""This module defines a data stream that flows through a pipeline."""

from six import add_metaclass

from gaia.core.base import GaiaObject
from gaia.core.factory import create_registry


StreamRegistry = create_registry()


@add_metaclass(StreamRegistry)
class Stream(GaiaObject):

    """Define the interface for a data stream.

    A stream is the type of object passed through a pipeline.  It is the
    primary container for data in Gaia.  Data streams should be self
    describing in that they contain all necessary metadata for interpreting
    the data.  While this class exposes a stream-like interface, the
    actual implementations can vary from websocket stream to file objects
    or in memory numpy arrays.

    The default behavior is to take an arbitrary object on write and return
    that object on read.  The reference to the object is deleted after
    reading.
    """

    def __init__(self, source_port, sink_port):
        """Create the stream between to ports.
Exemplo n.º 3
0
from six import add_metaclass

from base import TestCase
from gaia.core import factory


TestRegistry = factory.create_registry()
Registry2 = factory.create_registry()


@add_metaclass(TestRegistry)
class TestMainClass(object):

    """A toplevel class for registry testing."""

    pass


registry = TestRegistry.registry()


@add_metaclass(Registry2)
class Secondary(object):

    """A second toplevel class."""

    pass


class FactoryTest(TestCase):