Skip to content

Commit

Permalink
fix index init
Browse files Browse the repository at this point in the history
  • Loading branch information
rbs333 committed Jul 19, 2024
1 parent 6e0713f commit 328624f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 7 additions & 1 deletion backend/arxivsearch/db/redis_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ def get_schema():

def get_index():
dir_path = os.path.dirname(os.path.realpath(__file__))
return SearchIndex.from_yaml(os.path.join(dir_path, "index.yaml"))
index = SearchIndex.from_yaml(os.path.join(dir_path, "index.yaml"))
index.connect(redis_url=config.REDIS_URL)

if index.exists():
return index
else:
index.create(overwrite=True)


async def get_async_index():
Expand Down
1 change: 0 additions & 1 deletion backend/arxivsearch/tests/utils/seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@ def seed_test_db():
paper["cohere"] = np.array(paper["cohere"], dtype=np.float32).tobytes()

index = redis_helpers.get_index()
index.connect(redis_url=config.REDIS_URL)
index.load(data=papers, id_field="paper_id")
return papers

0 comments on commit 328624f

Please sign in to comment.