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

Detect invalid encoding size earlier #507

Merged
merged 3 commits into from
Feb 20, 2020
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
12 changes: 12 additions & 0 deletions backend/entityservice/database/insertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,18 @@ def update_run_mark_failure(conn, run_id):
cur.execute(sql_query, [run_id])


def update_project_mark_all_runs_failed(conn, project_id):
with conn.cursor() as cur:
sql_query = """
UPDATE runs SET
state = 'error',
time_completed = now()
WHERE
project = %s
"""
cur.execute(sql_query, [project_id])


def mark_project_deleted(db, project_id):
with db.cursor() as cur:
sql_query = """
Expand Down
16 changes: 10 additions & 6 deletions backend/entityservice/tasks/comparing.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,16 @@ def compute_filter_similarity(chunk_info, project_id, run_id, threshold, encodin
span.log_kv({'event': 'chunks are fetched and deserialized'})
log.debug("Calculating filter similarity")
span.log_kv({'size1': chunk_dp1_size, 'size2': chunk_dp2_size})
chunk_results = anonlink.concurrency.process_chunk(
chunk_info,
(chunk_dp1, chunk_dp2),
anonlink.similarities.dice_coefficient_accelerated,
threshold,
k=min(chunk_dp1_size, chunk_dp2_size))
try:
chunk_results = anonlink.concurrency.process_chunk(
chunk_info,
(chunk_dp1, chunk_dp2),
anonlink.similarities.dice_coefficient_accelerated,
threshold,
k=min(chunk_dp1_size, chunk_dp2_size))
except NotImplementedError as e:
log.warning("Encodings couldn't be compared using anonlink.")
return
Copy link
Contributor

Choose a reason for hiding this comment

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

return nothing? Is this equivalent to return None?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sure is

t3 = time.time()
span.log_kv({'event': 'similarities calculated'})

Expand Down
9 changes: 6 additions & 3 deletions backend/entityservice/tasks/pre_run_check.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from entityservice.async_worker import celery, logger
from entityservice.database import DBConn, get_created_runs_and_queue, get_uploaded_encoding_sizes, \
get_project_schema_encoding_size, get_project_encoding_size, set_project_encoding_size
get_project_schema_encoding_size, get_project_encoding_size, set_project_encoding_size, \
update_project_mark_all_runs_failed
from entityservice.models.run import progress_run_stage as progress_stage
from entityservice.settings import Config as config
from entityservice.tasks.base_task import TracedTask
Expand All @@ -25,7 +26,8 @@ def check_for_executable_runs(project_id, parent_span=None):
check_and_set_project_encoding_size(project_id, conn)
except ValueError as e:
log.warning(e.args[0])
# todo make sure this can be exposed to user
# make sure this error can be exposed to user by marking the run/s as failed
update_project_mark_all_runs_failed(conn, project_id)
return
new_runs = get_created_runs_and_queue(conn, project_id)

Expand Down Expand Up @@ -72,4 +74,5 @@ def check_and_set_project_encoding_size(project_id, conn):
handle_invalid_encoding_data(project_id, dp_id)
raise ValueError("Encoding size out of configured bounds")


if encoding_size % 8:
raise ValueError("Encoding size must be multiple of 8 bytes (64 bits)")