Dataiku scenario variable

Jedrzej
Jedrzej Registered Posts: 2 ✭✭

Hi everyone,

I’m trying to set up a scenario with reporting. In my Python script, I declare a scenario variable like this:

scenario = Scenario()
scenario.set_scenario_variables(variables={
"tables_summary": summary
})

Then, in my report, I attempt to send an email using ${tables_summary}.

The summary variable is a non-empty string - I print it at the end of the script and can see it correctly in the logs. However, in the scenario, I get the following error:

An unexpected error occurred: the following has evaluated to null or missing: ==> tables_summary

I previously created another scenario where I declared the variable in the same way, and after a few runs, I was able to receive the email as expected. In this case, however, I’m unable to resolve the error.

Does anyone have experience with using scenario variables for reporting or know what might be causing this issue?

Dataiku version used: 12

Answers

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023, Circle Member Posts: 2,677 Neuron
    edited March 18

    Where exactly are you trying to use tables_summary after you defined it?

  • Jedrzej
    Jedrzej Registered Posts: 2 ✭✭

    In the Reporters e-mail body - message source: inline. I changed the scenario variable to project variable and it works now.

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023, Circle Member Posts: 2,677 Neuron

    Scenario variables only exist in the scope of a scenario run, not outside them. Mail reporters run AFTER the scenario run and outside their scope so they won't be able to access scenario variables. One solution, as you already found, is to use project variables which are persisted permanently in the project. Another solution will be to use a send mail step inside the scenario, which will have access to scenario variables. Ideally scenario reporters should be used only to convey the result of the scenario. If you have any operational emails to be sent as part of the scenario you should use scenario mail steps.

Setup Info
    Tags
      Help me…