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

workflows: only use matcher on help #4294

Closed
wants to merge 3 commits into from
Closed
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
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@
Procfile*
docker*
gun

**/__pycache__
**/*.pyc
15 changes: 5 additions & 10 deletions inspirehep/modules/workflows/tasks/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
extract_references_from_text,
extract_references_from_text_data,
)
from inspirehep.modules.refextract.matcher import match_references
from inspirehep.modules.workflows.utils import _get_headers_for_hep_root_table_request, create_error
from inspirehep.modules.workflows.errors import BadGatewayError, MissingRecordControlNumber
from inspirehep.modules.workflows.utils import (
Expand Down Expand Up @@ -474,10 +473,6 @@ def match_references_hep(references):
create_error(response)


def match_references_based_on_flag(references):
return match_references(references)


@with_debug_logging
def refextract(obj, eng):
"""Extract references from various sources and add them to the workflow.
Expand All @@ -497,7 +492,7 @@ def refextract(obj, eng):
if 'references' in obj.data:
extracted_raw_references = dedupe_list(extract_references_from_raw_refs(obj.data['references']))
obj.log.info('Extracted %d references from raw refs.', len(extracted_raw_references))
obj.data['references'] = match_references_based_on_flag(extracted_raw_references)
obj.data['references'] = match_references_hep(extracted_raw_references)
return

matched_pdf_references, matched_text_references = [], []
Expand All @@ -511,12 +506,12 @@ def refextract(obj, eng):
url, source=source, custom_kbs_file=journal_kb_dict
)
)
matched_pdf_references = match_references_based_on_flag(pdf_references)
matched_pdf_references = match_references_hep(pdf_references)
else:
with get_document_in_workflow(obj) as tmp_document:
if tmp_document:
pdf_references = dedupe_list(extract_references_from_pdf(tmp_document, source))
matched_pdf_references = match_references_based_on_flag(pdf_references)
matched_pdf_references = match_references_hep(pdf_references)

text = get_value(obj.extra_data, 'formdata.references')
if text and current_app.config.get("FEATURE_FLAG_ENABLE_REFEXTRACT_SERVICE"):
Expand All @@ -525,10 +520,10 @@ def refextract(obj, eng):
text, source=source, custom_kbs_file=journal_kb_dict
)
)
matched_text_references = match_references_based_on_flag(text_references)
matched_text_references = match_references_hep(text_references)
elif text:
text_references = dedupe_list(extract_references_from_text(text, source))
matched_text_references = match_references_based_on_flag(text_references)
matched_text_references = match_references_hep(text_references)

if not matched_pdf_references and not matched_text_references:
obj.log.info('No references extracted.')
Expand Down
2 changes: 0 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ omit =
inspirehep/wsgi.py
inspirehep/wsgi_with_coverage.py

[tool:pytest]
addopts = --cov=inspirehep --cov-report=term-missing:skip-covered

[flake8]
ignore = *.py E501 FI12 FI14 FI15 FI16 FI17 FI18 FI50 FI51 FI53 W504 W605 W743 W503
7 changes: 7 additions & 0 deletions tests/integration/workflows/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,13 @@ def mocked_external_services(workflow_app):
headers=_get_headers_for_hep_root_table_request(),
status_code=200,
)
requests_mocker.register_uri(
"POST",
"http://web:8000/api/matcher/linked_references/",
json={"references": []},
headers=_get_headers_for_hep_root_table_request(),
status_code=200,
)
if "INSPIREHEP_URL" in workflow_app.config:
# HEP record upload
requests_mocker.register_uri(
Expand Down
Loading
Loading