Skip to content

Commit

Permalink
Small doc changes from PR
Browse files Browse the repository at this point in the history
and now updates schema_version constant to 3
  • Loading branch information
EdgesFTW committed Dec 15, 2023
1 parent a95e8fb commit 6769605
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,14 @@ jobs:
# test ungathered_v2 default name
upgrade-db .github/workflows/log_ungathered_v2.sqlite
# utilize nogather flag to ensure schema is from modification
# instead of gathering, which builds schema v3
runalyzer .github/workflows/log_ungathered_v2_upgrade.sqlite -c 'db.print_cursor(db.q("select * from warnings"))' --nogather
runalyzer .github/workflows/log_ungathered_v2_upgrade.sqlite -c 'print([l[0] for l in q("select * from warnings").description])' --nogather
runalyzer .github/workflows/log_ungathered_v2_upgrade.sqlite -c 'print([l[0] for l in q("select * from logging").description])' --nogather
runalyzer .github/workflows/log_ungathered_v2_upgrade.sqlite -c 'assert "unixtime" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_ungathered_v2_upgrade.sqlite -c 'assert "rank" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_ungathered_v2_upgrade.sqlite -c 'assert [l[0] for l in q("select schema_version")][0] == 3'
# test gathered_v2 default name
Expand All @@ -276,6 +279,7 @@ jobs:
runalyzer .github/workflows/log_gathered_v2_upgrade.sqlite -c 'print([l[0] for l in q("select * from logging").description])' --nogather
runalyzer .github/workflows/log_gathered_v2_upgrade.sqlite -c 'assert "unixtime" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_gathered_v2_upgrade.sqlite -c 'assert "rank" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_gathered_v2_upgrade.sqlite -c 'assert [l[0] for l in q("select schema_version")][0] == 3'
# test gathered custom name
Expand All @@ -286,6 +290,7 @@ jobs:
runalyzer .github/workflows/log_gathered_v2_new.sqlite -c 'print([l[0] for l in q("select * from logging").description])' --nogather
runalyzer .github/workflows/log_gathered_v2_new.sqlite -c 'assert "unixtime" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_gathered_v2_new.sqlite -c 'assert "rank" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_gathered_v2_new.sqlite -c 'assert [l[0] for l in q("select schema_version")][0] == 3'
- name: Upgrade V3 to V3
# Tests upgrades on current version for stability and allows users
Expand All @@ -296,11 +301,14 @@ jobs:
# test ungathered_v3 default name
upgrade-db .github/workflows/log_ungathered_v3.sqlite
# utilize nogather flag to ensure schema is from modification
# instead of gathering, which builds schema v3
runalyzer .github/workflows/log_ungathered_v3_upgrade.sqlite -c 'db.print_cursor(db.q("select * from warnings"))' --nogather
runalyzer .github/workflows/log_ungathered_v3_upgrade.sqlite -c 'print([l[0] for l in q("select * from warnings").description])' --nogather
runalyzer .github/workflows/log_ungathered_v3_upgrade.sqlite -c 'print([l[0] for l in q("select * from logging").description])' --nogather
runalyzer .github/workflows/log_ungathered_v3_upgrade.sqlite -c 'assert "unixtime" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_ungathered_v3_upgrade.sqlite -c 'assert "rank" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_ungathered_v3_upgrade.sqlite -c 'assert [l[0] for l in q("select schema_version")][0] == 3'
# test gathered_v3 default name
upgrade-db .github/workflows/log_gathered_v3.sqlite
Expand All @@ -310,6 +318,7 @@ jobs:
runalyzer .github/workflows/log_gathered_v3_upgrade.sqlite -c 'print([l[0] for l in q("select * from logging").description])' --nogather
runalyzer .github/workflows/log_gathered_v3_upgrade.sqlite -c 'assert "unixtime" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_gathered_v3_upgrade.sqlite -c 'assert "rank" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_gathered_v3_upgrade.sqlite -c 'assert [l[0] for l in q("select schema_version")][0] == 3'
# test gathered custom name
upgrade-db .github/workflows/log_gathered_v3.sqlite --suffix '_new'
Expand All @@ -319,3 +328,4 @@ jobs:
runalyzer .github/workflows/log_gathered_v3_new.sqlite -c 'print([l[0] for l in q("select * from logging").description])' --nogather
runalyzer .github/workflows/log_gathered_v3_new.sqlite -c 'assert "unixtime" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_gathered_v3_new.sqlite -c 'assert "rank" in [l[0] for l in q("select * from warnings").description]' --nogather
runalyzer .github/workflows/log_gathered_v3_new.sqlite -c 'assert [l[0] for l in q("select schema_version")][0] == 3'
5 changes: 4 additions & 1 deletion bin/runalyzer
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ def main() -> None:
parser.add_argument("--script", type=str,
help="script file to read")
parser.add_argument("--nogather", action="store_true",
help="do not automatically gather files")
help="""
Do not automatically gather files. Primarily
used internally to view database schema.
""")
args = parser.parse_args()

from logpyle.runalyzer import make_runalyzer_symbols, make_wrapped_db
Expand Down
2 changes: 1 addition & 1 deletion logpyle/runalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ def make_wrapped_db(
if gather:
db = auto_gather(filenames)
else:
assert len(filenames) == 1, "Enable autogather to support multiple infiles"
assert len(filenames) == 1, "Enable autogather to support multiple input files"
db = sqlite3.connect(filenames[0])
db.create_aggregate("stddev", 1, StdDeviation) # type: ignore[arg-type]
db.create_aggregate("var", 1, Variance)
Expand Down
13 changes: 13 additions & 0 deletions logpyle/upgrade_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Database Upgrade Functions
--------------------------------
.. autofunction:: upgrade_db
.. note::
Currently, upgrades all schema versions to version 3.
Upgrading from version 1 is untested.
.. list-table:: Overview of known changes between schema versions
:widths: 25 25 50
Expand Down Expand Up @@ -71,6 +74,16 @@ def upgrade_conn(conn: sqlite3.Connection) -> sqlite3.Connection:
ADD run_id integer;
""")

from pickle import dumps
schema_version = 3
value = bytes(dumps(schema_version))
if gathered:
conn.execute("UPDATE runs SET schema_version=3")
# conn.execute("UPDATE runs SET schema_version = ?", (value,))
else:
# conn.execute("UPDATE constants SET value=3 WHERE name='schema_version'")
conn.execute("UPDATE constants SET value = ? WHERE name='schema_version'", (value,))

return conn


Expand Down

0 comments on commit 6769605

Please sign in to comment.