Skip to content

Commit

Permalink
Improve demo project script (flush + batching) (#1112)
Browse files Browse the repository at this point in the history
* Update demo_data_generator.py

* Fix linter
  • Loading branch information
ferc authored Jan 22, 2025
1 parent 81059a3 commit 840b9d5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sdks/python/examples/demo_data_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def create_demo_data(base_url: str, workspace_name, comet_api_key):
workspace=workspace_name,
host=base_url,
api_key=comet_api_key,
_use_batching=True,
)

for trace in sorted(evaluation_traces, key=lambda x: x["start_time"]):
Expand All @@ -48,6 +49,8 @@ def create_demo_data(base_url: str, workspace_name, comet_api_key):
span["parent_span_id"] = new_parent_span_id
client.span(**span)

client.flush()

# Demo traces and spans
# We have a simple chatbot application built using llama-index.
# We gave it the content of Opik documentation as context, and then asked it a few questions.
Expand All @@ -57,6 +60,7 @@ def create_demo_data(base_url: str, workspace_name, comet_api_key):
workspace=workspace_name,
host=base_url,
api_key=comet_api_key,
_use_batching=True,
)

for trace in sorted(demo_traces, key=lambda x: x["start_time"]):
Expand Down Expand Up @@ -152,6 +156,8 @@ def create_demo_data(base_url: str, workspace_name, comet_api_key):

experiment.insert(experiment_items)

client.flush()


if __name__ == "__main__":
base_url = "http://localhost:5173/api"
Expand Down

0 comments on commit 840b9d5

Please sign in to comment.