Skip to content

Commit

Permalink
🐛 flake8 corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
victorjourne committed Oct 20, 2023
1 parent 644a102 commit 823a960
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 23 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/backend-github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/iga/test_elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
14 changes: 0 additions & 14 deletions backend/tools/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
8 changes: 4 additions & 4 deletions backend/tools/elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import elasticsearch
from elasticsearch import Elasticsearch, NotFoundError
import os
import os, sys
import base64
import json
import logging
Expand Down Expand Up @@ -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"):
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 823a960

Please sign in to comment.