Skip to navigation

Check Data Ingestion Status

Data added to Zep is processed asynchronously and can take a few seconds to a few minutes to finish processing. In this recipe, we show how to check whether a given data upload request (also known as an Episode) is finished processing by polling Zep with the graph.episode.get method.

First, let’s create a user:

import os
import uuid
import time
from dotenv import find_dotenv, load_dotenv
from zep_cloud.client import Zep
load_dotenv(dotenv_path=find_dotenv())
client = Zep(api_key=os.environ.get("ZEP_API_KEY"))
uuid_value = uuid.uuid4().hex[:4]
user_id = "-" + uuid_value
client.user.add(
user_id=user_id,
first_name = "John",
last_name = "Doe",
)

Now, let’s add some data and immediately try to search for that data; because data added to Zep is processed asynchronously and can take a few seconds to a few minutes to finish processing, our search results do not have the data we just added:

episode = client.graph.add(
user_id=user_id,
type="text",
data="The user is an avid fan of Eric Clapton"
)
search_results = client.graph.search(
user_id=user_id,
query="Eric Clapton",
scope="nodes",
limit=1,
reranker="cross_encoder",
)
print(search_results.nodes)
None

We can check the status of the episode to see when it has finished processing, using the episode returned from the graph.add method and the graph.episode.get method:

while True:
episode = client.graph.episode.get(
uuid_=episode.uuid_,
)
if episode.processed:
print("Episode processed successfully")
break
print("Waiting for episode to process...")
time.sleep(10)
Waiting for episode to process...
Waiting for episode to process...
Waiting for episode to process...
Waiting for episode to process...
Waiting for episode to process...
Episode processed successfully

Now that the episode has finished processing, we can search for the data we just added, and this time we get a result:

search_results = client.graph.search(
user_id=user_id,
query="Eric Clapton",
scope="nodes",
limit=1,
reranker="cross_encoder",
)
print(search_results.nodes)
[EntityNode(attributes={'category': 'Music', 'labels': ['Entity', 'Preference']}, created_at='2025-04-05T00:17:59.66565Z', labels=['Entity', 'Preference'], name='Eric Clapton', summary='The user is an avid fan of Eric Clapton.', uuid_='98808054-38ad-4cba-ba07-acd5f7a12bc0', graph_id='6961b53f-df05-48bb-9b8d-b2702dd72045')]