Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions backend/entityservice/database/insertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,6 @@ def update_run_mark_failure(conn, run_id):
cur.execute(sql_query, [run_id])


def update_run_mark_queued(db, run_id):
with db.cursor() as cur:
sql_query = """
UPDATE runs SET
state = 'queued'
WHERE
run_id = %s
"""
cur.execute(sql_query, [run_id])


def mark_project_deleted(db, project_id):
with db.cursor() as cur:
sql_query = """
Expand Down Expand Up @@ -263,7 +252,7 @@ def get_created_runs_and_queue(db, project_id):
UPDATE runs SET
state = 'queued'
WHERE
state IN ('created', 'queued') AND project = %s
state = 'created' AND project = %s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

RETURNING
run_id;
"""
Expand Down
24 changes: 6 additions & 18 deletions backend/entityservice/views/run/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from entityservice import database as db
from entityservice.tasks import check_for_executable_runs
from entityservice.database import get_runs, update_run_mark_queued
from entityservice.database import get_runs
from entityservice.models.run import Run
from entityservice.utils import safe_fail_request
from entityservice.views.auth_checks import abort_if_project_doesnt_exist, abort_if_invalid_results_token, \
Expand Down Expand Up @@ -44,23 +44,11 @@ def post(project_id, run):

with db.DBConn() as db_conn:
run_model.save(db_conn)
project_object = db.get_project(db_conn, project_id)
parties_contributed = db.get_number_parties_uploaded(db_conn, project_id)
ready_to_run = parties_contributed == project_object['parties']
log.debug("Expecting {} parties to upload data. Have received {}".format(
project_object['parties'], parties_contributed
))
if ready_to_run:
log.info("Scheduling task to carry out all runs for project {} now".format(project_id))
update_run_mark_queued(db_conn, run_model.run_id)
else:
log.info("Task queued but won't start until CLKs are all uploaded")

if ready_to_run:
span = g.flask_tracer.get_span()
span.set_tag("run_id", run_model.run_id)
span.set_tag("project_id", run_model.project_id)
check_for_executable_runs.delay(project_id, serialize_span(span))

span = g.flask_tracer.get_span()
span.set_tag("run_id", run_model.run_id)
span.set_tag("project_id", run_model.project_id)
check_for_executable_runs.delay(project_id, serialize_span(span))
return RunDescription().dump(run_model), 201


Expand Down
2 changes: 1 addition & 1 deletion backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pytest==5.1.3
pytest-xdist==1.29.0
PyYAML==5.1
redis==3.2.1
requests==2.21.0
requests==2.22.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add this dependency update in the changelog.

setproctitle==1.1.10 # used by celery to change process name
structlog==18.2.0
tenacity==5.1.1
Expand Down