未验证 提交 e5a6bb1d 编写于 作者: D danleifeng 提交者: GitHub

adaptive for py3 for ps util;test=develop (#33727)

上级 687571f2
......@@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
import ps_pb2 as pslib
# NOTE: reduce removed in fuctools in python3
from functools import reduce
class Server(object):
......
......@@ -181,7 +181,7 @@ class Fleet(object):
trainers = self.worker_num()
remainder = len(files) % trainers
blocksize = len(files) / trainers
blocksize = len(files) // trainers
blocks = [blocksize] * trainers
for i in range(remainder):
......
......@@ -244,7 +244,7 @@ class FleetUtil(object):
new_pos = 0.0
new_neg = 0.0
total_ins_num = 0
for i in xrange(num_bucket):
for i in range(num_bucket):
index = num_bucket - 1 - i
new_pos = pos + global_pos[0][index]
total_ins_num += global_pos[0][index]
......@@ -1240,8 +1240,8 @@ class FleetUtil(object):
hours = os.popen("echo -n " + hours).read().split(" ")
split_interval = int(split_interval)
split_per_pass = int(split_per_pass)
splits_per_day = 24 * 60 / split_interval
pass_per_day = splits_per_day / split_per_pass
splits_per_day = 24 * 60 // split_interval
pass_per_day = splits_per_day // split_per_pass
left_train_hour = int(hours[0])
right_train_hour = int(hours[-1])
......@@ -1425,7 +1425,7 @@ class FleetUtil(object):
relative_ctr_error = 0.0
k_max_span = 0.01
k_relative_error_bound = 0.05
for i in xrange(num_bucket):
for i in range(num_bucket):
click = global_pos[0][i]
show = global_pos[0][i] + global_neg[0][i]
ctr = float(i) / num_bucket
......
......@@ -14,8 +14,9 @@
"""Http Server."""
import logging
import BaseHTTPServer
import SimpleHTTPServer
# NOTE: HTTPServer has a different name in python2 and python3
from http.server import HTTPServer
import http.server as SimpleHTTPServer
import time
import threading
import socket
......@@ -123,7 +124,7 @@ class KVHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
self.end_headers()
class KVHTTPServer(BaseHTTPServer.HTTPServer, object):
class KVHTTPServer(HTTPServer, object):
"""
it is a http server storing kv pairs.
"""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册