Skip to content

Commit

Permalink
issue #20 - code review with jolan
Browse files Browse the repository at this point in the history
  • Loading branch information
melanie-fressard committed Oct 31, 2023
1 parent 287cab0 commit 4d6c0a2
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions search.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
# Name of this file: search.py
# Location: at the root of the project
# How to execute: python3 -m search.py query

import subprocess
import sys
import louis.db.api as api
import louis.db as db
from microbench import MicroBench, MBReturnValue, MBFunctionCall
import pandas as pd


class Bench(MicroBench, MBFunctionCall, MBReturnValue):
pass

output_file = "benchmarking/search_results.json"
commit_version = subprocess.check_output(["git",
"rev-parse", "HEAD"]).strip().decode('utf-8')
basic_bench = Bench(outfile=output_file, commit_version=commit_version,
function_version="0.0.1")

outfile = "benchmarking/search_results.json"
commit = subprocess.check_output(["git", "rev-parse", "HEAD"]).strip().decode("utf-8")
basic_bench = Bench(
output_file=outfile, commit_version=commit, function_version="0.0.1"
)


def search(cursor, query):
"""Execute the SQL search function"""
return api.search_from_text_query(cursor, query)


@basic_bench
def init_bench(query):
"""Initialize the benchmark by calling the function search"""
connection = db.connect_db()
with db.cursor(connection) as cursor:
return search(cursor, query)

if __name__ == '__main__':
init_bench(' '.join(sys.argv[1:]))
with open(output_file, 'r') as result_file:
print(pd.read_json(result_file, lines=True))



if __name__ == "__main__":
"""How to execute: python3 -m search.py query"""
init_bench(" ".join(sys.argv[1:]))
with open(outfile, "r") as result_file:
print(pd.read_json(result_file, lines=True))

0 comments on commit 4d6c0a2

Please sign in to comment.