Hi, I would like to do this but I can't figure out...
# ask-community
Hi, I would like to do this but I can't figure out how to do it, any ideas? Thanks!! from dagster import op, graph @op def return_number_list(): return [5, 6, 7] @op def add_one(number): return number + 1 @op def add_two(number): return number + 2 @graph def add(number): return add_two(add_one(number)) @graph def add_test(): number_list = return_number_list() add_list = [] for i in number_list: result = add(i) add_list.append(result) if name == '__main__': result = add_test.execute_in_process()
I think you'll want to use a dynamic job: https://docs.dagster.io/concepts/ops-jobs-graphs/dynamic-graphs#a-dynamic-job so you'd want to map your add() op across the number_list result, then use the .collect() method on the mapping result - something along the lines of
Copy code
def add_test():
    number_list = return_number_list()
    added_numbers = number_list.map(add).collect()
You'd also need to change return_number_list() to yield a series of DynamicOutputs that correspond to each element in your list.
❤️ 1