def __init__(self): super(JDXGraphFeatures, self).__init__() self.job_name = "jdx_graph_features" self.queue_flow = message_manager.get_queue(cm.config['queue']['flow']) self.queue_name = cm.config['queue_server']['name'] self.queue_ml_graph = message_manager.get_queue( cm.config['queue']['ml_graph']) self.stop_server = False self.mongo_client = mongo.Mongo(**cm.config['mongo_jd_cl']) self.jdx_data = jdx_data.JDXData(self.mongo_client)
def __send_message(self, flow, flow_record): queue = message_manager.get_queue(flow['queue'], with_new_client=True) message_tpl = flow['message'].copy() message_to_send = self.__build_message(message_tpl, flow_record['variables']) queue.send_message(message_to_send, delay_seconds=flow.get('delayed_seconds', -1)) flow_record['sent_messages'].append(message_to_send) flow_record['finished_flows'].append(flow['name'])
def __init__(self): super().__init__() self.queue_flow = mm.get_queue(cm.config['queue_flow']['name']) self.mysql_ml = MySql(**cm.config['mysql_jd_cl']) self.mongo_derivate = Mongo(**cm.config['mongo_jd_cl']) self.rule_config_list = self.get_rule_list() self.group_tag_config_list = self.get_group_tag_list()
def test_send_message(self): mm.setup_message( "http://1667348596157055.mns.cn-hangzhou.aliyuncs.com", "LTAISSRtsh6JnpTW", "0AOhWeUfbkPnQf01OlGO7BnR4w47Ts") q = mm.get_queue("TestMachineLearningQueue") data = {'data': 'message from ml queue test ...'} result = q.send_message(json.dumps(data)) self.assertTrue(result)
def setup_message(self): mc = cm.config['queue_server'] mm.setup_message(mc['host'], mc['access_id'], mc['access_key'], logger=logging.getLogger('elogger')) self.queue = mm.get_queue(mc['name']) logging.info("message setup finished")
def __init__(self): super(JDXMLWithdrawModelServer, self).__init__() self.queue_flow = message_manager.get_queue( cm.config['queue_flow']['name']) self.mysql_ml = MySql(**cm.config['mysql_jd_cl']) self.mongo_der = Mongo(**cm.config['mongo_jd_cl']) self.model_config_list = self.get_model_list() self.group_tag_threshold = self.get_group_tag_threshold()
def __init__(self): super(JDXMLCreditServer, self).__init__() self.queue_flow = message_manager.get_queue( cm.config['queue_flow']['name']) self.mysql_ml = MySql(**cm.config['mysql_jd_cl']) self.mongo_der = Mongo(**cm.config['mongo_jd_cl']) self.model_config_list = self.get_model_list() self.target = 'jd'
def __init__(self): super(JDXModifyQuota, self).__init__() self.queue_flow = message_manager.get_queue( cm.config['queue_flow']['name']) self.mysql_ml = MySql(**cm.config['mysql_jd_cl']) self.mongo_derivable = Mongo(**cm.config['mongo_jd_cl']) self.quota_modify_strategy_list = self.get_quota_modify_strategy_list( ) # 获取全部额度变更策略配置
def test_consume_message(self): mm.setup_message( "http://1667348596157055.mns.cn-hangzhou.aliyuncs.com", "LTAISSRtsh6JnpTW", "0AOhWeUfbkPnQf01OlGO7BnR4w47Ts") q = mm.get_queue("TestMachineLearningQueue") result, message = q.consume_message() print(message) self.assertTrue(result) self.assertIsNotNone(message)
def _send_message(self, product_name, app_id, graph_features, back_queue): queue_flow = message_manager.get_queue(back_queue) queue_flow.send_message({ "app_id": app_id, "job_name": self.job_name, "product_name": product_name, "graph_features": graph_features }) logging.info("app_id:{}, product_name:{}, graph calculate done.".format(app_id, product_name))
def run(self): executor = None if self.processes > 1: executor = ThreadPoolExecutor(max_workers=self.processes) while not self.stop_server: try: success, msg_dict = self.queue.consume_message() if not success: time.sleep(self.idle_seconds) continue if executor: mc = cm.config['queue_server'] queue = mm.get_queue(mc['name'], True) executor.submit(self.handle_message, msg_dict, queue) else: self.handle_message(msg_dict, self.queue) except Exception as ex: self.handle_exception(ex)
def __init__(self): super().__init__() self.queue_flow = mm.get_queue(cm.config['queue_flow']['name']) self.mysql_ml = MySql(**cm.config['mysql_jd_cl']) self.mongo_derivate = Mongo(**cm.config['mongo_jd_cl']) self.category_list = self.get_category_configs()
def __init__(self): super().__init__() self.queue_flow = mm.get_queue(cm.config['queue']['flow']) self.mysql_ml = MySql(**cm.config['mysql_jd_cl'])
def __init__(self): super().__init__() self.mongo_derivate = mongo.Mongo(**cm.config['mongo_derivatives']) self.mysql_ml = mysql.MySql(**cm.config['mysql_jd_cl']) self.queue_flow = mm.get_queue(cm.config['queue']['flow'])