Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix starting runs #459

Merged
merged 4 commits into from
Nov 4, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 7 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ Changelog
Next Version
------------

- fixed bug where invalid state changes could occur when starting a run (#459)
- ``matching`` output type has been removed as redundant with the ``groups`` output with 2 parties. (#458)

- Update dependencies:

- requests from 2.21.0 to 2.22.0 (#459)

Breaking Change
~~~~~~~~~~~~~~~

- ``matching`` output type is not available anymore. (#458)


Version 1.12.0
--------------

Expand Down Expand Up @@ -58,7 +64,7 @@ Version 1.12.0
- Update dependencies:

- anonlink to v0.12.5. (#423)
- redis to from 3.2.0 to 3.2.1 (#415)
- redis from 3.2.0 to 3.2.1 (#415)
- alpine from 3.9 to 3.10.1 (#404)

- Add some release documentation. (#455)
Expand Down