Skip to content

Commit

Permalink
build python from nb
Browse files Browse the repository at this point in the history
  • Loading branch information
algal committed Oct 25, 2024
1 parent 0eecc5b commit 8841006
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions fastdata/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def generate(self,
temp: float = 1.,
sp: str = "You are a helpful assistant.",
max_workers: int = 64) -> list[dict]:
"For every input in INPUTS, fill PROMPT_TEMPLATE and generate a value fitting SCHEMA"

def process_input(input_data):
try:
Expand All @@ -57,10 +58,9 @@ def process_input(input_data):
return None

results = []
with concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as executor:
futures = [executor.submit(process_input, input_data) for input_data in inputs]
for future in tqdm(concurrent.futures.as_completed(futures), total=len(inputs)):
result = future.result()
results.append(result)

return results
with tqdm(total=len(inputs)) as pbar:
with concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as executor:
futures = [executor.submit(process_input, input_data) for input_data in inputs]
for completed_future in concurrent.futures.as_completed(futures):
pbar.update(1)
return [f.result() for f in futures]

0 comments on commit 8841006

Please sign in to comment.