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

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

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