detect details about scenario run

Adi Registered Posts: 1


I would like to create a new scenario that basically just tells me which scenarios were triggered manually in the previous day.

I'm doing it in a python code, and right now I have 2 things i have questions on-

1. I would like to know the real user that triggered the scenario manually, for example even if a scenario has a "run as" option i would like to get both the user that the scenario run as and also the real user who triggered the scenario manually.

the code looks like this right now-

scenario_runs = scenario_obj.get_last_runs(only_finished_runs=True)

for run in scenario_runs:
details = run.get_details()

# Check if the run was manually triggered from the last 24 hours
if run.trigger.get('name') == 'Manual trigger' and > last_day:
'Project' : proj,
'Scenario': scenario_id,
'User' : details.get('scenarioRun', 'User Unknown').get('result', 'User Unknown').get('login', 'User Unknown'),
'Real_user': details.get('realUserLogin', 'User Unknown'),
'Start_Time': str(run.start_time),
'Trigger_Type': run.trigger['name']

so with the login (user field) i get the "run as" user but the "realUserLogin" doesn't work for me..

2. I want to save the results to an hive dataset that only keeps the data of the last day, so in case there's new records of scenarios that were triggered manually everything works fine, but in case there's no records at some day i want to just delete the records from the dataset but keep it's structure.
right now im doing-

df = pd.DataFrame(manually_triggered_runs)

dataset = dataiku.Dataset("Manual_triggered_scenarios_last_day")

is there any better way i can just delete the old data in the dataset and insert the new records if there is any?

Thanks a lot


  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 1,710 Neuron

    Hi, can you please edit your post and change your code to be in a code block (see screen shot below)? As you know padding is key in Python so can't really try your code sample under it's properly formatted. Thanks


Setup Info
      Help me…