def main2(): config = DBConfig( host=os.environ.get("DB_HOST"), port=os.environ.get("DB_PORT"), username=os.environ.get("DB_USERNAME"), password=os.environ.get("DB_PASSWORD"), db_name=os.environ.get("DB_NAME"), ) logger = LoggerFactory.get_logger(logger_type="print", logger_name="debug_db") db_instance = DBFactory.get_db_instance(db_config=config, log_instance=logger) # テーブルの作成 db_instance.create_all_tables_if_needed() # BodyInfoの追加 ids = db_instance.insert_body_infos(body_infos=[ BodyInfo(body="てすとです", created_at=datetime.now()), BodyInfo(body="てすとです2", created_at=datetime.now()), ]) # SuammarizerResultの追加 result_list = [ SummarizeResult(body_id=id, predicted_text="予測です", label_text="外れます") for id in ids ] result_ids = db_instance.insert_summarize_results(result_infos=result_list) logger.info("result ids is {}".format(result_ids))
def setUp(self) -> None: self.queue_config = QueueConfig( host="dummy", port=0, optional_param={ "timeout": 5000, "topic_name": "test" }, ) self.db_config = DBConfig( host="test_db", port="0", username="******", password="******", db_name="test", ) self.logger = LoggerFactory.get_logger(logger_type="print", logger_name="test_summarizer") self.db_instance = DBForTest( config=self.db_config, log_instance=self.logger, dummy_body_infos=[], dummy_job_infos=[], dummy_result_infos=[], ) self.queue = QueueConsumerForTest(config=self.queue_config, logger=self.logger)
def create_db_config(): config = DBConfig( host=os.environ.get("DB_HOST"), port=os.environ.get("DB_PORT"), username=os.environ.get("DB_USERNAME"), password=os.environ.get("DB_PASSWORD"), db_name=os.environ.get("DB_NAME"), db_type=os.environ.get("DB_TYPE"), ) return config
def setUpClass(cls) -> None: cls.config = DBConfig( host=os.environ.get("DB_HOST"), port=os.environ.get("DB_PORT"), username=os.environ.get("DB_USERNAME"), password=os.environ.get("DB_PASSWORD"), db_name="test_summarizer_db", # db_name=os.environ.get("DB_NAME") db_type="mysql", ) log_instance = LoggerFactory.get_logger(logger_type="print", logger_name="test_db_wrapper") cls.db_instance = DBFactory.get_db_instance(db_config=cls.config, log_instance=log_instance) cls.db_instance.create_all_tables_if_needed()
def setUpClass(cls): cls.config = DBConfig( host="", port="", username="", password="", db_name="test_youyaku_ai_db", db_type="bigquery", ) cls.log_instance = LoggerFactory.get_logger( logger_type="print", logger_name="test_bq_db_wrapper") cls.db_instance = DBFactory.get_db_instance( db_config=cls.config, log_instance=cls.log_instance) cls.db_instance.create_database_if_needed() cls.db_instance.create_all_tables_if_needed()
def setUp(self) -> None: self.queue_config = QueueConfig( host="dummy", port=0, optional_param={ "timeout": 5000, "topic_name": "test" }, ) self.db_config = DBConfig( host="test_db", port="0", username="******", password="******", db_name="test", ) self.logger = LoggerFactory.get_logger(logger_type="print", logger_name="test_api")