当前位置: 首页 > news >正文

fate-serving-server增加取数逻辑并源码编译

1.什么是fate-serving-server?

FATE-Serving 是一个高性能、工业化的联邦学习模型服务系统,专为生产环境而设计,主要用于在线推理。

2.fate-serving-server源码编译

下载fate-serving-serving项目(GitHub - FederatedAI/FATE-Serving: A scalable, high-performance serving system for federated learning models),并执行下面的命令

mvn clean
mvn package

3.修改日志输出等级

修改AsyncRoot的level等级为debug

修改AppenderRef中的info和console的日志等级为debug

具体配置文件如下:

<?xml version="1.0" encoding="UTF-8"?>
<!--~ Copyright 2019 The FATE Authors. All Rights Reserved.~~ Licensed under the Apache License, Version 2.0 (the "License");~ you may not use this file except in compliance with the License.~ You may obtain a copy of the License at~~     http://www.apache.org/licenses/LICENSE-2.0~~ Unless required by applicable law or agreed to in writing, software~ distributed under the License is distributed on an "AS IS" BASIS,~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.~ See the License for the specific language governing permissions and~ limitations under the License.-->
<Configuration status="ERROR" monitorInterval="60"><Properties><Property name="logdir">logs</Property><Property name="project">fate</Property><Property name="module">serving-server</Property></Properties><Appenders><Console name="console" target="SYSTEM_OUT"><PatternLayout charset="UTF-8"pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} [%-5p] %c{1.}(%F:%L) - %m%n"/></Console><RollingFile name="info" fileName="${logdir}/${project}-${module}.log"filePattern="${logdir}/%d{yyyy-MM-dd}/${project}-${module}.log.%d{yyyy-MM-dd}"><PatternLayout charset="UTF-8" pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} [%-5p] %c{1.}(%F:%L) - %m%n"/><Policies><TimeBasedTriggeringPolicy/></Policies><DefaultRolloverStrategy max="24"/></RollingFile><RollingFile name="flow" fileName="${logdir}/flow.log"filePattern="${logdir}/%d{yyyy-MM-dd}/flow.log.%d{yyyy-MM-dd}.log"><PatternLayout charset="UTF-8" pattern="%d{yyyy-MM-dd HH:mm:ss,SSS}|%m%n"/><Policies><TimeBasedTriggeringPolicy/></Policies><DefaultRolloverStrategy max="24"/></RollingFile><RollingFile name="error" fileName="${logdir}/${project}-${module}-error.log"filePattern="${logdir}/${project}-${module}-error.log.%d{yyyy-MM-dd}.log"><PatternLayout charset="UTF-8" pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} [%-5p] %c{1.}(%F:%L) - %m%n"/><Policies><TimeBasedTriggeringPolicy/></Policies><DefaultRolloverStrategy max="24"/></RollingFile><RollingFile name="debug" fileName="${logdir}/${project}-${module}-debug.log"filePattern="${logdir}/${project}-${module}-debug.log.%d{yyyy-MM-dd}.log"><PatternLayout charset="UTF-8" pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} [%-5p] %c{1.}(%F:%L) - %m%n"/><Policies><TimeBasedTriggeringPolicy/></Policies><DefaultRolloverStrategy max="24"/></RollingFile></Appenders><Loggers><logger name="org.apache.zookeeper" level="WARN"></logger><AsyncLogger name="flow" level="info" includeLocation="true" additivity="true"><AppenderRef ref="flow"/></AsyncLogger><!--<AsyncLogger name="debug" level="debug" includeLocation="true" additivity="false"><AppenderRef ref="debug"/></AsyncLogger>--><AsyncRoot level="debug" includeLocation="true"><AppenderRef ref="console" level="debug"/><AppenderRef ref="info" level="debug"/><AppenderRef ref="error" level="error"/></AsyncRoot></Loggers>
</Configuration>

4.在mockAdater增加host自定义取数逻辑

1.找到MockAdapter.java中的getData方法(取数逻辑)

/** Copyright 2019 The FATE Authors. All Rights Reserved.** Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at**     http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/package com.webank.ai.fate.serving.adaptor.dataaccess;import com.webank.ai.fate.serving.core.bean.Context;
import com.webank.ai.fate.serving.core.bean.ReturnResult;
import com.webank.ai.fate.serving.core.constant.StatusCode;
import com.webank.ai.fate.serving.core.utils.JsonUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;import java.util.HashMap;
import java.util.Map;public class MockAdapter extends AbstractSingleFeatureDataAdaptor {private static final Logger logger = LoggerFactory.getLogger(MockAdapter.class);@Overridepublic void init() {environment.getProperty("port");}@Overridepublic ReturnResult getData(Context context, Map<String, Object> featureIds) {logger.info("getData_featureIds:{}", featureIds);logger.info("Context:{}", context);logger.info("appId:{} callName:{} actionType:{} caseId:{},serviceId:{} servoceName:{}",context.getApplyId(), context.getCallName(), context.getActionType(), context.getCaseId(),context.getServiceId(), context.getServiceName());ReturnResult returnResult = new ReturnResult();Map<String, Object> data = new HashMap<>();try {String mockData = "x0:1,x1:5,x2:13,x3:58,x4:95,x5:352,x6:418,x7:833,x8:888,x9:937,x10:32776";for (String kv : StringUtils.split(mockData, ",")) {String[] a = StringUtils.split(kv, ":");data.put(a[0], Double.valueOf(a[1]));}returnResult.setData(data);returnResult.setRetcode(StatusCode.SUCCESS);if (logger.isDebugEnabled()) {logger.debug("MockAdapter result, {}", JsonUtil.object2Json(returnResult));}} catch (Exception ex) {logger.error(ex.getMessage());returnResult.setRetcode(StatusCode.SYSTEM_ERROR);}return returnResult;}
}
  1. 默认的取数逻辑是一个x0-x10的一个默认值,替换旧的取数逻辑
  2. 重新打包fate-serving-extension服务并替换对应的jar包

http://www.lryc.cn/news/56177.html

相关文章:

  • 循环队列、双端队列 C和C++
  • 正则表达式(语法+例子)
  • Properties和IO流集合的方法
  • python 生成器、迭代器、动态新增属性及方法
  • Java处理JSON
  • 58-Map和Set练习-LeetCode692前k个高频单词
  • 线程生命周期及五种状态
  • OBCP第八章 OB运维、监控与异常处理-灾难恢复
  • 亚马逊云科技Serverless Data:数字经济下的创新动能
  • 【Ruby学习笔记】15.Ruby 异常
  • 聊聊MySQL主从延迟
  • 【C++从0到1】19、C++中多条件的if语句
  • 【多微电网】计及碳排放的基于交替方向乘子法(ADMM)的多微网电能交互分布式运行策略研究(Matlab代码实现)
  • Linux(centos7)安装防火墙firewalld及开放端口相关命令
  • Linux部署.Net Core Web项目
  • 【C++】STL之stack、queue的使用和模拟实现+优先级队列(附仿函数)+容器适配器详解
  • 第⑦讲:Ceph集群RGW对象存储核心概念及部署使用
  • 从异步到promise
  • Linux系统中进行JDK环境的部署
  • Leetcode.1033 移动石子直到连续
  • 【Java】在SpringBoot中使用事务注解(@Transactional)时需要注意的点
  • 找到序列最高位的1和最高位的0并输出位置
  • 面试总结sdiugiho
  • WIN10無法再使用 IE 瀏覽器打开网页解决办法
  • 搭建SpringBoot和Mysql Demo
  • 晶振03——晶振烧坏的原因
  • 项目管理的难点
  • day22 ● 235. 二叉搜索树的最近公共祖先 ● 701.二叉搜索树中的插入操作 ● 450.删除二叉搜索树中的节点
  • ChatGPT 这个风口,普通人怎么抓住?
  • Python代码规范:企业级代码静态扫描-代码规范、逻辑、语法、安全检查,以及代码规范自动编排(2)