Expiring a mostly-finished task run.
See original GitHub issueIf I have a large task run, expiring it expires all its units, which sets the expiry on mturk even if the unit is completed. This can take a long time. I am wondering if this is worth optimizing. If so, would the following change in mephisto, in mturk_unit.py
, be safe?
def expire(self) -> float:
"""
Send a request to expire the HIT, and if it's not assigned return,
otherwise just return the maximum assignment duration
"""
delay = 0
+ status = self.get_status()
+ if status in [AssignmentState.EXPIRED, AssignmentState.COMPLETED]:
+ return delay
- if self.get_status() == AssignmentState.ASSIGNED:
+ if status == AssignmentState.ASSIGNED:
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Asynchronously wait for Task<T> to complete with timeout
Delay task is backed by a system timer which will continue to be tracked until the timeout expires regardless of how long SomeOperationAsync...
Read more >Just because you stopped waiting for it, doesn't mean the Task ...
Without special handling, a Task always run to completion. Let's start by looking at what happens to the "source" Task when you use...
Read more >Running an async task with a timeout - Swift Forums
Its goal is to run an async task with a timeout. If the timeout expires and the work hasn't completed, it should cancel...
Read more >The danger of TaskCompletionSource class
It means that an “async” continuation runs synchronously almost all the time when the awaited task is not finished!
Read more >Tasks - Prefect 2 - Coordinating the world's dataflows
Caching refers to the ability of a task run to reflect a finished state without ... results are used rather than running the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@federicoruggeri this is something of a bug in behavior, but not of intent. When an agent disconnects, if the system doesn’t explicitly expire the
Unit
, we assume that theUnit
should be put up for a different agent to be able to accept. In the case of a dialogue task though, we do expire theUnit
directly, but then the get_status overrides that. We should reject the edge transition toLAUNCHED
here though specifically if the unit is already in the expired state: https://github.com/facebookresearch/Mephisto/blob/fc359c74dc73c4c408b089301833682107bbbbfa/mephisto/data_model/unit.py#L285-L289Good job in identifying the logical transition though, this fix would definitely be appreciated.
I’ve been testing this out, running large runs for a few days, and it seems to be working. I will make a PR.
There are often cases where I expire a run* and wait a while (much longer than the assignment duration) and find that there’s a hit or two in the “launched” state. In this case, expiring the run again succeeds in cleaning up.
operator.get_running_task_runs()[...].task_launcher.expire_units()