How to modify Run as id for multiple project

Solved!
Srkanoje
Level 3
How to modify Run as id for multiple project

Hi all, 

is there any script present which can help me modify the run as id for 100 of project in one go.

the exact situation is like within these 100 of project each project might have 2 to 3 scenarios so i want all these to be modified to a particular run as id.

can someone please suggest action on this appreciate your time and efforts.

 

Thanks !!!

0 Kudos
1 Solution
AlexT
Dataiker

Hi,

We have an example here on how to re-assigned a scenario runas to another user :

https://doc.dataiku.com/dss/latest/python-api/scenarios.html#reassign-scenarios-to-another-user

 

To loop trough all project you can do this:

import dataiku
client = dataiku.api_client()
projects = client.list_projects()

for p in projects:
    project = client.get_project(p["projectKey"])
    for scenario in project.list_scenarios(as_type="objects"):
        settings = scenario.get_settings()

        if settings.effective_run_as == "u1":
            print("Scenario %s used to run as u1, reassigning it")
            # To configure a run_as, we must use the run_as property.
            # effective_run_as is read-only
            settings.run_as = "u2"
            settings.save()

View solution in original post

0 Kudos
2 Replies
AlexT
Dataiker

Hi,

We have an example here on how to re-assigned a scenario runas to another user :

https://doc.dataiku.com/dss/latest/python-api/scenarios.html#reassign-scenarios-to-another-user

 

To loop trough all project you can do this:

import dataiku
client = dataiku.api_client()
projects = client.list_projects()

for p in projects:
    project = client.get_project(p["projectKey"])
    for scenario in project.list_scenarios(as_type="objects"):
        settings = scenario.get_settings()

        if settings.effective_run_as == "u1":
            print("Scenario %s used to run as u1, reassigning it")
            # To configure a run_as, we must use the run_as property.
            # effective_run_as is read-only
            settings.run_as = "u2"
            settings.save()
0 Kudos
Srkanoje
Level 3
Author

@Alex  thank you this should work

0 Kudos