-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from semiotic-ai/add-version-to-comment
Added version to the top of the aa model
- Loading branch information
Showing
3 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
#!include:.gitignore | ||
.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import random | ||
import re | ||
import string | ||
from math import exp, log | ||
from unittest import mock | ||
from unittest.mock import patch | ||
|
||
import asyncpg | ||
import pytest | ||
from numpy.testing import assert_approx_equal | ||
|
||
from autoagora import model_builder | ||
from autoagora.logs_db import LogsDB | ||
|
||
|
||
class TestModelBuilder: | ||
@pytest.fixture | ||
async def pgpool(self, postgresql): | ||
pool = await asyncpg.create_pool( | ||
host=postgresql.info.host, | ||
database=postgresql.info.dbname, | ||
user=postgresql.info.user, | ||
password=postgresql.info.password, | ||
port=postgresql.info.port, | ||
) | ||
assert pool | ||
yield pool | ||
await pool.close() | ||
|
||
async def test_build_model(self, pgpool): | ||
with mock.patch( | ||
"autoagora.logs_db.LogsDB.get_most_frequent_queries" | ||
) as mock_get_mfq: | ||
mock_get_mfq.return_value = [ | ||
LogsDB.QueryStats( | ||
query="query getData{ values { id } }", | ||
count=100, | ||
min_time=1, | ||
max_time=60, | ||
avg_time=1.2, | ||
stddev_time=0.5, | ||
) | ||
] | ||
model = await model_builder.model_builder( | ||
"Qmadj8x9km1YEyKmRnJ6EkC2zpJZFCfTyTZpuqC3j6e1QH", pgpool | ||
) | ||
pattern = r"# Generated by AutoAgora \d+\.\d+\.\d+" | ||
# To ensure a version is being obtained | ||
assert re.match(pattern, model), f"{model} does not match pattern {pattern}" |