From c46fe40eb5d1c39773568df583c3caa100305c82 Mon Sep 17 00:00:00 2001 From: Dario Lopez Padial Date: Fri, 29 Sep 2023 19:16:15 +0200 Subject: [PATCH] sorting imports --- requirements.txt | 6 +++++- src/email/send_email.py | 3 +-- src/etls/etl_common.py | 7 +++---- src/etls/etl_daily.py | 3 +-- src/etls/etl_initial.py | 5 ++--- src/etls/scrapper/base.py | 2 +- src/etls/scrapper/boe.py | 10 +++++----- src/etls/utils.py | 6 +++--- src/initialize.py | 15 ++++++++------- src/service/main.py | 3 +-- src/utils.py | 6 +++--- 11 files changed, 33 insertions(+), 33 deletions(-) diff --git a/requirements.txt b/requirements.txt index 0b72fc5..37f253b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,4 +17,8 @@ pinecone-client==2.2.2 sentence_transformers==2.2.2 openai==0.27.8 -sendgrid==6.10.0 \ No newline at end of file +sendgrid==6.10.0 + +# Clean code tools +black==23.9.1 +isort==5.12.0 diff --git a/src/email/send_email.py b/src/email/send_email.py index 4144bee..d0408e6 100644 --- a/src/email/send_email.py +++ b/src/email/send_email.py @@ -2,11 +2,10 @@ import os from sendgrid import SendGridAPIClient -from sendgrid.helpers.mail import Email, To, Content, Mail +from sendgrid.helpers.mail import Content, Email, Mail, To from src.initialize import initialize_logging - initialize_logging() diff --git a/src/etls/etl_common.py b/src/etls/etl_common.py index 2fc2fa4..4607f5b 100644 --- a/src/etls/etl_common.py +++ b/src/etls/etl_common.py @@ -2,15 +2,14 @@ import os import typing as tp -from langchain.text_splitter import CharacterTextSplitter -from langchain.schema import Document import pinecone +from langchain.schema import Document +from langchain.text_splitter import CharacterTextSplitter from retry import retry -from src.etls.utils import BOETextLoader, BOEMetadataDocument +from src.etls.utils import BOEMetadataDocument, BOETextLoader from src.initialize import initialize_logging - initialize_logging() diff --git a/src/etls/etl_daily.py b/src/etls/etl_daily.py index 03c41e9..3eabfcf 100644 --- a/src/etls/etl_daily.py +++ b/src/etls/etl_daily.py @@ -1,10 +1,9 @@ from datetime import date +from src.email.send_email import send_email from src.etls.etl_common import ETL from src.etls.scrapper.boe import BOEScrapper from src.initialize import initialize_app -from src.email.send_email import send_email - if __name__ == '__main__': INIT_OBJECTS = initialize_app() diff --git a/src/etls/etl_initial.py b/src/etls/etl_initial.py index 53f0c0f..56915c8 100644 --- a/src/etls/etl_initial.py +++ b/src/etls/etl_initial.py @@ -1,10 +1,9 @@ from datetime import datetime +from src.email.send_email import send_email from src.etls.etl_common import ETL -from src.initialize import initialize_app from src.etls.scrapper.boe import BOEScrapper -from src.email.send_email import send_email - +from src.initialize import initialize_app if __name__ == '__main__': INIT_OBJECTS = initialize_app() diff --git a/src/etls/scrapper/base.py b/src/etls/scrapper/base.py index 1396193..b82e1e1 100644 --- a/src/etls/scrapper/base.py +++ b/src/etls/scrapper/base.py @@ -1,5 +1,5 @@ -from abc import ABC, abstractmethod import typing as tp +from abc import ABC, abstractmethod from datetime import date from src.etls.utils import BOEMetadataDocument diff --git a/src/etls/scrapper/boe.py b/src/etls/scrapper/boe.py index a892b8c..58ca521 100644 --- a/src/etls/scrapper/boe.py +++ b/src/etls/scrapper/boe.py @@ -1,19 +1,19 @@ import copy import logging as lg -import typing as tp import tempfile +import typing as tp import unicodedata -from datetime import datetime, date, timedelta +from datetime import date, datetime, timedelta -from bs4 import BeautifulSoup import requests +from bs4 import BeautifulSoup from requests.exceptions import HTTPError from src.etls.scrapper.base import BaseScrapper -from src.etls.utils import BOEMetadataDocument, BOEMetadataReferencia, BOEMetadataDocument2 +from src.etls.utils import (BOEMetadataDocument, BOEMetadataDocument2, + BOEMetadataReferencia) from src.initialize import initialize_logging - initialize_logging() diff --git a/src/etls/utils.py b/src/etls/utils.py index 7e3fa9d..cfedc8f 100644 --- a/src/etls/utils.py +++ b/src/etls/utils.py @@ -1,10 +1,10 @@ -from dataclasses import dataclass -from datetime import datetime, date import typing as tp +from dataclasses import dataclass +from datetime import date, datetime -from pydantic import BaseModel, validator from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader +from pydantic import BaseModel, validator @dataclass diff --git a/src/initialize.py b/src/initialize.py index ab2d1ba..212fcb2 100644 --- a/src/initialize.py +++ b/src/initialize.py @@ -1,18 +1,19 @@ import collections import logging as lg import os -import yaml import pinecone -from supabase.client import Client, create_client -from langchain.prompts import ChatPromptTemplate, HumanMessagePromptTemplate, SystemMessagePromptTemplate -from langchain.vectorstores.pinecone import Pinecone -from langchain.embeddings import HuggingFaceEmbeddings +import yaml from langchain.chains import RetrievalQA from langchain.chat_models import ChatOpenAI -from qdrant_client.models import Distance, VectorParams -from qdrant_client import QdrantClient +from langchain.embeddings import HuggingFaceEmbeddings +from langchain.prompts import (ChatPromptTemplate, HumanMessagePromptTemplate, + SystemMessagePromptTemplate) +from langchain.vectorstores.pinecone import Pinecone from langchain.vectorstores.qdrant import Qdrant +from qdrant_client import QdrantClient +from qdrant_client.models import Distance, VectorParams +from supabase.client import Client, create_client from src.utils import StandardSupabaseVectorStore diff --git a/src/service/main.py b/src/service/main.py index b231c00..9965a95 100644 --- a/src/service/main.py +++ b/src/service/main.py @@ -3,9 +3,8 @@ from fastapi import FastAPI -from src.utils import QAResponsePayloadModel, timeit from src.initialize import initialize_app, initialize_logging - +from src.utils import QAResponsePayloadModel, timeit initialize_logging() diff --git a/src/utils.py b/src/utils.py index 1ae2663..117fa53 100644 --- a/src/utils.py +++ b/src/utils.py @@ -1,11 +1,11 @@ -import typing as tp -from functools import wraps import logging as lg import time +import typing as tp +from functools import wraps +from langchain.schema import Document from langchain.vectorstores import SupabaseVectorStore from pydantic import BaseModel -from langchain.schema import Document class StandardSupabaseVectorStore(SupabaseVectorStore):