Passing arguments between scenarios

Solved!
Srini_E
Level 3
Passing arguments between scenarios

Hi,

 

I have a case where I need to pass arguments/variables from a scenario (scenario_A) to another scenario (scenario_B). Scenario_B will be executed after scenario_A is completed, some outputs from scenario_A will be used in scenario_B, is there any option to pass these values?

 

Thanks in advance!

0 Kudos
1 Solution
nmadhu20

Hey @Srini_E ,

For you to be able to pass the value of parameters from one scenario to another, you'd need to store it somewhere. The easiest approach is what @kathyqingyuxu mentioned as 'project variables' which gives you the added advantage of monitoring the values as well.

However, there is one more approach. You can set Scenario variables via your code and access them in scenario B.

Step 1 - Set scenario variables in scenario A

scenario = Scenario()

scenario.set_scenario_variables(file_path = 'file_path', confidence_threshold = 'confidence_threshold', aws_keys = 'aws_keys')

Step 2 - Access these variables from Scenario B

import dataiku

client = dataiku.api_client()

project = client.get_project(โ€˜PROJECT_NAME')

scenario = project.get_scenario(โ€˜SCENARIO_Aโ€™)

parameter_value = scenario.get_last_finished_run().get_details()['scenarioRun']['variables']  #returns a json 

 

Hope this helps!

Regards,
Madhuleena

View solution in original post

3 Replies
kathyqingyuxu

Hey @Srini_E,

 

Any chance you can elaborate on what kind of values you're looking to pass to scenario B from scenario A?

If you can store the values in a dataset that might make the most sense (i.e. final output of scenario A generates data to a dataset on the flow, then use that final dataset output from scenario A as input to processes in scenario B).

Or store your values/arguments in a Dataiku project level variable:Variables in Flows, Webapps, and Dataiku Applications โ€” Dataiku Knowledge Base.

 

Hope this helps!

 

Best,

Kathy

Srini_E
Level 3
Author

Hi @kathyqingyuxu ,

 

Thank you for your response!

 

My actual use case is a chain trigger of scenarios one after other once an API call triggers scenario_A where in the API call business will provide these params: filepaths (for all scenarios (A, B, C, etc)), confidence_threshold, AWS_secret keys. This API can utilized by any business within our organization by providing their params. We want to create something we do not want to make edits in dataiku project level variables every-time. We just want to use in API call. 

 

API call ---> Scenario_A ---> Scenario_B -----> Scenario_C ........

 

 

Hope this explains better.

0 Kudos
nmadhu20

Hey @Srini_E ,

For you to be able to pass the value of parameters from one scenario to another, you'd need to store it somewhere. The easiest approach is what @kathyqingyuxu mentioned as 'project variables' which gives you the added advantage of monitoring the values as well.

However, there is one more approach. You can set Scenario variables via your code and access them in scenario B.

Step 1 - Set scenario variables in scenario A

scenario = Scenario()

scenario.set_scenario_variables(file_path = 'file_path', confidence_threshold = 'confidence_threshold', aws_keys = 'aws_keys')

Step 2 - Access these variables from Scenario B

import dataiku

client = dataiku.api_client()

project = client.get_project(โ€˜PROJECT_NAME')

scenario = project.get_scenario(โ€˜SCENARIO_Aโ€™)

parameter_value = scenario.get_last_finished_run().get_details()['scenarioRun']['variables']  #returns a json 

 

Hope this helps!

Regards,
Madhuleena