示例#1
0
 def partition(self, payload, wait=False):
     payload = {src: at.dumps(typ) for src, typ in payload.items()}
     self.message(MsgTypes.Transition, self.node, Transition(Transitions.Configure, payload))
     if wait:
         self.wait_for(self.mark())
     else:
         return self.mark
示例#2
0
def test_serialization(typed_dict):
    name, fields, cls = typed_dict

    reloaded_cls = amitypes.loads(amitypes.dumps(cls))

    assert reloaded_cls.__name__ == name
    assert typing.get_type_hints(reloaded_cls) == fields
示例#3
0
 def graph(version=0, names=None, sources=None, graph=None):
     if names is None:
         names = set()
     if sources is None:
         sources = {}
     else:
         sources = {src: at.dumps(typ) for src, typ in sources.items()}
     return {'version': version, 'names': names, 'sources': sources, 'dill': dill.dumps(graph)}
示例#4
0
def test_pickled(typed_dict):
    name, fields, cls = typed_dict

    reloaded_cls = amitypes.loads(amitypes.dumps(cls))

    assert reloaded_cls.__name__ == name
    assert typing.get_type_hints(reloaded_cls) == fields

    pickled_cls = pickle.loads(pickle.dumps(reloaded_cls))

    assert pickled_cls.__name__ == name
    assert typing.get_type_hints(pickled_cls) == fields
示例#5
0
    def configure(self):
        """
        Constructs a properly formatted configure message

        Returns:
            An object of type `Message` which includes a dict of
            names:types of the currently available detectors/data.
        """
        self.reset_heartbeat()
        self.request(self.requested_names)
        flatten_types = {name: at.dumps(dtype) for name, dtype in self.types.items()}
        return Message(MsgTypes.Transition,
                       self.idnum,
                       Transition(Transitions.Configure, flatten_types))
示例#6
0
def test_dumps_and_loads(types):
    for obj in types:
        assert amitypes.loads(amitypes.dumps(obj)) == obj
示例#7
0
def test_dumps(type_map):
    for obj, expected in type_map:
        # check that the object dumps as expected
        assert amitypes.dumps(obj) == expected