Skip to content

Commit

Permalink
Add progress indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffxy committed Nov 22, 2023
1 parent 6252a55 commit 59bdb59
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tools/load_embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ def insert(connection: Connection, embeddings: npt.NDArray):
movie_id_rows = cursor.fetchall_sync()
all_movie_ids = [row[0] for row in movie_id_rows]

total_batches = embeddings.shape[0] // BATCH_SIZE
if embeddings.shape[0] % BATCH_SIZE != 0:
total_batches += 1

# Insert batches
batch = 0
while batch * BATCH_SIZE < embeddings.shape[0]:
Expand All @@ -37,6 +41,7 @@ def insert(connection: Connection, embeddings: npt.NDArray):
for id, e in zip(movie_ids_batch, np_embeddings_batch)
]

print(f"Loading batch {batch} of {total_batches}...")
cursor.executemany_sync(
"INSERT INTO embeddings (movie_id, embedding) VALUES (?,?);", insert_batch
)
Expand Down

0 comments on commit 59bdb59

Please sign in to comment.