How to Change the Run As user of a Scenario dynamically through Script

srdheekonda
Level 2
How to Change the Run As user of a Scenario dynamically through Script

Hi All,

We are using Dataiku Version 8.My requirement is whoever runs the Scenario, the Scenario has to run with their name as Owner to pass the current executing user id to underlying recipes to process dynamic logic.

I tried using below script in the same scenario but it is still taking the scenario owner name only.

for scenario in p.list_scenarios(as_type="objects"):
settings = scenario.get_settings()

if scenario == "Custom Python Scenario":
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 = int(cuser)
settings.save()

Please suggest if any option to achieve this


Operating system used: RHEL 7.9

0 Kudos
3 Replies
NN

Hi,

Havent done this exact thing but just sharing a few things you can check incase you dont get a full solution from anyone else.

Do your users have the rights to change the RUN_AS option manually ?
One of the things we had noticed was that the RUN_AS option could only be changed by Admin roles.
If thats the case for you as well you might want to consider creating a Macro, and use an Admin Client for your API calls.

Also not sure if you can change the runas in the same scenario . so please check if it works when you call the function from another scenario

srdheekonda
Level 2
Author

Hi Neuron,

Thanks for your response. Yes you are right,Later I realised that and also tried from another scenario to change the scenario run_as but no luck. It seems some limitation in using that method in version 8.

Regarding the privilege's I will check further and identify which roles/access can change the owner of the scenario.

Thanks,
Sampath 

0 Kudos
Sampathvinta

Hello, 

I don't think its possible to do this without being an administrator. May be you can try getting the current authenticated user instead of getting a scenario user.

auth_info = client.get_auth_info()

# auth_info is a dict which contains at least a "authIdentifier" field, which is the login for a user
print("User running this code is %s" % auth_info["authIdentifier"])

https://doc.dataiku.com/dss/latest/python-api/authinfo.html

Thanks,

Sam

 

0 Kudos

Labels

?

Setup info

?
A banner prompting to get Dataiku