From e94bc8aec15c677f246d9755266753d51e255842 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Thu, 28 Dec 2023 16:44:02 +0330 Subject: [PATCH] fix: linter issues based on superlinter rules! --- celery_app/tasks.py | 2 +- discord_query.py | 12 +++++------- retrievers/forum_summary_retriever.py | 3 +-- retrievers/summary_retriever_base.py | 5 ++--- tests/unit/test_discord_summary_retriever.py | 4 +--- tests/unit/test_summary_retriever_base.py | 2 +- worker.py | 5 ++--- 7 files changed, 13 insertions(+), 20 deletions(-) diff --git a/celery_app/tasks.py b/celery_app/tasks.py index 73652a7..e2025af 100644 --- a/celery_app/tasks.py +++ b/celery_app/tasks.py @@ -1,5 +1,5 @@ -from celery_app.server import app from celery_app.job_send import job_send +from celery_app.server import app # TODO: Write tasks that match our requirements diff --git a/discord_query.py b/discord_query.py index 6bb6fb8..d65829a 100644 --- a/discord_query.py +++ b/discord_query.py @@ -1,12 +1,10 @@ -from retrievers.forum_summary_retriever import ( - ForumBasedSummaryRetriever, -) +from llama_index import QueryBundle +from llama_index.vector_stores import ExactMatchFilter, FilterCondition, MetadataFilters +from retrievers.forum_summary_retriever import ForumBasedSummaryRetriever from retrievers.process_dates import process_dates from retrievers.utils.load_hyperparams import load_hyperparams from tc_hivemind_backend.embeddings.cohere import CohereEmbedding from tc_hivemind_backend.pg_vector_access import PGVectorAccess -from llama_index import QueryBundle -from llama_index.vector_stores import ExactMatchFilter, FilterCondition, MetadataFilters def query_discord( @@ -140,8 +138,8 @@ def query_discord_auto_filter( response = query_discord( community_id=community_id, query=query, - thread_names=threads, - channel_names=channels, + thread_names=list(threads), + channel_names=list(channels), days=dates_modified, ) return response diff --git a/retrievers/forum_summary_retriever.py b/retrievers/forum_summary_retriever.py index 58b4d3e..8a3c16c 100644 --- a/retrievers/forum_summary_retriever.py +++ b/retrievers/forum_summary_retriever.py @@ -1,8 +1,7 @@ +from llama_index.embeddings import BaseEmbedding from retrievers.summary_retriever_base import BaseSummarySearch from tc_hivemind_backend.embeddings.cohere import CohereEmbedding -from llama_index.embeddings import BaseEmbedding - class ForumBasedSummaryRetriever(BaseSummarySearch): def __init__( diff --git a/retrievers/summary_retriever_base.py b/retrievers/summary_retriever_base.py index 8cedca8..1cc3420 100644 --- a/retrievers/summary_retriever_base.py +++ b/retrievers/summary_retriever_base.py @@ -1,10 +1,9 @@ -from tc_hivemind_backend.embeddings.cohere import CohereEmbedding - -from tc_hivemind_backend.pg_vector_access import PGVectorAccess from llama_index import VectorStoreIndex from llama_index.embeddings import BaseEmbedding from llama_index.indices.query.schema import QueryBundle from llama_index.schema import NodeWithScore +from tc_hivemind_backend.embeddings.cohere import CohereEmbedding +from tc_hivemind_backend.pg_vector_access import PGVectorAccess class BaseSummarySearch: diff --git a/tests/unit/test_discord_summary_retriever.py b/tests/unit/test_discord_summary_retriever.py index 915742c..6c73bc3 100644 --- a/tests/unit/test_discord_summary_retriever.py +++ b/tests/unit/test_discord_summary_retriever.py @@ -3,11 +3,9 @@ from unittest import TestCase from unittest.mock import MagicMock -from retrievers.forum_summary_retriever import ( - ForumBasedSummaryRetriever, -) from dateutil import parser from llama_index import Document, MockEmbedding, ServiceContext, VectorStoreIndex +from retrievers.forum_summary_retriever import ForumBasedSummaryRetriever class TestDiscordSummaryRetriever(TestCase): diff --git a/tests/unit/test_summary_retriever_base.py b/tests/unit/test_summary_retriever_base.py index f630d94..0575a4b 100644 --- a/tests/unit/test_summary_retriever_base.py +++ b/tests/unit/test_summary_retriever_base.py @@ -2,9 +2,9 @@ from unittest import TestCase from unittest.mock import MagicMock -from retrievers.summary_retriever_base import BaseSummarySearch from llama_index import Document, MockEmbedding, ServiceContext, VectorStoreIndex from llama_index.schema import NodeWithScore +from retrievers.summary_retriever_base import BaseSummarySearch class TestSummaryRetrieverBase(TestCase): diff --git a/worker.py b/worker.py index dcea119..fca2379 100644 --- a/worker.py +++ b/worker.py @@ -1,13 +1,12 @@ +from celery_app.tasks import add from tc_messageBroker import RabbitMQ from tc_messageBroker.rabbit_mq.event import Event from tc_messageBroker.rabbit_mq.queue import Queue -from celery_app.tasks import add - # TODO: Update according to our requirements def do_something(recieved_data): - message = f"Calculation Results:" + message = "Calculation Results:" print(message) print(f"recieved_data: {recieved_data}") add.delay(20, 14)