-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4836e13
commit dffdfa4
Showing
14 changed files
with
196 additions
and
67 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import os | ||
import aerovaldb | ||
import re | ||
|
||
|
||
if os.path.exists("tests/test-db/sqlite/test.sqlite"): | ||
os.remove("tests/test-db/sqlite/test.sqlite") | ||
|
||
jsondb = aerovaldb.open("json_files:tests/test-db/json") | ||
sqlitedb = aerovaldb.open("sqlitedb:tests/test-db/sqlite/test.sqlite") | ||
|
||
data = jsondb.get_config( | ||
"project", "experiment", access_type=aerovaldb.AccessType.FILE_PATH, default="{}" | ||
) | ||
print(data) | ||
print(jsondb._get_uri_for_file(data)) | ||
print( | ||
jsondb.get_by_uri( | ||
jsondb._get_uri_for_file(data), access_type=aerovaldb.AccessType.JSON_STR | ||
) | ||
) | ||
|
||
sqlitedb.put_by_uri(data, jsondb._get_uri_for_file(data)) | ||
|
||
for i, uri in enumerate(list(jsondb.list_all())): | ||
print(f"Processing uri {uri}") | ||
data = jsondb.get_by_uri( | ||
uri, access_type=aerovaldb.AccessType.JSON_STR, default="{}" | ||
) | ||
sqlitedb.put_by_uri(data, uri) | ||
|
||
print(f"jsondb number of assets: {len(list(jsondb.list_all()))}") | ||
# print(f"sqlite number of assets: {len(list(sqlitedb.list_all()))}") |
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,46 @@ | ||
import simplejson | ||
import sqlite3 | ||
|
||
|
||
con = sqlite3.connect(":memory:") | ||
|
||
data = simplejson.dumps({"test": 1234}) | ||
|
||
print(data) | ||
|
||
cur = con.cursor() | ||
|
||
cur.execute( | ||
""" | ||
CREATE TABLE test(key, value) | ||
""" | ||
) | ||
|
||
con.commit() | ||
|
||
cur.execute( | ||
""" | ||
INSERT INTO test | ||
VALUES(?, ?) | ||
""", | ||
("test", data) | ||
) | ||
|
||
con.commit() | ||
|
||
cur.execute( | ||
""" | ||
SELECT value FROM test | ||
WHERE key='test' | ||
""" | ||
) | ||
print(simplejson.loads(cur.fetchone()[0])) | ||
|
||
import aerovaldb | ||
|
||
with aerovaldb.open("tests/test-db/json") as db: | ||
print(data) | ||
|
||
#db.put_by_uri(data, "/v0/config/project/experiment") | ||
|
||
print(db.get_by_uri("/v0/config/project/experiment", access_type=aerovaldb.AccessType.JSON_STR)) |
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
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
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,10 +0,0 @@ | ||
import re | ||
|
||
|
||
def extract_substitutions(template: str): | ||
""" | ||
For a python template string, extracts the names between curly brackets: | ||
For example 'blah blah {test} blah {test2}' returns [test, test2] | ||
""" | ||
return re.findall(r"\{(.*?)\}", template) | ||
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 |
---|---|---|
@@ -1,16 +0,0 @@ | ||
import pytest | ||
from aerovaldb.sqlitedb.utils import extract_substitutions | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"template,result", | ||
( | ||
("{A}{B}{C}", {"A", "B", "C"}), | ||
("{A}hello world{B} test {C}", {"A", "B", "C"}), | ||
("", set()), | ||
), | ||
) | ||
def test_extract_substitutions(template: str, result: set[str]): | ||
l = extract_substitutions(template) | ||
|
||
assert set(l) == result | ||
3 changes: 0 additions & 3 deletions
3
tests/test-db/json/project-no-experiments-json/experiment/hm/ts/_network-obsvar-layer.json
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
tests/test-db/json/project/experiment/hm/ts/_network-obsvar-layer.json
This file was deleted.
Oops, something went wrong.
Binary file not shown.
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
Oops, something went wrong.