async def repo(self, key: str): query = self.parent.config.repo_query repo = Repo(key) db = self.conn await db.execute(query, (key, )) row = await db.fetchone() if row is not None: features = {} predictions = {} for key, value in row.items(): if key.startswith("feature_"): features[key.replace("feature_", "")] = value elif "_value" in key: target = key.replace("_value", "") predictions[target] = { "value": row[target + "_value"], "confidence": row[target + "_confidence"], } repo.merge( Repo( row["key"], data={ "features": features, "prediction": predictions }, )) return repo
async def repo(self, key: str): repo = Repo(key) db = self.conn # Get features await db.execute("SELECT json FROM ml_data WHERE key=%s", (key, )) dump = await db.fetchone() if dump is not None and dump[0] is not None: repo.merge(Repo(key, data=json.loads(dump[0]))) await db.execute("SELECT maintained FROM `status` WHERE key=%s", (key, )) maintained = await db.fetchone() if maintained is not None and maintained[0] is not None: repo.evaluated({"maintained": str(maintained[0])}) return repo
async def repo(self, src_url: str): repo = Repo(src_url) db = self.conn # Get features await db.execute("SELECT json FROM ml_data WHERE src_url=%s", (src_url, )) dump = await db.fetchone() if dump is not None and dump[0] is not None: repo.merge(Repo(src_url, data=json.loads(dump[0]))) await db.execute("SELECT maintained FROM `status` WHERE src_url=%s", (src_url, )) classification = await db.fetchone() if classification is not None and classification[0] is not None: repo.classify(str(classification[0])) return repo
async def repo(self, key: str): query = self.parent.config.repo_query repo = Repo(key) db = self.conn await db.execute(query, (key, )) row = await db.fetchone() if row is not None: repo.merge( Repo( row["key"], data={ "features": { key.replace("feature_", ""): value for key, value in row.items() if key.startswith("feature_") }, "prediction": { key.replace("prediction_", ""): value for key, value in row.items() if key.startswith("prediction_") }, }, )) return repo
def test_merge(self): null = Repo("null") null.merge(self.full) self.assertIn("half", null.extra) self.assertTrue(null.extra["half"])
def test_merge(self): null = Repo('null') null.merge(self.full) self.assertIn('half', null.extra) self.assertTrue(null.extra['half'])