Status of steps in scenario

altaf_ansari
altaf_ansari Registered Posts: 3

Hello,

I have created a scenario that consists of 5 steps. When I trigger the scenario ,I want to track the status of each step in that scenario as well as the Percentage of Completion of the scenario through python code.

So, if step 1 completes , the status should be 20% , after step 2 - 40% and so on.

I cannot find how to get the status of the steps in the current run of the scenario.


Operating system used: Windows

Tagged:

Answers

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 1,925 Neuron
    edited July 17

    The way you can achieve this is by creating a Custom Python step as the last tep of the scenario. Then you can invoke the Scenario of scenario object which will give you access to the data you are looking for. Here is some sample code:

    from dataiku.scenario import Scenario
    current_scenario = Scenario()
    scenario_variables = current_scenario.get_all_variables()
    
    print("scenarioOutcome: " + scenario_variables['outcome'])
    print("stepResults: " + str(scenario_variables['stepResults']))
    print("stepOutcomes: " + str(scenario_variables['stepOutcomes']))

  • altaf_ansari
    altaf_ansari Registered Posts: 3

    Hey Hi,

    Thanks for the response. I tried it but the catch is that if I use the code provided by you as the last step of a scenario then I am getting the status after completion of all the steps. I am looking for a dynamic solution such that when a step is running , the status displayed to user should be "Running" and when it completes it should change to "Step No __ Completed" . Then the percentage completion of the scenario should be printed . This loop should repeat till all steps are ran successfully and the Scenario Completion is 100%.

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 1,925 Neuron
    edited July 17

    In that case you need to check the scenario from outside the scenario itself using the Dataiku API. Here is some sample code:

    import dataiku
    
    api_client = dataiku.api_client()
    
    project = api_client.get_project('your project key')
    scenario = project.get_scenario('your scenario id')
    current_run = scenario.get_current_run()
    steps = current_run.get_details().steps

Setup Info
    Tags
      Help me…