Skip to content

Commit e8eb9d8

Browse files
committed
python transport sdk support initLog
1 parent ee04393 commit e8eb9d8

File tree

8 files changed

+40
-13
lines changed

8 files changed

+40
-13
lines changed

cpp/wedpr-computing/ppc-pir/tests/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ set(TEST_BINARY_NAME test-ppc-pir)
55

66
add_executable(${TEST_BINARY_NAME} ${SOURCES})
77
target_include_directories(${TEST_BINARY_NAME} PRIVATE .)
8-
# target_link_libraries(${PIR_TARGET} PUBLIC ${IO_TARGET} ${FRONT_TARGET} ${BCOS_UTILITIES_TARGET} ${TARS_PROTOCOL_TARGET} TBB::tbb TCMalloc)
98

10-
# target_link_libraries(${TEST_BINARY_NAME} ${PIR_TARGET} ${RPC_TARGET} ${CRYPTO_TARGET} ${BOOST_UNIT_TEST})
11-
target_link_libraries(${TEST_BINARY_NAME} PUBLIC ${IO_TARGET} ${FRONT_TARGET} ${BCOS_UTILITIES_TARGET} ${TARS_PROTOCOL_TARGET} ${PIR_TARGET} ${RPC_TARGET} ${CRYPTO_TARGET} ${PROTOCOL_TARGET} ${BOOST_UNIT_TEST})
9+
target_link_libraries(${TEST_BINARY_NAME} PUBLIC ${CRYPTO_TARGET} ${BCOS_UTILITIES_TARGET} ${TARS_PROTOCOL_TARGET} ${PIR_TARGET} ${PROTOCOL_TARGET} ${BOOST_UNIT_TEST})
1210
add_test(NAME test-pir WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND ${TEST_BINARY_NAME})

cpp/wedpr-computing/ppc-psi/src/ecdh-multi-psi/EcdhMultiCache.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,16 @@ bool CalculatorCache::tryToFinalize()
328328
{
329329
continue;
330330
}
331-
if (it.second.plainDataIndex >= 0)
331+
if (it.second.plainDataIndex > 0)
332332
{
333333
m_intersectionResult.emplace_back(getPlainDataByIndex(it.second.plainDataIndex));
334334
}
335+
// means the header field, swap with the first element
336+
if (it.second.plainDataIndex == 0)
337+
{
338+
m_intersectionResult.emplace_back(m_intersectionResult[0]);
339+
m_intersectionResult[0] = getPlainDataByIndex(it.second.plainDataIndex);
340+
}
335341
}
336342
m_cacheState = CacheState::Finalized;
337343
ECDH_MULTI_LOG(INFO) << LOG_DESC("* tryToFinalize: compute intersection success")

cpp/wedpr-transport/sdk-wrapper/python/bindings/wedpr_python_gateway_sdk/transport/impl/transport_loader.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def __repr__(self):
4747

4848
class TransportLoader:
4949
transport_builder = TransportBuilder()
50+
transport_builder.initLog("conf/wedpr_sdk_log_config.ini")
5051

5152
@staticmethod
5253
def load(transport_config: TransportConfig) -> Transport:

python/ppc_model/conf/logging.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ keys=root,wsgi
33

44
[logger_root]
55
level=INFO
6-
handlers=consoleHandler,fileHandler
6+
handlers=fileHandler
77

88
[logger_wsgi]
99
level = INFO
@@ -12,7 +12,7 @@ qualname = wsgi
1212
propagate = 0
1313

1414
[handlers]
15-
keys=fileHandler,consoleHandler,accessHandler
15+
keys=fileHandler,accessHandler
1616

1717
[handler_accessHandler]
1818
class=handlers.TimedRotatingFileHandler
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[log]
2+
enable = true
3+
log_path = ./log
4+
; info debug trace
5+
level = info
6+
; MB
7+
max_log_file_size = 200
8+
; LineID, TimeStamp, ProcessID, ThreadName, ThreadID and Message
9+
;format = %Severity%|ppcs-gateway|system-id|%TimeStamp%|%ThreadName%-%ThreadID%|%Message%
10+
format = %Severity%|%TimeStamp%|%Message%
11+
enable_rotate_by_hour = true
12+
; if archive_path is empty, the archive function will be disabled
13+
; archive_path = ./log/
14+
;compress_archive_file = true
15+
; ; 0 = no limit, in MB
16+
; max_archive_size = 0
17+
; min_free_space = 0

python/ppc_model/ppc_model_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def register_task_handler():
6868
TransLogger(app, setup_console_handler=False), numthreads=2)
6969

7070
protocol = 'http'
71-
message = f"Starting ppc model server at {protocol}://{app.config['HOST']}:{app.config['HTTP_PORT']} successfully"
71+
message = f"* Starting ppc model server at {protocol}://{app.config['HOST']}:{app.config['HTTP_PORT']} successfully"
7272
print(message)
7373
components.logger().info(message)
7474
server.start()

python/ppc_model/task/task_manager.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ def _terminate_timeout_tasks(self):
244244
with self._rw_lock.gen_rlock():
245245
for task_id, value in self._tasks.items():
246246
alive_time = (datetime.datetime.now() -
247-
value[1]).total_seconds()
248-
if alive_time >= self._task_timeout_s and value[0] == TaskStatus.RUNNING.value:
247+
value.start_time).total_seconds()
248+
if alive_time >= self._task_timeout_s and value.task_status == TaskStatus.RUNNING.value:
249249
tasks_to_kill.append(task_id)
250250

251251
for task_id in tasks_to_kill:
@@ -257,9 +257,9 @@ def _cleanup_finished_tasks(self):
257257
with self._rw_lock.gen_rlock():
258258
for task_id, value in self._tasks.items():
259259
alive_time = (datetime.datetime.now() -
260-
value[1]).total_seconds()
260+
value.start_time).total_seconds()
261261
if alive_time >= self._task_timeout_s + 3600:
262-
tasks_to_cleanup.append((task_id, value[3]))
262+
tasks_to_cleanup.append((task_id, value.job_id))
263263
with self._rw_lock.gen_wlock():
264264
for task_id, job_id in tasks_to_cleanup:
265265
if task_id in self._tasks:

python/ppc_model/tools/start.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,19 @@ LOG_INFO() {
1111
}
1212
binary_path=${SHELL_FOLDER}/ppc_model_app.py
1313
cd ${SHELL_FOLDER}
14+
log_dir=logs
15+
if [ ! -f ${log_dir} ];then
16+
mkdir -p logs
17+
fi
1418
node=$(basename ${SHELL_FOLDER})
1519
node_pid=$(ps aux|grep ${binary_path}|grep -v grep|awk '{print $2}')
1620

1721
if [ ! -z ${node_pid} ];then
1822
echo " ${node} is running, pid is $node_pid."
1923
exit 0
2024
else
21-
nohup python ${binary_path} > start.out 2>&1 &
25+
# -u means Force the stdout and stderr streams to be unbuffered
26+
nohup python -u ${binary_path} > start.out 2>&1 &
2227
sleep 1.5
2328
fi
2429
try_times=4
@@ -34,4 +39,4 @@ do
3439
sleep 0.5
3540
((i=i+1))
3641
done
37-
echo -e "\033[31m Exceed waiting time. Please try again to start ${node} \033[0m"
42+
echo -e "\033[31m Exceed waiting time. Please try again to start ${node} \033[0m"

0 commit comments

Comments
 (0)