Ramesh Balasubramaniam

12 papers B 5Journal 7
YearRankTypeTitle / Venue / Authors
2023 J jnl
Cogn. Sci.
Shannon Proksch, Majerle Reeves, Kent Gee, Mark K. Transtrum, Christopher T. Kello, Ramesh Balasubramaniam
2021 J jnl
Int. J. Child Comput. Interact.
Sofia Tancredi, Rotem Abdu, Dor Abrahamson, Ramesh Balasubramaniam
2019 J jnl
Cogn. Sci.
Chelsea Gordon, Timothy M. Shea, David C. Noelle, Ramesh Balasubramaniam
2018 J jnl
Top. Cogn. Sci.
Ramesh Balasubramaniam, Michael J. Hove, Butovens Médé
2018 J jnl
Frontiers Comput. Neurosci.
Daniel C. Comstock, Michael J. Hove, Ramesh Balasubramaniam
2018 J jnl
J. Cogn. Neurosci.
Jessica Ross, John R. Iversen, Ramesh Balasubramaniam
2017 B conf
CogSci
Chelsea Gordon, Ramesh Balasubramaniam
2016 B conf
CogSci
Chelsea Gordon, Ramesh Balasubramaniam, Michael J. Spivey
2016 B conf
CogSci
Butovens Médé, Ramesh Balasubramaniam, Christopher T. Kello
2015 B conf
CogSci
Jessica Ross, Anne S. Warlaumont, Lillian Rigoli, Ramesh Balasubramaniam
2014 B conf
CogSci
Janelle Szary, Eric Chiu, Ramesh Balasubramaniam
2004 J jnl
Biol. Cybern.
Ramesh Balasubramaniam, Michael T. Turvey
redb/utils/push_to_elastic.py
← Index redb/utils/push_to_elastic.py python
import json
import os
#from redb.settings import elasticsearch as es
from elasticsearch import Elasticsearch
from dataclasses import asdict
from dotenv import load_dotenv

class Utils():
    """
    Utility class for pushing

    """
    @staticmethod
    def push_to_elastic(sample_dict):
        """
        Pushes the sample_dict to elastic search
        """
        load_dotenv()
        ELASTIC_ENDPOINT = os.getenv("ELASTIC_HOST")
        ELASTIC_ENFORCE_SSL = os.getenv("ELASTIC_ENFORCE_SSL", False) == "True"
        ELASTIC_USER = os.getenv("ELASTIC_USER")
        ELASTIC_PASSWORD = os.getenv("ELASTIC_PASSWORD")
        ELASTIC_BINARIES_COLLECTION = os.getenv(
            "ELASTIC_BINARIES_COLLECTION", "redb_test"
        )
        es = Elasticsearch(
            ELASTIC_ENDPOINT,
            verify_certs=ELASTIC_ENFORCE_SSL,
            basic_auth=(ELASTIC_USER, ELASTIC_PASSWORD),
            maxsize=20,
            retry_on_timeout=True,
            timeout=30,
        )

        try:
            dict_dump = json.dumps(sample_dict)
        except Exception as e:
            print(f"Error: {e}")
            return False
        elastic = es.index(index=ELASTIC_BINARIES_COLLECTION, body=dict_dump)
        return True
    
    def push_to_index(sample_dict, index_name):
        """
        Pushes the sample_dict to elastic search
        """
        load_dotenv()
        ELASTIC_ENDPOINT = os.getenv("ELASTIC_HOST")
        ELASTIC_ENFORCE_SSL = os.getenv("ELASTIC_ENFORCE_SSL", False) == "True"
        ELASTIC_USER = os.getenv("ELASTIC_USER")
        ELASTIC_PASSWORD = os.getenv("ELASTIC_PASSWORD")
        ELASTIC_BINARIES_COLLECTION = index_name
        
        es = Elasticsearch(
            ELASTIC_ENDPOINT,
            verify_certs=ELASTIC_ENFORCE_SSL,
            basic_auth=(ELASTIC_USER, ELASTIC_PASSWORD),
            maxsize=20,
            retry_on_timeout=True,
            timeout=30,
        )

        try:
            dict_dump = json.dumps(sample_dict)
        except Exception as e:
            print(f"Error: {e}")
            return False
        elastic = es.index(index=ELASTIC_BINARIES_COLLECTION, body=dict_dump)
        return True