From ce12e4f2fac37a0c79dec56c0b056c46c0dd48cc Mon Sep 17 00:00:00 2001 From: Qi Zhou Date: Wed, 22 Apr 2020 14:33:31 -0700 Subject: [PATCH] cluster.py prints cluster config in env (#887) --- quarkchain/cluster/cluster.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/quarkchain/cluster/cluster.py b/quarkchain/cluster/cluster.py index 9e4aeb1a0..8464d7b68 100644 --- a/quarkchain/cluster/cluster.py +++ b/quarkchain/cluster/cluster.py @@ -10,6 +10,7 @@ import psutil from quarkchain.cluster.cluster_config import ClusterConfig +from quarkchain.env import DEFAULT_ENV PYTHON = "pypy3" if platform.python_implementation() == "PyPy" else "python3" @@ -147,9 +148,7 @@ def check_db(self): self.start_and_loop() -def main(): - logging.getLogger("asyncio").setLevel(logging.ERROR) - os.chdir(os.path.dirname(os.path.abspath(__file__))) +def parse_args(): parser = argparse.ArgumentParser() ClusterConfig.attach_arguments(parser) parser.add_argument("--profile", default="", type=str) @@ -158,7 +157,20 @@ def main(): parser.add_argument("--check_db_rblock_batch", default=1, type=int) args = parser.parse_args() - config = ClusterConfig.create_from_args(args) + env = DEFAULT_ENV.copy() + env.cluster_config = ClusterConfig.create_from_args(args) + env.arguments = args + + return env + + +def main(): + logging.getLogger("asyncio").setLevel(logging.ERROR) + os.chdir(os.path.dirname(os.path.abspath(__file__))) + env = parse_args() + config = env.cluster_config + args = env.arguments + print("Cluster config file: {}".format(config.json_filepath)) print(config.to_json())