Justin Albinet
04/18/2023, 1:45 PMDynamicOut
for my needs. I'm trying to change a simple python code containing loops into different @op
elements
My code is something like this:
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:
@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 !