Why does `.with_remote_executor(SynchronousLocalTa...
# hamilton-help
s
Why does
.with_remote_executor(SynchronousLocalTaskExecutor())
execute more than once ~5/6 times? Given
len(accounts) == 1
.
Copy code
dr = (
        driver.Builder()
        .enable_dynamic_execution(allow_experimental_mode=True)
        .with_config({
            "cob_date": datetime(2023,3,25),
            "portfolio_config": portfolio_config,
            "execution": "parallel",
            "accounts": ["account_1"] # the `Parallelizable` part
        })
        .with_remote_executor(SynchronousLocalTaskExecutor())
        .with_modules(
            data_loader, # accounts are broken up here to load each 
            transfrom, # performed after collect
        )
        .build()
    )
👀 1
s
@Seth Stokes I can’t reproduce.
Copy code
# debug_parallel.py
from hamilton import driver
import datetime
from hamilton.execution.executors import SynchronousLocalTaskExecutor
from hamilton.htypes import Parallelizable, Collect

def account_loop(accounts: list[str]) -> Parallelizable[str]:
    print("account loop")
    for account in accounts:
        yield account

def account_step(account_loop: str) -> str:
    print("in account step")
    return account_loop

def reduce(account_step: Collect[str]) -> list[str]:
    print("reducing")
    return list(account_step)


if __name__ == '__main__':

    import __main__ as debug_parallel
    dr = (
            driver.Builder()
            .enable_dynamic_execution(allow_experimental_mode=True)
            .with_config({
                "cob_date": datetime.datetime(2023,3,25),
                "portfolio_config": {},
                "execution": "parallel",
                "accounts": ["account_1"] # the `Parallelizable` part
            })
            .with_remote_executor(SynchronousLocalTaskExecutor())
            .with_modules(
                debug_parallel
            )
            .build()
        )
    dr.execute(["reduce"])
s
I tried to reproduce as well with a toy example but couldn’t either. The only difference was an unsuccessful response - which produced the odd behavior - where the task executor kept making calls.
It works as expected from when the response is successful
s
What do you mean response? It's doing an API request?
s
That is correct
s
what step is the response?
inside parallel? or?
s
In your dag, closet to `account_ste`p
👍 1
s
do you have retrys? or something set?
s
I do not, but there’s a side effect of writing to a file. Not sure if that affects anything or not, but N calls is more than 1 even still
s
yeah even if
account_step
throws an error, it only is run once.
Follow up note: It appears that a stack trace is printed multiple times giving the impression of multiple executions, but the function is only run once as confirmed via print statements.