Skip to content

Commit

Permalink
Merge pull request #35 from epinzur/reset_once
Browse files Browse the repository at this point in the history
reset db once
  • Loading branch information
epinzur authored Jun 27, 2024
2 parents fef6e1a + c0c4885 commit 1bcbe1d
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions ragulate/pipelines/query_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ def __init__(
signal.signal(signal.SIGINT, self.signal_handler)

self._tru = get_tru(recipe_name=self.recipe_name)
if self.restart_pipeline:
# TODO: Work with TruLens to get a new method added
# so we can just delete a single "app" instead of the whole
# database.
self._tru.reset_database()

for dataset in datasets:
queries, golden_set = dataset.get_queries_and_golden_set()
Expand All @@ -77,18 +82,10 @@ def __init__(
)
queries = [queries[i] for i in sampled_indices]

if self.restart_pipeline:
# TODO: Work with TruLens to get a new method added
# so we can just delete a single "app" instead of the whole
# database.
self._tru.reset_database()
else:
# Check for existing records and filter queries
existing_records = self._tru.get_records_and_feedbacks(
app_ids=[dataset]
)
existing_queries = {record.query for record in existing_records}
queries = [query for query in queries if query not in existing_queries]
# Check for existing records and filter queries
existing_records = self._tru.get_records_and_feedback(app_ids=[dataset])
existing_queries = {record.query for record in existing_records}
queries = [query for query in queries if query not in existing_queries]

self._queries[dataset.name] = queries
self._golden_sets[dataset.name] = golden_set
Expand Down

0 comments on commit 1bcbe1d

Please sign in to comment.