Skip to content

Commit

Permalink
Merge pull request #648 from opensafely-core/no-action-resubmit
Browse files Browse the repository at this point in the history
Do not raise INTERNAL_ERROR for job resubmission
  • Loading branch information
bloodearnest authored Sep 6, 2023
2 parents f848e98 + a2aa6ac commit e4e8fc1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions jobrunner/create_or_update_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def assert_new_jobs_created(job_request, new_jobs, current_jobs):
# is treated as a successful outcome because we've already done everything that was
# requested.
if RUN_ALL_COMMAND in job_request.requested_actions:
raise NothingToDoError()
raise NothingToDoError("All actions have already completed succesfully")

# The other reason is that every requested action is already running or pending,
# this is considered a user error.
Expand All @@ -298,7 +298,7 @@ def assert_new_jobs_created(job_request, new_jobs, current_jobs):
current_job_states.get(action) for action in job_request.requested_actions
}
if requested_action_states <= {State.PENDING, State.RUNNING}:
raise JobRequestError("All requested actions were already scheduled to run")
raise NothingToDoError("All requested actions were already scheduled to run")

# But if we get here then we've somehow failed to schedule new jobs despite the fact
# that some of the actions we depend on have failed, which is a bug.
Expand Down
9 changes: 9 additions & 0 deletions tests/test_create_or_update_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,15 @@ def make_job_request(action=None, actions=None, **kwargs):
return job_request


def test_create_jobs_already_requested(db, tmp_work_dir):
create_jobs_with_project_file(make_job_request(action="analyse_data"), TEST_PROJECT)

with pytest.raises(NothingToDoError):
create_jobs_with_project_file(
make_job_request(action="analyse_data"), TEST_PROJECT
)


def create_jobs_with_project_file(job_request, project_file):
with mock.patch("jobrunner.create_or_update_jobs.get_project_file") as f:
f.return_value = project_file
Expand Down

0 comments on commit e4e8fc1

Please sign in to comment.