Skip to content

Commit

Permalink
Add indexing pipeline type (#3461)
Browse files Browse the repository at this point in the history
  • Loading branch information
vblagoje authored Oct 24, 2022
1 parent 9b931bb commit 1b9586a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions haystack/pipelines/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ def run( # type: ignore
i = 0
else:
i += 1 # attempt executing next node in the queue as current `node_id` has unprocessed predecessors
self.send_pipeline_event_if_needed()
self.send_pipeline_event_if_needed(is_indexing=file_paths is not None)
return node_output

@pipeline_invocation_counter
Expand Down Expand Up @@ -2237,14 +2237,14 @@ def uptime(self) -> timedelta:
"""
return datetime.datetime.now(datetime.timezone.utc) - self.init_time

def send_pipeline_event(self):
def send_pipeline_event(self, is_indexing: bool = False):
fingerprint = sha1(json.dumps(self.get_config(), sort_keys=True).encode()).hexdigest()
run_total = self.run.counter + self.run_batch.counter
send_custom_event(
"pipeline",
payload={
"fingerprint": fingerprint,
"type": self.get_type(),
"type": "Indexing" if is_indexing else self.get_type(),
"uptime": int(self.uptime().total_seconds()),
"run_total": run_total,
"run_total_window": run_total - self.last_window_run_total,
Expand All @@ -2254,10 +2254,10 @@ def send_pipeline_event(self):
self.time_of_last_sent_event = datetime.datetime(now.year, now.month, now.day, tzinfo=datetime.timezone.utc)
self.last_window_run_total = run_total

def send_pipeline_event_if_needed(self):
def send_pipeline_event_if_needed(self, is_indexing: bool = False):
should_send_event = self.has_event_time_interval_exceeded() or self.has_event_run_total_threshold_exceeded()
if should_send_event and not self.sent_event_in_window:
self.send_pipeline_event()
self.send_pipeline_event(is_indexing)
self.sent_event_in_window = True
elif self.has_event_time_interval_exceeded():
self.sent_event_in_window = False
Expand Down

0 comments on commit 1b9586a

Please sign in to comment.