-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Spelunker] Tweak eval tooling (#743)
Log successful spelunker requests in `~/.spelunker.log`. (A place where it isn't easily accidentally erased.) Add a simple tool to read back `~/.spelunker.log`. (For manual inspection, for now.) Add a simple script to dump the salient parts of an eval database to a text file `eval.sql`. (Tool to read it back is TBD.) Rename IdType to ChunkId in `chunker.py`. Preserve `Questions` and `Scores` tables when redoing the eval setup. Lint.
- Loading branch information
1 parent
cb6ec74
commit 63d610a
Showing
8 changed files
with
632 additions
and
44 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,16 @@ | ||
#!/bin/bash | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
|
||
case $1 in | ||
"" | "-h" | "--help") | ||
echo "Usage: $0 <path> # eval directory, e.g. evals/eval-1" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
TABLES="Questions Hashes Scores" | ||
|
||
sqlite3 $1/eval.db ".dump $TABLES" >$1/dbdump.sql || exit 1 | ||
echo "Dumped $TABLES $1/eval.db to $1/dbdump.sql" | ||
|
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
|
||
import argparse | ||
import json | ||
import os | ||
import time | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"-q", | ||
"--questions", | ||
action="store_true", | ||
help="Show the questions only.", | ||
default=False, | ||
) | ||
parser.add_argument( | ||
"-f", | ||
"--follow", | ||
action="store_true", | ||
help="Follow the log file (like tail -f).", | ||
default=False, | ||
) | ||
args = parser.parse_args() | ||
questions_only = args.questions | ||
follow = args.follow | ||
with open(os.path.join(os.getenv("HOME") or "", ".spelunker.log"), "r") as f: | ||
while True: | ||
line = f.readline() | ||
if not line: | ||
if follow: | ||
time.sleep(0.2) | ||
continue | ||
else: | ||
break | ||
try: | ||
data = json.loads(line) | ||
except json.JSONDecodeError: | ||
print(f"Invalid JSON: {line:.100}") | ||
continue | ||
if questions_only: | ||
print(data["question"]) | ||
else: | ||
print() | ||
print("-" * 50) | ||
print(f"Question: {data['question']}") | ||
print(f"Answer: {data['answer']}") | ||
print(f"References: {data['references']}") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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