Skip to content

Commit

Permalink
Merge pull request #28 from OpenFreeEnergy/stricter-checkout
Browse files Browse the repository at this point in the history
Stricter task checkout requirement
  • Loading branch information
dwhswenson authored Aug 25, 2023
2 parents 07ddf1c + 4be25ce commit 3e84595
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion exorcist/taskdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ def _task_row_update_statement(
is_checkout: bool = False,
max_tries: Optional[int] = None,
old_status: Optional[TaskStatus] = None,
old_tries: Optional[int] = None
) -> SQLStatement:
"""
Parameters
Expand Down Expand Up @@ -416,6 +417,9 @@ def _task_row_update_statement(
if old_status is not None:
stmt = stmt.where(self.tasks_table.c.status == old_status.value)

if old_tries is not None:
stmt = stmt.where(self.tasks_table.c.tries == old_tries)

# create a dict of values to update
values = {
'status': status,
Expand Down Expand Up @@ -477,7 +481,9 @@ def check_out_task(self):
update_stmt = self._task_row_update_statement(
task_row.taskid,
status=TaskStatus.IN_PROGRESS,
is_checkout=True
is_checkout=True,
old_status=TaskStatus.AVAILABLE,
old_tries=task_row.tries,
)
result = conn.execute(update_stmt)

Expand Down

0 comments on commit 3e84595

Please sign in to comment.