Skip to content

Commit

Permalink
added kwargs passing to expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
Aynur Adanbekova authored and Aynur Adanbekova committed Nov 3, 2024
1 parent a9ee912 commit b914e04
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/func.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def engine(self, *args, **kwargs):
"""
pass

def single_expression(self, data_point: Any) -> Any:
def single_expression(self, data_point: Any, **kwargs) -> Any:
"""
Execute the symbolicai Expression for a single data point.
Expand All @@ -41,7 +41,7 @@ def single_expression(self, data_point: Any) -> Any:
"""
expr = self.expr
try:
return expr(data_point, executor_callback=self.executor_callback)
return expr(data_point, executor_callback=self.executor_callback, **kwargs)
except Exception as e:
print(f"Data point {data_point} generated an exception: {str(e)}")
return e
Expand Down Expand Up @@ -96,7 +96,7 @@ def execute_queries(self) -> None:
if self.arguments:
self.batch_ready.set()

def forward(self, expr: Expression, num_workers: int, dataset: List[Any], batch_size: int = 5) -> List[Any]:
def forward(self, expr: Expression, num_workers: int, dataset: List[Any], batch_size: int = 5, **kwargs) -> List[Any]:
"""
Run the batch scheduling process for symbolicai Expressions.
Expand Down Expand Up @@ -126,7 +126,7 @@ def forward(self, expr: Expression, num_workers: int, dataset: List[Any], batch_
query_thread = threading.Thread(target=self.execute_queries)
query_thread.start()
with concurrent.futures.ThreadPoolExecutor(max_workers=self.num_workers) as executor:
future_to_data = {executor.submit(self.single_expression, data_point): data_point for data_point in self.dataset}
future_to_data = {executor.submit(self.single_expression, data_point, **kwargs): data_point for data_point in self.dataset}
for future in concurrent.futures.as_completed(future_to_data):
data_point = future_to_data[future]
try:
Expand Down

0 comments on commit b914e04

Please sign in to comment.