Skip to content

Commit 71395f1

Browse files
authored
fix: update and print for eval (#536)
1 parent ab81d5f commit 71395f1

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

examples/code_embedding/main.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ def search(pool: ConnectionPool, query: str, top_k: int = 5):
6666
]
6767

6868
def _main():
69+
# Make sure the flow is built and up-to-date.
70+
stats = code_embedding_flow.update()
71+
print("Updated index: ", stats)
72+
6973
# Initialize the database connection pool.
7074
pool = ConnectionPool(os.getenv("COCOINDEX_DATABASE_URL"))
7175
# Run queries in a loop to demonstrate the query capabilities.

python/cocoindex/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ def evaluate(app_flow_specifier: str, output_dir: str | None, cache: bool = True
354354

355355
fl = _flow_by_name(flow_ref)
356356
if output_dir is None:
357-
output_dir = f"eval_{setting.get_app_namespace(trailing_delimiter='_')}{flow_name}_{datetime.datetime.now().strftime('%y%m%d_%H%M%S')}"
357+
output_dir = f"eval_{setting.get_app_namespace(trailing_delimiter='_')}{fl.name}_{datetime.datetime.now().strftime('%y%m%d_%H%M%S')}"
358358
options = flow.EvaluateAndDumpOptions(output_dir=output_dir, use_cache=cache)
359359
fl.evaluate_and_dump(options)
360360

python/cocoindex/flow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,8 @@ async def update_async(self) -> _engine.IndexUpdateInfo:
538538
Update the index defined by the flow.
539539
Once the function returns, the index is fresh up to the moment when the function is called.
540540
"""
541-
updater = await FlowLiveUpdater.create_async(self, FlowLiveUpdaterOptions(live_mode=False))
542-
await updater.wait_async()
541+
async with FlowLiveUpdater(self, FlowLiveUpdaterOptions(live_mode=False)) as updater:
542+
await updater.wait_async()
543543
return updater.update_stats()
544544

545545
def evaluate_and_dump(self, options: EvaluateAndDumpOptions):

0 commit comments

Comments
 (0)