diff --git a/.github/workflows/backend-github.yml b/.github/workflows/backend-github.yml index 9fb666f3..43c536a3 100644 --- a/.github/workflows/backend-github.yml +++ b/.github/workflows/backend-github.yml @@ -64,15 +64,13 @@ jobs: python -m pip install --upgrade pip pip install flake8 pytest if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - if [ -f pavimafinance/requirements.txt ]; then pip install -r pavimafinance/requirements.txt; fi - if [ -f pavimafinance/requirements.txt ]; then pip install -e pavimafinance; fi - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + flake8 . --exclude benchmark --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + flake8 . --exclude benchmark --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics build: name: 🐋 Save docker image diff --git a/backend/tests/iga/test_elastic.py b/backend/tests/iga/test_elastic.py index 9091dcbe..f9ab74a9 100644 --- a/backend/tests/iga/test_elastic.py +++ b/backend/tests/iga/test_elastic.py @@ -113,7 +113,7 @@ def test_search(): threshold_file = threshold_file) #print(hits, length_req, bande) - assert res['hits'][0]['_id'] == 'BF2016-08-16010-dfci.pdf', 'Found to result %s'%hits[0]['_id'] + assert res['hits'][0]['_id'] == 'BF2016-08-16010-dfci.pdf', 'Found to result %s'%res['hits'][0]['_id'] assert res['length']>= 2, res['length'] assert not res['band'] #import pdb; pdb.set_trace() diff --git a/backend/tools/converter.py b/backend/tools/converter.py index be7e912e..573a995b 100644 --- a/backend/tools/converter.py +++ b/backend/tools/converter.py @@ -135,17 +135,3 @@ def save_json(data, json_file: str): doc = "CALLMI_FS_015_Simplifiée - Message terminal déjà utilisé avec une autre carte.odt" path = '/data/user/odt/%s'%doc data = odt2json(path, sections) - - path = '/app/tests/doc.odt' - data = convertisseur_odt_txt(path) - save_json(data, 'docOdt.json') - - path = '/app/tests/doc.pdf' - txt = convertisseur_pdf_txt(path) - name = 'doc name' - Titre = 'doc titre' - Date = 'doc date' - Auteurs = 'doc auteur 1' - data = dict(Titre=Titre, Date=Date,Auteurs=Auteurs) - data['Corps'] = txt - save_json(data, 'doc.json') diff --git a/backend/tools/elastic.py b/backend/tools/elastic.py index 1f1d08ce..a5b86e2e 100644 --- a/backend/tools/elastic.py +++ b/backend/tools/elastic.py @@ -3,7 +3,7 @@ import elasticsearch from elasticsearch import Elasticsearch, NotFoundError -import os +import os, sys import base64 import json import logging @@ -41,7 +41,7 @@ def simple_request(index_name, size): } } - D = es.search(index=str(INDEX_NAME_prop), size=size, body=request) + D = es.search(index=str(index_name), size=size, body=request) return D['hits']['hits'] def clean(expression:str, index_name:str, analyzer="clean_analyser"): @@ -169,7 +169,7 @@ def build_query(must: dict, should: dict, filter: dict, index_name: str, def search(must: dict, should: dict, filter: dict, index_name: str, highlight: list, - glossary_file=None, expression_file=None, threshold_file=None): + glossary_file=None, expression_file=None, threshold_file=None, size=10e2): """Perform the ES search Args: @@ -218,7 +218,7 @@ def search(must: dict, should: dict, filter: dict, index_name: str, thresholds['r_threshold'] = 0 try: #This try is for the case where no match is found - if not T and D['hits']['hits'][0]["_score"]/length_of_request < seuil: #The first filter then the second filter + if not T and D['hits']['hits'][0]["_score"]/length_of_request < size: #The first filter then the second filter Bande = True except: pass