Skip to content

Commit

Permalink
NO-REF: Remove Elastic Search Manager Ancestor (#435)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylevillegas93 authored Nov 7, 2024
1 parent c92de8f commit af95c3d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
14 changes: 8 additions & 6 deletions processes/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Optional

from .core import CoreProcess
from managers import SFRRecordManager, KMeansManager, SFRElasticRecordManager
from managers import SFRRecordManager, KMeansManager, SFRElasticRecordManager, ElasticsearchManager
from model import Record, Work
from logger import createLog

Expand All @@ -27,10 +27,12 @@ def __init__(self, *args):
self.createSession()

self.createRedisClient()

self.elastic_search_manager = ElasticsearchManager()

self.createElasticConnection()
self.createElasticSearchIngestPipeline()
self.createElasticSearchIndex()
self.elastic_search_manager.createElasticConnection()
self.elastic_search_manager.createElasticSearchIngestPipeline()
self.elastic_search_manager.createElasticSearchIndex()

def runProcess(self):
try:
Expand Down Expand Up @@ -135,7 +137,7 @@ def update_cluster_status(self, record_ids: list[str], cluster_status: bool=True
)

def update_elastic_search(self, works_to_index: list, word_ids_to_delete: set):
self.deleteWorkRecords(word_ids_to_delete)
self.elastic_search_manager.deleteWorkRecords(word_ids_to_delete)
self.index_works_in_elastic_search(works_to_index)

def delete_stale_works(self, work_ids: set[str]):
Expand Down Expand Up @@ -234,7 +236,7 @@ def index_works_in_elastic_search(self, works: Work):
elastic_manager.getCreateWork()
work_documents.append(elastic_manager.work)

self.saveWorkRecords(work_documents)
self.elastic_search_manager.saveWorkRecords(work_documents)

def titles_overlap(self, tokenized_record_title: set, tokenized_matched_record_title: set):
if len(tokenized_record_title) == 1 and not tokenized_record_title <= tokenized_matched_record_title:
Expand Down
5 changes: 2 additions & 3 deletions processes/core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from managers import DBManager, RabbitMQManager, RedisManager, ElasticsearchManager, S3Manager
from managers import DBManager, RabbitMQManager, RedisManager, S3Manager
from model import Record
from static.manager import StaticManager

Expand All @@ -8,8 +8,7 @@
logger = createLog(__name__)


class CoreProcess(DBManager, RabbitMQManager, RedisManager, StaticManager,
ElasticsearchManager, S3Manager):
class CoreProcess(DBManager, RabbitMQManager, RedisManager, StaticManager, S3Manager):
def __init__(self, process, customFile, ingestPeriod, singleRecord, batchSize=500):
super(CoreProcess, self).__init__()
self.process = process
Expand Down
4 changes: 0 additions & 4 deletions tests/unit/processes/test_core_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ def test_coreProcess_initial_values(self, coreInstance):
assert coreInstance.port == 'test_psql_port'
assert coreInstance.db == 'test_psql_name'

# Properties set by the ElasticSearchManager
assert coreInstance.index == 'test_es_index'
assert coreInstance.client is None

# Properties set by the RabbitMQManager
assert coreInstance.rabbitHost == 'test_rbmq_host'
assert coreInstance.rabbitPort == 'test_rbmq_port'
Expand Down

0 comments on commit af95c3d

Please sign in to comment.