How to use the output of a Custom Python Step in another Scenario Step
![Remi_Mathieu](https://us.v-cdn.net/6038231/uploads/Dataiku/nAvatar2.png)
Hello,
I am currently parametrizing a scenario in which i try to launch a 'Build/Train Step' if a condition is satisfied. The condition i am trying to implement is based on the result of the previous Step which is a 'Custom Python Step'.
Until now, when i am launching my scenario, the condition is never verified and so the Build/Train Step never works.
Does someone now how to use the output of a Custom Python Step in my Build/Train Step ?
Thank you in advance.
Best Answer
-
Marlan Neuron 2020, Neuron, Registered, Dataiku Frontrunner Awards 2021 Finalist, Neuron 2021, Neuron 2022, Dataiku Frontrunner Awards 2021 Participant, Neuron 2023 Posts: 318 Neuron
Hi @Remi_Mathieu
,You may already be setting a scenario variable in your Execute Python step but just in case here is how to do that:
from dataiku.scenario import Scenario
Scenario().set_scenario_variables(pythonStepResult='OK')This topic by @tomas
describes how to set a step condition to check the value of a variable: https://community.dataiku.com/t5/Using-Dataiku-DSS/How-to-use-variables-in-the-Scenario-step-condition/m-p/3046/highlight/true#M2188Turns out to be very simple - just use the variable name directly: pythonStepResult == 'OK'
Marlan
Answers
-
You can use:
stepResults.getPath(".['customPythonStep1'].outcome").arrayContains("SUCCESS")
With FAILED, WARNING being the other 2 possible outcomes
Note that step output and step results are slightly different. Step outputs are only availables on steps which provide one (for ex: the execute SQL step puts the results of the SQL query. as output)
-
Remi_Mathieu Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 3 ✭✭✭
In fact, "OK" is the result of a function which is in the Custom Python Step. My purpose is getting the result of these function and not getting the state of the Step (SUCCESS, WARNING, FAILED)
-
Remi_Mathieu Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 3 ✭✭✭
Thanks you for your response. It works very well on my case.