Exemple #1
0
    def setUp(self):
        """Call before every test case."""
        self.dapManager = DapManager.DapManager()

        dapManagerConfig = {
            "dap1": {
                "class": "InMemoryDap",
                "config": {
                    "structure": {
                        "wibbles": {
                            "wibble": "string"
                        },
                    },
                },
            },
            "dap2": {
                "class": "InMemoryDap",
                "config": {
                    "structure": {
                        "wobbles": {
                            "wobble": "string"
                        },
                    },
                },
            },
        }
        self.dapManager.setup(sys.modules[__name__], dapManagerConfig)
        self.dap1 = self.dapManager.getInstance("dap1")
        self.dap2 = self.dapManager.getInstance("dap2")
Exemple #2
0
 def __init__(self):
     self.router = None
     self.dapManager = DapManager.DapManager()
     self._network_dap_config = dict()
     self._setup_endpoints()
     self._port_injector = PortInjector()
     self._log_dir = ""
    def setUp(self):
        """Call before every test case."""

        self.dapManager = DapManager.DapManager()

        dapManagerConfig = {
            "dap1": {
                "class": "InMemoryDap",
                "config": {
                    "structure": {
                        "media": {
                            "media": "string"
                        },
                    },
                },
            },
            "dap-early": {
                "class": "EarlyInMemoryDap",
                "config": {
                    "structure": {
#                        "wibbles": {
#                            "wibble": "string"
#                        },
#                        "wobbles": {
#                            "wobble": "string"
#                        },
                    },
                },
            },
            "dap2": {
                "class": "InMemoryDap",
                "config": {
                    "structure": {
                        "nation": {
                            "nation": "string"
                        },
                    },
                },
            },
            "uniquer": {
                "class": "DapUniquer",
                "config": {
                    "module": "dap_uniquer.src.python.DapUniquer",
                    "structure": {
                    },
                },
            },
        }
        self.dapManager.setDataModelEmbedder("", "", "")
        self.dapManager.setup(
            sys.modules[__name__],
            dapManagerConfig)

        self.dap1 = self.dapManager.getInstance("dap1")
        self.dap2 = self.dapManager.getInstance("dap2")
Exemple #4
0
    def setUp(self):
        """Call before every test case."""

        config = {
            "er-graph": {
                "class": "DapERNetwork",
                "config": {
                    "structure": {
                        "mesh": {},
                    },
                },
            },
        }

        self.data = DapManager.DapManager()
        self.data.addClass("DapERNetwork", DapERNetwork.DapERNetwork)
        self.data.setup(sys.modules[__name__], config)

        self.setupAgents()
    def setUp(self):
        """Call before every test case."""
        self.dapManager = DapManager.DapManager()

        dapManagerConfig = {
            "data_model_searcher": {
                "class": "SearchEngine",
                "config": {
                    "structure": {
                        "data_model_table": {
                            "service": "data_model"
                        },
                    },
                },
            },
        }
        self.dapManager.setup(sys.modules[__name__], dapManagerConfig)
        self.dapManager.setDataModelEmbedder('data_model_searcher',
                                             'data_model_table', 'service')
Exemple #6
0
    def setUp(self):
        """Call before every test case."""

        self.dapManager = DapManager.DapManager()

        dapManagerConfig = {
            "geo": {
                "class": "DapGeo",
                "config": {
                    "structure": {
                        "location": {
                            "location": {
                                'type': 'location'
                            },
                        },
                    },
                },
            },
        }
        self.dapManager.setDataModelEmbedder("", "", "")
        self.dapManager.setup(sys.modules[__name__], dapManagerConfig)
    def setUp(self):
        """Call before every test case."""

        config = {
            "locations": {
                "class": "DapGeo",
                "config": {
                    "structure": {
                        "airports": {
                            "airports": {
                                "type": "location"
                            }
                        },
                    },
                },
            },
        }

        self.data = DapManager.DapManager()
        #self.data.addClass("DapGeo", DapGeo.DapGeo)
        self.data.setup(sys.modules[__name__], config)

        self.setupAirports()
        self.BHX = ("latlon", "deg", (52.454, -1.748))
Exemple #8
0
    def testFieldOptionsWork(self):
        dapManager = DapManager.DapManager()
        self.dapManager = dapManager

        dapManagerConfig = {
            "data_model_searcher": {
                "class": "SearchEngine",
                "config": {
                    "structure": {
                        "data_model_table": {
                            "data_model": "embedding"
                        },
                    },
                },
            },
            "geo": {
                "class": "DapGeo",
                "config": {
                    "structure": {
                        "location": {
                            "location": {
                                "type": "location",
                                "options": [
                                    "plane",
                                ]
                            }
                        },
                    },
                },
            },
        }
        dapManager.setup(
            sys.modules[__name__],
            dapManagerConfig)

        dapManager.setDataModelEmbedder('data_model_searcher', 'data_model_table', 'data_model')

        dm1 = query_pb2.Query.DataModel()
        dm1.name = "weather_data"
        dm1.description = "All possible weather data."
        dm1.attributes.extend([
            get_attr_b("wind_speed", "Provides wind speed measurements.",0),
            get_attr_b("temperature", "Provides wind speed measurements.",1),
            get_attr_b("air_pressure", "Provides wind speed measurements.",2)
        ])
        dm2 = query_pb2.Query.DataModel()
        dm2.name = "more weather"
        dm2.description = "More weather"
        dm2.attributes.extend([
            get_attr_b("wind_speed", "Provides wind speed measurements.",0),
            get_attr_b("temperature", "Provides wind speed measurements.",1),
            get_attr_b("rain_fall", "Provides wind speed measurements.",2)
        ])
        dm3 = query_pb2.Query.DataModel()
        dm3.name = "book_store_new"
        dm3.description = "Other bookstore"
        dm3.attributes.extend([
            get_attr_b("title", "The title of the book", 1),
            get_attr_b("author", "The author of the book", 3),
            get_attr_b("ISBN", "That code thing", 4),
            get_attr_b("price", "We will need a lot of money", 3),
            get_attr_b("count", "How many do we have", 0),
            get_attr_b("condition", "Our books are in the best condition", 0)
        ])

        engine = dapManager.getInstance('data_model_searcher')
        embed1 = engine._dm_to_vec(dm1)
        embed2 = engine._dm_to_vec(dm2)
        embed3 = engine._dm_to_vec(dm3)

        lat = 0
        lon = 0
        count = 1
        for agent, loc, model in [
            ("007/James/Bond",   (51.477,-0.461), dm1), # LHR, WEATHER
            ("White/Spy",        (53.354,-2.275), dm2), # MANCHESTER, WEATHER
            ("Black/Spy",        (50.734,-3.414), dm3), #EXETER, BOOKSHOP
            ("86/Maxwell/Smart", (40.640,-73.779), dm1), # JFK, WEATHER
        ]:
            update = dap_update_pb2.DapUpdate()
            update.update.add()
            update.update[0].tablename = "location"
            update.update[0].fieldname = "location.update"
            update.update[0].key.core = b'localhost'
            update.update[0].key.agent = agent.encode("utf-8")
            update.update[0].value.l.coordinate_system = "latlon"
            update.update[0].value.l.unit = "deg"
            update.update[0].value.l.v.extend(loc)
            update.update[0].value.type = 9
            dapManager.update(update)

            update = self._createUpdate(agent)
            update.update.add()
            update.update[0].tablename = "data_model_table"
            update.update[0].fieldname = "data_model"
            update.update[0].value.type = 6
            update.update[0].value.dm.CopyFrom(model)
            self.dapManager.update(update)

        qm = query_pb2.Query.Model()
        qAnd = qm.constraints.add()
        q1 = qAnd.and_.expr.add()

        q1.constraint.attribute_name = "location"
        q1.constraint.relation.op = 0
        q1.constraint.distance.center.lat = 52.454
        q1.constraint.distance.center.lon = -1.748   # BHX
        q1.constraint.distance.distance = 150 * 1000

        qm.model.CopyFrom(create_dm("weather_data",
         "All possible weather data.", [
             get_attr_b("wind_speed", "Provides wind speed measurements.", 0),
             get_attr_b("temperature", "Provides wind speed measurements.", 0),
             get_attr_b("air_pressure", "Provides wind speed measurements.", 0)
        ]))

        dapQuery = self.dapManager.makeQuery(qm)
        output = self.dapManager.execute(dapQuery)

        agents = sorted([
            result.agent
            for result
            in output.identifiers
        ])

        self.log.warning("agents={}".format(agents))

        assert(agents == [
            b"007/James/Bond",
            b"White/Spy",
        ])
Exemple #9
0
    def testFieldOptionsWork(self):
        dapManager = DapManager.DapManager()

        dapManagerConfig = {
            "geo": {
                "class": "DapGeo",
                "config": {
                    "structure": {
                        "wobbles": {
                            "wobbles": {
                                "type": "location",
                                "options": [
                                    "plane",
                                ]
                            }
                        },
                    },
                },
            },
        }
        dapManager.setup(sys.modules[__name__], dapManagerConfig)

        lat = 0
        lon = 0
        count = 1
        for agent, loc in [
            ("007/James/Bond", (51.477, -0.461)),  # LHR
            ("White/Spy", (53.354, -2.275)),  # MANCHESTER
            ("Black/Spy", (50.734, -3.414)),  #EXETER
            ("86/Maxwell/Smart", (40.640, -73.779)),  # JFK
        ]:
            update = dap_update_pb2.DapUpdate()
            update.update.add()
            update.update[0].tablename = "wobbles"
            update.update[0].fieldname = "location.update"
            update.update[0].key.core = b'localhost'
            update.update[0].key.agent = agent.encode("utf-8")

            update.update[0].value.l.coordinate_system = "latlon"
            update.update[0].value.l.unit = "deg"
            update.update[0].value.l.v.extend(loc)
            update.update[0].value.type = 9
            dapManager.update(update)

            lat += loc[0]
            lon += loc[1]
            count += 1

        lat /= count
        lon /= count

        update = dap_update_pb2.DapUpdate()
        update.update.add()
        update.update[0].tablename = "wobbles"
        update.update[0].fieldname = "wobbles.update"
        update.update[0].key.core = b'localhost'
        update.update[0].value.l.coordinate_system = "latlon"
        update.update[0].value.l.unit = "deg"
        update.update[0].value.l.v.extend([lat, lon])
        update.update[0].value.type = 9
        dapManager.update(update)

        r = dapManager.getInstance("geo").describe()
        nameToField = {}
        for f in r.table[0].field:
            nameToField[f.name] = {
                "type": f.type,
                "options": f.options,
            }
        assert 'plane' in nameToField["wobbles.location"]["options"]
        assert nameToField["wobbles.location"]["type"] == "location"

        r = dapManager.getPlaneInformation('location')
        assert r['field_name'] == 'wobbles.location'
        assert len(r['values']) == 1

        print(r['values'][0].value.l)
        assert r['values'][0].key.core == b'localhost'
        assert int(r['values'][0].value.l.v[1]) == -15
        assert int(r['values'][0].value.l.v[0]) == 39
 def __init__(self):
     self.router = None
     self.dapManager = DapManager.DapManager()
     self._log_dir = ""
    def setUp(self):
        """Call before every test case."""

        self.dapManager = DapManager.DapManager()
        dapManagerConfig = {
            "dap1": {
                "class": "DapNetworkProxy",
                "config": {
                    "structure": {
                        "media": {
                            "media": "string"
                        },
                        "nation": {
                            "nation": "string"
                        },
                    },
                    "host": "127.0.0.1",
                    "port": 15000
                },
            }
        }

        self.remoteProcessConfig = """
{
    "host": "127.0.0.1",
    "port": 15000,
    "description": {
        "name": "dap1",
        "table": [
            {
                "name": "media",
                "field": [
                    {
                        "name": "media",
                        "type": "string"
                    }
                ]
            }, {
                "name": "nation",
                "field": [
                    {
                        "name": "nation",
                        "type": "string"
                    }
                ]
            }
        ]
    }
}
"""
        self.remoteProcessArgs = [
            "cpp_dap_in_memory/src/cpp/cpp_dap_in_memory_server",
            "--configjson",
            self.remoteProcessConfig,
            #'find', '.', "-name", "cpp_dap_in_memory_server",
            #'bazel-bin/cpp_dap_in_memory/src/cpp/cpp_dap_in_memory_server.runfiles/__main__/cpp_dap_in_memory/src/cpp/cpp_dap_in_memory_server',
            #'--help',
        ]
        self.remoteProcess = subprocess.Popen(self.remoteProcessArgs)
        time.sleep(0.25)

        self.dapManager.setup(sys.modules[__name__], dapManagerConfig)
        self.dap1 = self.dapManager.getInstance("dap1")
    def setUp(self):
        """Call before every test case."""

        self.dapManager = DapManager.DapManager()

        dapManagerConfig = {
            "inmem": {
                "class": "InMemoryDap",
                "config": {
                    "structure": {
                        "ratings": {
                            "rating": "double"
                        },
                    },
                },
            },
            "attributes": {
                "class": "DapAttributeStore",
                "config": {
                    "structure": {},
                },
            },
        }
        self.dapManager.setDataModelEmbedder("", "", "")
        self.dapManager.setup(sys.modules[__name__], dapManagerConfig)

        for agent, list_of_attr_val_type_tuples, list_of_field_val_tuples in [
            ("007/James/Bond", [
                ("fave-gun", "string", "waltherppk"),
                ("licence", "string", "to-kill"),
                ("arbitrary", "int64", 7),
            ], [
                ("rating", 7.00),
            ]),
            ("santa", [
                ("busiest-day", "string", "25 december"),
                ("arbitrary", "int64", 12),
            ], [
                ("rating", 10.00),
            ]),
            (
                "this bloody office",
                [
                    ("temperature", "double", 23.9),
                    ("arbitrary", "int64", 24),
                ],
                [
                    ("rating", 1.00),
                ],
            ),
            (
                "not arbitrary",
                [
                    ("moocows", "int64", 24),
                ],
                [
                    ("rating", 10.00),
                ],
            ),
        ]:
            self.dapManager.update(
                self.CreateAttributesUpdateForAgent(
                    agent, list_of_attr_val_type_tuples))
            self.DoFieldsUpdateForAgent(agent, list_of_field_val_tuples)
Exemple #13
0
    def testFieldOptionsWork(self):
        dapManager = DapManager.DapManager()

        dapManagerConfig = {
            "geo": {
                "class": "DapGeo",
                "config": {
                    "structure": {
                        "wobbles": {
                            "location": {
                                "type": "location",
                                "options": [
                                    "plane",
                                ]
                            }
                        },
                    },
                },
            },
            "attrs": {
                "class": "DapAttributeStore",
                "config": {
                    "structure": {},
                },
                "options": [
                    "lazy",
                ],
            },
            "annotations": {
                "class": "InMemoryDap",
                "config": {
                    "structure": {
                        "annotations": {
                            "name": "string",
                            "id": "int64",
                        },
                    },
                },
            },
        }
        dapManager.setup(sys.modules[__name__], dapManagerConfig)

        DATA = [
            (
                "007/James/Bond",
                (51.477, -0.461),
                [('id', 1), ('foo', 1)],
            ),  # LHR
            (
                "White/Spy",
                (53.354, -2.275),
                [('id', 2), ('foo', 2)],
            ),  # MANCHESTER
            (
                "Black/Spy",
                (50.734, -3.414),
                [('id', 3), ('foo', 3)],
            ),  #EXETER
            (
                "86/Maxwell/Smart",
                (40.640, -73.779),
                [('id', 4), ('foo', 4)],
            ),  # JFK
        ]

        lat = 0
        lon = 0
        count = 1
        #update = dap_update_pb2.DapUpdate()
        #update.update.add()
        #update.update[0].fieldname = "location"
        #update.update[0].key.core = b'localhost'
        #update.update[0].key.agent = agent.encode("utf-8")
        #update.update[0].value.l.lat = loc[0]
        #update.update[0].value.l.lon = loc[1]
        #update.update[0].value.type = 9
        #dapManager.update(update)

        for agent, loc, attrs in DATA:
            update = dap_update_pb2.DapUpdate()
            for (k, v) in attrs[0:1]:
                u = update.update.add()
                u.key.core = b'localhost'
                u.key.agent = agent.encode("utf-8")
                ProtoHelpers.populateUpdateTFV(u, k, v)
            dapManager.update(update)
            break

        # we're going to check that when the assignments to the "id"
        # field were routed, they did not go to the attribute store.

        assert dapManager.getInstance("attrs").table == {}

        for agent, loc, attrs in DATA:
            update = dap_update_pb2.DapUpdate()
            for (k, v) in attrs[1:]:
                u = update.update.add()
                u.key.core = b'localhost'
                u.key.agent = agent.encode("utf-8")
                ProtoHelpers.populateUpdateTFV(u, k, v)
            dapManager.update(update)
            break

        # But "foo" should have been...

        assert dapManager.getInstance("attrs").table != {}