diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100755 index 0000000000000000000000000000000000000000..d8112837dc9627bc2e501940b8e97c89e97c45ff --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,52 @@ +repos: +- repo: https://github.com/Lucas-C/pre-commit-hooks.git + sha: v1.0.1 + hooks: + - id: remove-crlf + files: (?!.*third_party)^.*$ | (?!.*book)^.*$ +- repo: https://github.com/PaddlePaddle/mirrors-yapf.git + sha: 0d79c0c469bab64f7229c9aca2b1186ef47f0e37 + hooks: + - id: yapf + files: (.*\.(py|bzl)|BUILD|.*\.BUILD|WORKSPACE)$ +- repo: https://github.com/pre-commit/pre-commit-hooks + sha: 5bf6c09bfa1297d3692cadd621ef95f1284e33c0 + hooks: + - id: check-added-large-files + - id: check-merge-conflict + - id: check-symlinks + - id: detect-private-key + files: (?!.*third_party)^.*$ | (?!.*book)^.*$ + - id: end-of-file-fixer +- repo: local + hooks: + - id: clang-format-with-version-check + name: clang-format + description: Format files with ClangFormat. + entry: bash ./tools/codestyle/clang_format.hook -i + language: system + files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|proto)$ +- repo: local + hooks: + - id: cpplint-cpp-source + name: cpplint + description: Check C++ code style using cpplint.py. + entry: bash ./tools/codestyle/cpplint_pre_commit.hook + language: system + files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx)$ +- repo: local + hooks: + - id: pylint-doc-string + name: pylint + description: Check python docstring style using docstring_checker. + entry: bash ./tools/codestyle/pylint_pre_commit.hook + language: system + files: \.(py)$ +- repo: local + hooks: + - id: copyright_checker + name: copyright_checker + entry: python ./tools/codestyle/copyright.hook + language: system + files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|proto|py)$ + exclude: (?!.*third_party)^.*$ | (?!.*book)^.*$ diff --git a/python/paddle_fl/paddle_fl/core/trainer/fl_trainer.py b/python/paddle_fl/paddle_fl/core/trainer/fl_trainer.py index 65e171989aef8a08d4dd9fbe1135818b74a2bc51..fc696d417a104562639f8097df0e76032b9a13c7 100755 --- a/python/paddle_fl/paddle_fl/core/trainer/fl_trainer.py +++ b/python/paddle_fl/paddle_fl/core/trainer/fl_trainer.py @@ -19,6 +19,7 @@ import pickle from paddle.fluid.io import is_belong_to_optimizer from paddle_fl.paddle_fl.core.scheduler.agent_master import FLWorkerAgent import numpy +import paddle_serving_client.io as serving_io import hmac import hashlib from .diffiehellman.diffiehellman import DiffieHellman diff --git a/python/paddle_fl/paddle_fl/examples/deploy_serving_after_training/fl_trainer.py b/python/paddle_fl/paddle_fl/examples/deploy_serving_after_training/fl_trainer.py index 9b6ccb6d1a1b01eed05e661f9d1c304803171d30..a65aff74a046840a99f61e7d8e5ea9c9814f804b 100644 --- a/python/paddle_fl/paddle_fl/examples/deploy_serving_after_training/fl_trainer.py +++ b/python/paddle_fl/paddle_fl/examples/deploy_serving_after_training/fl_trainer.py @@ -47,17 +47,6 @@ place = fluid.CPUPlace() trainer.start(place) print("scheduler_ep is {}, current_ep is {}".format(trainer._scheduler_ep, trainer._current_ep)) -""" -feed_vars = {} -target_vars = {} -for target in trainer._target_names: - tmp_target = trainer._main_program.block(0)._find_var_recursive(target) - target_vars[target] = tmp_target - -for feed in trainer._feed_names: - tmp_feed = trainer._main_program.block(0)._find_var_recursive(feed) - feed_vars[feed] = tmp_feed -""" epoch_id = 0 while not trainer.stop(): if epoch_id > 10: @@ -73,6 +62,4 @@ while not trainer.stop(): break epoch_id += 1 if epoch_id % 5 == 0: - # trainer.save_inference_program(output_folder) - trainer.save_serving_model("test", "imdb_client_conf") -# serving_io.save_model("test","imdb_client_conf", feed_vars, target_vars, trainer._main_program) + trainer.save_serving_model("imdb_server_model", "imdb_client_conf")