From 602cc71393d293dca3c6e2eca57906049167550e Mon Sep 17 00:00:00 2001 From: Wey Gu Date: Fri, 24 May 2024 13:15:57 +0800 Subject: [PATCH 1/3] ci: non-debug mode by default for baremetal --- .github/workflows/pr.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 16fa09c..8d6865b 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -13,7 +13,7 @@ on: jobs: build-and-lint-test-bare-metal: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 @@ -32,8 +32,8 @@ jobs: - name: Build and Install NebulaGraph-Lite run: pip3 install . - - name: Dry run `nebulagraph start` - run: nebulagraph --debug start --cleanup + - name: Dry run `nebulagraph start`, in case of error, will run with debug mode + run: nebulagraph start --cleanup || nebulagraph --debug start --cleanup # error: Could not open the file: /sys/fs/cgroup/memory.max, seems cgroup version detection failed here # let's skip this test for now From 0a30b934e55e735b166152fd1ccfddd45bdf157a Mon Sep 17 00:00:00 2001 From: Wey Gu Date: Fri, 24 May 2024 13:24:24 +0800 Subject: [PATCH 2/3] use 20.04 due to cgroup issue. --- .github/workflows/pr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 8d6865b..adf245c 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -13,7 +13,7 @@ on: jobs: build-and-lint-test-bare-metal: - runs-on: ubuntu-22.04 + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 From 0d81069c7a95d9e3bb8cd45d2a1498c1401e551b Mon Sep 17 00:00:00 2001 From: Wey Gu Date: Fri, 24 May 2024 13:42:45 +0800 Subject: [PATCH 3/3] chore: activating storaged hosts optmized --- src/nebulagraph_lite/nebulagraph.py | 13 +++++++++++-- src/nebulagraph_lite/utils.py | 29 ++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/nebulagraph_lite/nebulagraph.py b/src/nebulagraph_lite/nebulagraph.py index 4ad6511..dda5f4f 100644 --- a/src/nebulagraph_lite/nebulagraph.py +++ b/src/nebulagraph_lite/nebulagraph.py @@ -1,4 +1,5 @@ import os +import json import shutil import socket import subprocess @@ -482,8 +483,16 @@ def activate_storaged(self): raise Exception("graphd did not become ready in 50 seconds") with connection_pool.session_context("root", "nebula") as session: session.execute(f'ADD HOSTS "{self.host}":9779') - result = session.execute_json("SHOW HOSTS") - fancy_dict_print({"SHOW HOSTS": result}) + time.sleep(12) + result_byte = session.execute_json("SHOW HOSTS") + result = result_byte.decode("utf-8") + result_dict = json.loads(result) + fancy_dict_print( + { + "Message": "Activating storaged...", + "Result of `SHOW HOSTS`": result_dict, + } + ) def load_basketballplayer_dataset(self): # udocker_create_command = f"ps | grep nebula-console || udocker --debug --allow-root create --name=nebula-console {self._container_image_prefix}vesoft/nebula-console:v3" diff --git a/src/nebulagraph_lite/utils.py b/src/nebulagraph_lite/utils.py index 0ca9f63..d066f69 100644 --- a/src/nebulagraph_lite/utils.py +++ b/src/nebulagraph_lite/utils.py @@ -105,17 +105,36 @@ def fancy_print(text: str, color: str = "random") -> None: print(f"\033[1;3;{color}m{text}\033[0m") -def fancy_dict_print(d: dict, color: str = None) -> None: +def fancy_dict_print(d: dict, color: str = None, indent: int = 0) -> None: """ - Print a dict in color from COLORS_rgb. + Recursively print a dict in color from COLORS_rgb, supporting nested dictionaries and lists. """ color_keys = list(COLORS_rgb.keys()) + indent_space = " " * indent for i, (key, value) in enumerate(d.items()): if color is None or color not in COLORS_rgb: - color = COLORS_rgb[color_keys[i % len(color_keys)]] + selected_color = COLORS_rgb[color_keys[i % len(color_keys)]] else: - color = COLORS_rgb[color] - print(f"\033[1;3;{color}m{key}: {value}\033[0m") + selected_color = COLORS_rgb[color] + if isinstance(value, dict): + print(f"\033[1;3;{selected_color}m{indent_space}{key}:\033[0m") + fancy_dict_print(value, color, indent + 4) + elif isinstance(value, list): + print(f"\033[1;3;{selected_color}m{indent_space}{key}:\033[0m") + if not all(isinstance(item, (dict, list)) for item in value): + print( + f"\033[1;3;{selected_color}m{indent_space} {', '.join(map(str, value))}\033[0m" + ) + else: + for item in value: + if isinstance(item, dict): + fancy_dict_print(item, color, indent + 4) + else: + print( + f"\033[1;3;{selected_color}m{indent_space} {item}\033[0m" + ) + else: + print(f"\033[1;3;{selected_color}m{indent_space}{key}: {value}\033[0m") def get_pid_by_port(port):