How to fetch run as Id for multiple scenarios

Srkanoje
Level 3
How to fetch run as Id for multiple scenarios

Hi all can some please help me out I need to fetch the run as Id for multiple project present within an instance 

Refering the documentation I was able to find the below script to fetch the run as Id for all scenarios but I am still facing issue while running this not sure what we need to specifically pass as an "objects" or either we do not need to pass anything  can some one suggest actions on this.

Script: 

for scenario in project.list_scenarios(as_type="objects"):
settings = scenario.get_settings()
# We must use `effective_run_as` and not `run_as` here.
# run_as contains the "configured" run as, which can be None - in that case, it will run
# as the last modifier of the scenario
# effective_run_as is always valued and is the resolved version.
print("Scenario %s runs as user %s" % (scenario.id, settings.effective_run_as))

0 Kudos
3 Replies
NN

@Srkanoje 
If it helps Something like below is how we have used it for our requirements

import dataiku
user_client = dataiku.api_client()
project=user_client.get_project('PROJECTNAME')
for each in project.list_scenarios():
    scenario=project.get_scenario(each['id'])
    settings=scenario.get_settings()
    print(each['id'],'-',settings.effective_run_as)

 

Srkanoje
Level 3
Author

@NN thank you for the script but this would be specific to a project 
i tried the script removing the 3 line as well but it grab the data only for a specific project i just want to grab the data "Scenario id " for all projects within my instance so if i have 100 projects i want to grab the scenario id for all 100 projects 

 

0 Kudos
Srkanoje
Level 3
Author

@NN  i got the solution to it below script worked 

import dataiku
user_client = dataiku.api_client()
for project_key in client.list_project_keys():
project = client.get_project(project_key)
for runasid in project.list_scenarios():
scenario=project.get_scenario(runasid['id'])
settings=scenario.get_settings()
print(project_key,'-',runasid['id'],'-',settings.effective_run_as)