stocky-apple-74569
10/18/2023, 4:27 PMimport typing
from flytekit import Resources, task, workflow, dynamic
@task(requests=Resources(cpu="1", mem="200Mi"), limits=Resources(cpu="2", mem="350Mi"))
def count_unique_numbers_1(x: typing.List[int]) -> int:
s = set()
for i in x:
s.add(i)
return len(s)
@task
def square_1(x: int) -> int:
return x * x
@task
def memory_string() -> str:
return "400Mi"
@workflow
def my_pipeline(x: typing.List[int]) -> int:
return square_1(x=count_unique_numbers_1(x=x)).with_overrides(
limits=Resources(cpu="6", mem="500Mi")
)
@dynamic
def my_workflow_dynamic(x: typing.List[int]) -> int:
memory = memory_string()
return square_1(x=count_unique_numbers_1(x=x)).with_overrides(
limits=Resources(mem=memory)
)
@workflow
def my_workflow_dynamic_wrapper(x: typing.List[int]) -> int:
return my_workflow_dynamic(x=x)
And the error is:
TypeError: bad argument type for built-in operation
sparse-advantage-22780
10/18/2023, 5:55 PMmy_workflow_dynamic
you're actually creating a resources object where memory is defined as a wrapped promise object, which it doesn't want.sparse-advantage-22780
10/18/2023, 5:57 PMmemory = memory_string()
to my_workflow_dynamic_wrapper
, put memory: str
in the args for my_workflow_dynamic
and pass in memory when you call it. It will be unwrapped when it's sent to the dynamic and you won't get that error anymore