async def initialize(self): connection = await init_neptune_connection() async with connection: g = Graph().traversal().withRemote(connection) most_visited_websites = await get_most_active_websites(g) data = await (g.V(most_visited_websites).group().by().by( inE().hasLabel("visited").coin(COIN).inV().in_( "links_to").out("links_to").coin(COIN).path().by( values("url")) # visited website .by(values("ts")) # timestamp .by(values("url")) # visited website .by(values("url")) # root website .by(values("url").limit(1)) # thank you page ).select(Column.values).unfold()).toList() self.args = [{ "website_url": result[0], "thank_you_page_url": result[4], "since": result[1] - timedelta(days=random.randint(30, 60)), "min_visited_count": random.randint(2, 5) } for result in data]
async def initialize(self): connection = await init_neptune_connection() async with connection: g = Graph().traversal().withRemote(connection) data = await (g.V().hasLabel("transientId").coin(COIN).limit( ARG_COLLECTION).group().by().by( outE("visited").coin(COIN).inV().in_("links_to").out( "links_to").coin(COIN).path().by(values("uid")).by( values("ts")).by(values("url")).by( values("url")).by(values("url"))).select( Column.values).unfold()).toList() self.args = [{ "transient_id": result[0], "website_url": result[2], "thank_you_page_url": result[4], "since": result[1] - timedelta(days=random.randint(30, 60)), "min_visited_count": random.randint(2, 5) } for result in data if result]
async def test_metas(app, place, remote_connection): g = Graph().traversal().withRemote(remote_connection) session = await app.session() place.zipcode = 98402 place.historical_name = ['Detroit'] place.historical_name('Detroit').notes = 'rock city' place.historical_name('Detroit').year = 1900 place.historical_name.append('Other') place.historical_name[-1].notes = 'unknown' place.historical_name[-1].year = 1700 detroit = await session.save(place) dprops = await g.V(detroit.id).properties().toList() assert len(dprops) == 4 trav = g.V(detroit.id).properties('historical_name').valueMap(True) dmetas = await trav.toList() assert dmetas[0]['value'] == 'Detroit' assert dmetas[0]['notes'] == 'rock city' assert dmetas[0]['year'] == 1900 assert dmetas[1]['value'] == 'Other' assert dmetas[1]['notes'] == 'unknown' assert dmetas[1]['year'] == 1700 new_session = await app.session() new_detroit = await new_session.g.V(detroit.id).next() assert new_detroit.zipcode == detroit.zipcode assert new_detroit.historical_name[-1].value == detroit.historical_name[-1].value assert new_detroit.historical_name[-1].notes == detroit.historical_name[-1].notes assert new_detroit.historical_name[-1].year == detroit.historical_name[-1].year assert new_detroit.historical_name[0].value == detroit.historical_name[0].value assert new_detroit.historical_name[0].notes == detroit.historical_name[0].notes assert new_detroit.historical_name[0].year == detroit.historical_name[0].year await remote_connection.close() await app.close()
async def initialize(self): connection = await init_neptune_connection() async with connection: g = Graph().traversal().withRemote(connection) websites = await (g.V().hasLabel("website").coin(COIN).limit( ARG_COLLECTION).toList()) self.args = [{"website_url": website} for website in websites]
async def go(loop): remote_connection = await DriverRemoteConnection.open( 'ws://localhost:8182/gremlin', TRAVERSAL_SOURCE) g = Graph().traversal().withRemote(remote_connection) vertices = await g.V().toList() await remote_connection.close() return vertices
async def initialize(self): connection = await init_neptune_connection() async with connection: g = Graph().traversal().withRemote(connection) transient_ids = await get_household_members(g, ARG_COLLECTION) self.args = [{ "transient_id": transient_id } for transient_id in transient_ids]
async def initialize(self): connection = await init_neptune_connection() async with connection: g = Graph().traversal().withRemote(connection) most_visited_websites = await get_most_active_websites(g) self.args = [{ "thank_you_page_url": website } for website in most_visited_websites]
async def run(self, sample, pool): """Run query and return measure.""" sample_no = sample + 1 try: connection = pool.lock() g = Graph().traversal().withRemote(connection) args = self.get_args(sample) try: start = time.time() result = await self.query(g, **args).toList() end = time.time() _log_query_info(self.samples, sample_no, args, result) self.succeded += 1 return (start, end, end - start) except GremlinServerError as e: logger.debug(f"Sample {sample_no} failed: {e.msg}") self.failed += 1 return None finally: pool.unlock(connection) except ConnectionError as e: logger.debug(f"Sample {sample_no} failed: {e}") self.failed += 1 return None