Skip to content

Commit

Permalink
Merge pull request #16 from epinzur/async-ingest
Browse files Browse the repository at this point in the history
added async support for ingest
  • Loading branch information
epinzur authored Jun 14, 2024
2 parents c7ee688 + e5500db commit bc107f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion ragulate/pipelines/ingest_pipeline.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
from typing import Any, Dict

from tqdm import tqdm
Expand All @@ -24,4 +25,7 @@ def ingest(self):
source_files.extend(dataset.get_source_file_paths())

for source_file in tqdm(source_files):
ingest_method(file_path=source_file, **params)
if asyncio.iscoroutinefunction(ingest_method):
asyncio.run(ingest_method(file_path=source_file, **params))
else:
ingest_method(file_path=source_file, **params)
4 changes: 3 additions & 1 deletion ragulate/pipelines/query_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ def query(self):
pipeline.invoke(query)
except Exception as e:
# TODO: figure out why the logger isn't working after tru-lens starts. For now use print()
print(f"ERROR: Query: '{query}' caused exception, skipping. Exception {e}")
print(
f"ERROR: Query: '{query}' caused exception, skipping. Exception {e}"
)
logger.error(f"Query: '{query}' caused exception, skipping.")
finally:
self.update_progress(query_change=1)
Expand Down

0 comments on commit bc107f4

Please sign in to comment.