Hello all ! :wave: I have a problem understanding ...
# ask-community
j
Hello all ! 👋 I have a problem understanding how I could use
DynamicOut
for my needs. I'm trying to change a simple python code containing loops into different
@op
elements My code is something like this:
Copy code
for i in range(len(variable_1)):
    for j in range(len(variable_2)):
        if variable_2[j] !=1:
            variable_3=variable_1[i]
        else:
            variable_3=0
I can either let everything in just one big
@asset
function, which works perfectly, but I wanted to try using
@op
instead But I have problem to understand how to use create and call the function that will run the "if" conditions, called "final" in the code below:
Copy code
@op(out = DynamicOut())
def listApps(variable_1):
    for i in variable_1.index:
        yield DynamicOutput(i, mapping_key=i)

@op(out = DynamicOut())
def listAPIs(variable_2):
    for i in variable_2.index:
        yield DynamicOutput(j, mapping_key=j)

@op
def final(i,j,variable_1,variable_2):
    if variable_2[j] !=1:
        variable_3=variable_1[i]
    else:
        variable_3=0

@job
def this_job():
    variable_1 = fromAfunction()
    variable_2 = [0,1]
    i = listApps(variable_1)
    j = listAPIs()
    results = i.map(final())
If
final
was just using
i
or
j
I would use
i.map(final())
but how can I call an
@op
in the
@job
if the op needs multiple variables & dynamicoutputs ? Thx for your help !