Does `Mapped Task` supported in local executions, ...
# flytekit
Mapped Task
supported in local executions, I have a mapped task in one of my workflow and tried to run it locally but im getting into a Promise issue like below
Copy code
E                   TypeError: Failed to convert return value for var o0 for function balrog_pipeline.workflows.primer_qc.process_expected_primer_qc_workflow.mapper_calculate_spike_in_metrics_in_fastq_dir_2 with error <class 'TypeError'>: No automatic conversion found from type <class 'flytekit.core.promise.Promise'> to FlyteFile.Supported (os.PathLike, str, Flytefile)
mapper task looks like this
Copy code
out_spike_in_metrics_list = map_task(
is the task with following signature
Copy code
def calculate_spike_in_metrics_in_fastq_dir(
    task_params: dict[str, FlyteFile]
) -> FlyteFile:
one thing, i think that should be
and what is base_task_worker?
oh we are on python 3.9
so native typing works without specifically importing typing
got it
base_task_worker is a decorator
that just adds resource request and cache versions to task/dynamic tasks
and just to be clear, running the calculate_spike not in a map task works right?
yup running remotely works
if you try with just one element of the task_params_list
no i mean locally
locally doesnt work, getting this Promise error
i mean just the
task, not the mapped version
it fails with the same error?
oh that i havent tested but i imagine it works fine
since other regular flyt tasks run just fine
let me try to repro this.
just look at the top file
does that kinda reflect what you were doing?
that works locally on my end
(the file is my attempt at debugging the other issue, ignore that for now)
Hi Yee I'll look into that in an hour currently not at my computer 😅
hmm yeah it is pretty much that. Although input to the map task was generated by another python task, like this
Copy code
def process_expected_primer_qc_workflow(
    in_spec_path: FlyteFile,
) -> tuple[FlyteFile, FlyteFile, FlyteFile]:
    task_params_list, can_run_contamination_metric = build_task_params(

    out_spike_in_metrics_list = map_task(calculate_spike_in_metrics_in_fastq_dir, metadata=TaskMetadata(retries=DEFAULT_DYNAMIC_TASK_RETRY),
hmm ill try to replicate it on a sandbox to see if that would work
ok i think i know the issue
but still wierdly why your example is working
i have a sandbox workflow like this
Copy code
def mappable_task(input: Dict[str, int]) -> Dict[str, int]:
    return {"number": input["number"] ** 2, "is_even": input["is_even"]}

def get_numbers(input: int) -> List[Dict[str, int]]:
    return [
        {"number": i, "is_even": 1 if i % 2 == 0 else 0} for i in range(input)

def mappable_workflow(limit: int) -> List[Dict]:
    mappable_inputs = get_numbers(input=limit)
    results_mapped_task = map_task(mappable_task, metadata=TaskMetadata(retries=1))(
    return results_mapped_task
this will give the following error
Copy code
raise AssertionError(f"Failed to convert value of output {k}, expected type {v}.") from e
AssertionError: Failed to convert value of output o0, expected type typing.List[typing.Dict].
i think it specific to Map types, this example was a generic Dict type before and it was working so Generic Struct works but when i type it then it fails
@Yee do you think its because i am on py3.9 with no native typing annotation
not sure… can you try with the typing.Dict?
or are you saying that doesn’t work
it should, we run our unit tests on 3.7-3.10
nvm yeah its not workoing the example above is using the
from typing import Dict, List
hmm ok above example is working on v0.31.0 i was on 0.30.3 in the sandbox 🤦 sorry for the alarm 😅