https://prefect.io logo
Title
i

itay livni

09/07/2020, 9:31 PM
Hi - Is
apply_map
the only way to implement a mapped case statement? Thanks
I am running into an issue in
apply_map
where a task returns a list but the downstream task is not mapping over the list. Is that expected behavior? In the diagram I am referring to the bottom most task.
j

Jenny

09/08/2020, 1:54 PM
Hi @itay livni - Can you let us know where you're calling apply_map? Or share your code for this? I'm guessing you've already looked at these but the docs have a bit more about the different types of mapping: https://docs.prefect.io/core/concepts/mapping.html#prefect-approach
i

itay livni

09/08/2020, 2:19 PM
Hi @Jenny - I am calling
apply_map
from the
add_new_vertex
the root task in the diagram. The input for task
new_term_to_make
is a dictionary. When I run this code outside
apply_map
, in a flow it runs fine.
👀 1
with case(vertices_to_add.not_(), False):

        # getRecdoc = GetItem("resource-doc")
        # resource_doc = getRecdoc(first_vert_artifacts, 'resource_doc')
        
        # 1. Extract keyterms
        getKeyTerms = GetKeyterms(name="get-rec-keyterms")
        keyterm_df_lst = getKeyTerms(
            summary_dict=vertices_to_add["vertex"],
            resource_doc = vertices_to_add["resource_doc"]
        )
 

        # 2. Generate list of new nodes to make
        with tags("node-input-list"):
            terms_to_make_lst = genKeys.map(
                keyterm_df=keyterm_df_lst,
                resource_doc=unmapped(vertices_to_add["resource_doc"]),
                summary_dict=unmapped(vertices_to_add["vertex"]),
                # vertices_to_add=vertices_to_add,
                task_args={"name": "new-terms-to-make"}
            )
This is the code outside without
apply_map
The code inside
apply_map
is the same but with
unmapped
removed.
j

Jim Crist-Harif

09/08/2020, 2:51 PM
Hi itay, can you provide a reproducible example (https://blog.dask.org/2018/02/28/minimal-bug-reports) of the issue you're running into? Case statements in general should be usable inside apply_map, so if that's not working we'd need something reproducible to help debug further.
i

itay livni

09/08/2020, 2:56 PM
Yes. I will. The
case
statement is working . I expected one of the terminal task's to be mapped over the inputs...
Hi @Jim Crist-Harif - I asked the question in git. Not as an issue - It's probably just a lack of knowledge on my end. https://github.com/PrefectHQ/prefect/discussions/3287