filipniziol
Esteemed Contributor

Hi @Vishalakshi ,

I have responded during the weekend, but it seems the responses were lost.
You have here the run object. For example the current criteria is to return only runs where run[state][result_state] == "FAILED" so basically all failed jobs.

filipniziol_0-1726589554376.png

What you can do is to print(run) and you will see the object structure:

filipniziol_1-1726589796071.png

For example to rerun the jobs where run["state"]["state_message"] contains  "Task df_regular failed with message: Workload failed" the code would be:

        for run in data["runs"]:
            # Check if the run failed and was within the last 24 hours
            run_end_time = datetime.datetime.fromtimestamp(run["end_time"] / 1000)
            if "state" in run and "result_state" in run["state"] and run["state"]["result_state"] == "FAILED" \
                and "Task df_regular failed with message: Workload failed" in run["state"]["state_message"] \
                and run_end_time > twenty_four_hours_ago:
                failed_runs.append(run)

So I recommend just printing the run object, and building the filtering logic according to your criteria.

Hope it helps!