Your question is Validate Deadline Eligibility Updates. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Scale.ai task workflows may allow an annotator task to receive a later deadline, but only while the task remains eligible for modification. Implement update_deadline to validate all rules and return the updated task when the change is allowed.
A task is eligible only when:
status is exactly "pending".deadline.modification_window seconds after created_at.new_deadline is strictly later than both the current time and the existing deadline.created_at + max_lifetime.If every rule passes, return a copy of the task with its deadline replaced by new_deadline. Otherwise, return None. Do not modify the input dictionary when the update is rejected.
Input is a dictionary containing integer Unix timestamps for created_at, deadline, modification_window, and max_lifetime, plus a string status. The function also receives integer new_deadline and now values. Return a dictionary on success or None on failure.
def update_deadline(task, new_deadline, now):