flyte icon indicating copy to clipboard operation
flyte copied to clipboard

[Core feature] Reuse same literals in the dynamic task

Open pingsutw opened this issue 2 years ago • 2 comments

Motivation: Why do you think this is important?

Running this workflow will upload the input df of conc_prediction 15x with different filenames to the connected blob storage. Each instance of predict_wf gets his own version of input.

@task()
def load_model(name: str) -> pd.DataFrame:
    return pd.DataFrame({name: [1, 2, 3, 4, 5]})


@task()
def predict_df(model: pd.DataFrame, n: int):
    print(model)
    print(n)


@workflow
def predict_wf(n: int, model: pd.DataFrame):
    predict_df(model=model, n=n)


@dynamic()
def conc_prediction(input: pd.DataFrame):
    for n in range(1, 15):
        predict_wf(model=input, n=n)


@workflow
def wf():
    output = load_model(name="foo")
    conc_prediction(input=output)

Goal: What should the final outcome look like, ideally?

We should only serialize the Pandas dataframe and upload it once. Each predict_wf should reuse the same input (parquet file).

We could probably add a local cache for the dynamic workflow. If the Python value has already been serialized, we can just load the literal from the cache

Describe alternatives you've considered

NA

Propose: Link/Inline OR Additional context

NA

Are you sure this issue hasn't been raised already?

  • [X] Yes

Have you read the Code of Conduct?

  • [X] Yes

pingsutw avatar Nov 19 '24 21:11 pingsutw

#take

davidlin20dev avatar Nov 19 '24 21:11 davidlin20dev

#take

BarryWu0812 avatar Aug 02 '25 07:08 BarryWu0812