Upload app.py
Browse files
app.py
CHANGED
|
@@ -675,6 +675,7 @@ def optimize_prompt(initial_prompt: str, dataset_name: str, dataset_split: str,
|
|
| 675 |
|
| 676 |
# Step 3: Monkey-patch ProcessParallelController
|
| 677 |
import openevolve.process_parallel as pp_module
|
|
|
|
| 678 |
|
| 679 |
OriginalProcessController = pp_module.ProcessParallelController
|
| 680 |
|
|
@@ -689,10 +690,27 @@ def optimize_prompt(initial_prompt: str, dataset_name: str, dataset_split: str,
|
|
| 689 |
pass
|
| 690 |
|
| 691 |
def submit(self, func, *args, **kwargs):
|
| 692 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 693 |
|
| 694 |
def map(self, func, *args):
|
| 695 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 696 |
|
| 697 |
def shutdown(self, wait=True):
|
| 698 |
pass
|
|
|
|
| 675 |
|
| 676 |
# Step 3: Monkey-patch ProcessParallelController
|
| 677 |
import openevolve.process_parallel as pp_module
|
| 678 |
+
from concurrent.futures import Future
|
| 679 |
|
| 680 |
OriginalProcessController = pp_module.ProcessParallelController
|
| 681 |
|
|
|
|
| 690 |
pass
|
| 691 |
|
| 692 |
def submit(self, func, *args, **kwargs):
|
| 693 |
+
# Execute directly and wrap in a completed Future
|
| 694 |
+
future = Future()
|
| 695 |
+
try:
|
| 696 |
+
result = func(*args, **kwargs)
|
| 697 |
+
future.set_result(result)
|
| 698 |
+
except Exception as e:
|
| 699 |
+
future.set_exception(e)
|
| 700 |
+
return future
|
| 701 |
|
| 702 |
def map(self, func, *args):
|
| 703 |
+
# Execute directly and wrap each result in a Future
|
| 704 |
+
futures = []
|
| 705 |
+
for a in zip(*args):
|
| 706 |
+
future = Future()
|
| 707 |
+
try:
|
| 708 |
+
result = func(*a)
|
| 709 |
+
future.set_result(result)
|
| 710 |
+
except Exception as e:
|
| 711 |
+
future.set_exception(e)
|
| 712 |
+
futures.append(future)
|
| 713 |
+
return futures
|
| 714 |
|
| 715 |
def shutdown(self, wait=True):
|
| 716 |
pass
|