Check out the first Dataiku 8 Deep Dive focusing on Productivity on October 29th Read More

Using a project variable in the message of a reporter.

Level 1
Using a project variable in the message of a reporter.

Can I use a project variable in the message sent out at the end of a scenario by a slack web hook.



 



More context because I feel I'm doing something convoluted (hence probably not the simplest way to do it) :



In one project the 'final' recipe executes some functional action.



I set a project level variable summarizing some infos on the run like this. This is the final line of code at the end of a scenario run.



(python code in the recipe)



dataiku.api_client().get_project('THISISAPROJECTNAME').set_variables({'local':{'reportmessages':message2report},'standard':{}})



On the scenario , I set a slack webhook as a 'reporter'



on the text to display :



Reporting on SomeRun

Vouchers sent via somesend

${scenarioName}:${triggerType}

Results : ${outcome}



and would like to add  Message: ${reportmessages}  something like this





Thanks for any pointers !

 



 

0 Kudos
4 Replies
Dataiker
Dataiker

Hi,



On the latest version of DSS, you can directly set a project variable, for instance:





And use it in your scenario reporter using the $ magic ${foo}. This will return "bar" 🙂



In your case, if there is a scenario step to define and reset the project variable " reportmessages" , you will indeed reference it with ${reportmessages} inside the scenario reporting screen.



Cheers,



Alex



 

0 Kudos
Level 1
Author
Would it be the way you recommend to get a string passed *from inside a recipe code * to a slack chan through report message ?
do you see any other way to do it ?
0 Kudos
Dataiker
Dataiker
It may be better to do the variable set in a Python scenario step so that it is monitored in the scenario log. That assumes you have Automation features activated. If not, you can do it in a recipe, there is nothing wrong with that.
0 Kudos
Level 1
Author
thx. I'll try this.
0 Kudos
Labels (2)