Skip to content

Commit

Permalink
Autogather can be disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
EdgesFTW committed Nov 16, 2023
1 parent c159b1f commit 194ab42
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 16 deletions.
32 changes: 21 additions & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,7 @@ jobs:
run: |
pip install -e .
# test ungathered default name
if [ -f .github/workflows/log_ungathered_v3_upgrade.sqlite ] ; then
rm .github/workflows/log_ungathered_v3_upgrade.sqlite
fi
# test ungathered_v3 default name
upgrade-db .github/workflows/log_ungathered_v3.sqlite
runalyzer .github/workflows/log_ungathered_v3_upgrade.sqlite -c 'db.print_cursor(db.q("select * from warnings"))'
Expand All @@ -270,10 +267,26 @@ jobs:
runalyzer .github/workflows/log_ungathered_v3_upgrade.sqlite -c 'assert "unixtime" in [l[0] for l in q("select * from warnings").description]'
runalyzer .github/workflows/log_ungathered_v3_upgrade.sqlite -c 'assert "rank" in [l[0] for l in q("select * from warnings").description]'
# test gathered default name
# if [ -f .github/workflows/log_gathered_v2_upgrade.sqlite ] ; then
# rm .github/workflows/log_gathered_v2_upgrade.sqlite
# fi
# test gathered_v3 default name
upgrade-db .github/workflows/log_gathered_v3.sqlite
runalyzer .github/workflows/log_gathered_v3_upgrade.sqlite -c 'db.print_cursor(db.q("select * from warnings"))'
runalyzer .github/workflows/log_gathered_v3_upgrade.sqlite -c 'print([l[0] for l in q("select * from warnings").description])'
runalyzer .github/workflows/log_gathered_v3_upgrade.sqlite -c 'print([l[0] for l in q("select * from logging").description])'
runalyzer .github/workflows/log_gathered_v3_upgrade.sqlite -c 'assert "unixtime" in [l[0] for l in q("select * from warnings").description]'
runalyzer .github/workflows/log_gathered_v3_upgrade.sqlite -c 'assert "rank" in [l[0] for l in q("select * from warnings").description]'
# test ungathered_v2 default name
upgrade-db .github/workflows/log_ungathered_v2.sqlite
runalyzer .github/workflows/log_ungathered_v2_upgrade.sqlite -c 'db.print_cursor(db.q("select * from warnings"))'
runalyzer .github/workflows/log_ungathered_v2_upgrade.sqlite -c 'print([l[0] for l in q("select * from warnings").description])'
runalyzer .github/workflows/log_ungathered_v2_upgrade.sqlite -c 'print([l[0] for l in q("select * from logging").description])'
runalyzer .github/workflows/log_ungathered_v2_upgrade.sqlite -c 'assert "unixtime" in [l[0] for l in q("select * from warnings").description]'
runalyzer .github/workflows/log_ungathered_v2_upgrade.sqlite -c 'assert "rank" in [l[0] for l in q("select * from warnings").description]'
# test gathered_v2 default name
upgrade-db .github/workflows/log_gathered_v2.sqlite
runalyzer .github/workflows/log_gathered_v2_upgrade.sqlite -c 'db.print_cursor(db.q("select * from warnings"))'
Expand All @@ -284,9 +297,6 @@ jobs:
# test gathered custom name
# if [ -f .github/workflows/log_gathered_v2_new.sqlite ] ; then
# rm .github/workflows/log_gathered_v2_new.sqlite
# fi
upgrade-db .github/workflows/log_gathered_v2.sqlite --suffix '_new'
runalyzer .github/workflows/log_gathered_v2_new.sqlite -c 'db.print_cursor(db.q("select * from warnings"))'
Expand Down
Binary file added .github/workflows/log_gathered_v3.sqlite
Binary file not shown.
Binary file added .github/workflows/log_ungathered_v2.sqlite
Binary file not shown.
16 changes: 13 additions & 3 deletions bin/runalyzer
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def main() -> None:
help="database file(s) to read")
parser.add_argument("--script", type=str,
help="script file to read")
parser.add_argument("--nogather", action="store_true",
help="do not automatically gather files")
args = parser.parse_args()

from logpyle.runalyzer import make_runalyzer_symbols, make_wrapped_db
Expand All @@ -27,16 +29,24 @@ def main() -> None:

do_mangle = not args.nomangle

gather = not args.nogather

if args.script:
db = make_wrapped_db(args.dbfiles, mangle=do_mangle, interactive=False)
db = make_wrapped_db(
args.dbfiles, mangle=do_mangle, interactive=False,
gather=gather)
exec(compile(open(args.script).read(), args.script, "exec"),
make_runalyzer_symbols(db))
elif args.commands:
db = make_wrapped_db(args.dbfiles, mangle=do_mangle, interactive=False)
db = make_wrapped_db(
args.dbfiles, mangle=do_mangle, interactive=False,
gather=gather)
exec(compile(args.commands, "--commands", "exec"),
make_runalyzer_symbols(db))
else:
db = make_wrapped_db(args.dbfiles, mangle=do_mangle, interactive=True)
db = make_wrapped_db(
args.dbfiles, mangle=do_mangle, interactive=True,
gather=gather)
from logpyle.runalyzer import RunalyzerConsole
cons = RunalyzerConsole(db)
cons.interact("Runalyzer running on Python %s\n"
Expand Down
11 changes: 9 additions & 2 deletions logpyle/runalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,15 @@ def auto_gather(filenames: List[str]) -> sqlite3.Connection:

# {{{ main program

def make_wrapped_db(filenames: List[str], interactive: bool, mangle: bool) -> RunDB:
db = auto_gather(filenames)
def make_wrapped_db(
filenames: List[str], interactive: bool,
mangle: bool, gather: bool = True
) -> RunDB:
if gather:
db = auto_gather(filenames)
else:
assert len(filenames) == 1, "Enable autogather to support multiple infiles"
db = sqlite3.connect(filenames[0])
db.create_aggregate("stddev", 1, StdDeviation) # type: ignore[arg-type]
db.create_aggregate("var", 1, Variance)
db.create_aggregate("norm1", 1, Norm1) # type: ignore[arg-type]
Expand Down
2 changes: 2 additions & 0 deletions logpyle/upgrade_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def upgrade_conn(conn: sqlite3.Connection) -> sqlite3.Connection:
""")

# ensure that warnings table has rank column
# nowhere to grab the rank of the process that generated
# the warning
if ("rank" not in warning_columns):
print("Adding a rank column in the warnings table")
conn.execute("""
Expand Down

0 comments on commit 194ab42

Please sign in to comment.