Beispiel #1
0
 def __init__(self):
     self.redis_client = RedisConnectionManager().get_client()
     self.queue_to_read = os.environ["CONTATCS_FOR_UPDATE_QUEUE"]
     self.redis_reader = RedisReader(
         self.queue_to_read, os.environ["MAX_BUFFER_SENDER"]
     )
     self.redis_writer = RedisWriter()
     self.contact_post_api_url = os.environ["CONTACT_POST_API_URL"]
     self.contacts_for_update = []
     self.processed_contacts = {}
Beispiel #2
0
 def __init__(self):
     self.contacts_for_prediction = os.environ[
         "CONTATCS_FOR_PREDICTION_QUEUE"]
     self.contacts_for_update = os.environ["CONTATCS_FOR_UPDATE_QUEUE"]
     self.redis_reader = RedisReader(
         os.environ["PREDICTABLE_CONTACTS_QUEUE"],
         os.environ["MAX_BUFFER_PREPROCESSOR"],
     )
     self.redis_writer = RedisWriter()
     self.contacts = {
         self.contacts_for_prediction: [],
         self.contacts_for_update: []
     }
Beispiel #3
0
def test_read_from_redis(mocked_get_client):
    # arange
    queue_to_read = "QUEUE_A"
    max_buffer = 2
    redis_queue = [
        b"[{'objectId': 1549880507, 'subscriptionType': 'deal.propertyChange'}]",
        b"[{'objectId': 383611195, 'subscriptionType': 'contact.creation'}]",
    ]
    mocked_get_client.return_value.lrange.return_value = redis_queue
    # act
    redis_reader = RedisReader(queue_to_read, max_buffer)
    response = redis_reader()
    # assert
    assert response == _EXPECTED_RESPONSE
Beispiel #4
0
    def __init__(self):

        self.queue_to_read = os.environ["CONTATCS_FOR_PREDICTION_QUEUE"]
        self.contacts_for_update = os.environ["CONTATCS_FOR_UPDATE_QUEUE"]
        self.redis_reader = RedisReader(self.queue_to_read,
                                        os.environ["MAX_BUFFER_MODEL"])
        self.redis_writer = RedisWriter()
        self.relevant_columns = ast.literal_eval(
            ast.literal_eval(os.environ["DATA_TRAIN_COLUMNS"]))
        train_objects = ModelTrainer()()
        self.model = train_objects["model"]
        self.reference_dicts = train_objects["reference_dicts"]
        self.contacts = {self.contacts_for_update: []}
        self.dataframe = pd.DataFrame()
Beispiel #5
0
    def __init__(self, queue_to_read=None):
        self.redis_client = RedisConnectionManager().get_client()
        self.deal_api_url = os.environ["DEAL_API_URL"]
        self.contact_api_url = os.environ["CONTACT_GET_API_URL"]
        self.contact_creation_subscription = os.environ[
            "CONTACT_CREATION_SUBSCRIPTION"]
        self.predictable_contacts = os.environ["PREDICTABLE_CONTACTS_QUEUE"]
        self.contacts_for_update = os.environ["CONTATCS_FOR_UPDATE_QUEUE"]

        if queue_to_read is None:
            self.queue_to_read = os.environ["QUEUE_TO_READ"]
        else:
            self.queue_to_read = queue_to_read

        max_buffer = os.environ["MAX_BUFFER_COLLETOR"]
        self.redis_reader = RedisReader(self.queue_to_read, max_buffer)
        self.redis_writer = RedisWriter()
        self.contacts_id_to_fetch = []
        self.contacts = {
            self.predictable_contacts: [],
            self.contacts_for_update: [],
        }
        self.processed_items = {}