From 89130ebbc99159428ce4ab4bf0c1a540df78933f Mon Sep 17 00:00:00 2001 From: KAAANG <79990647+SAKURA-CAT@users.noreply.github.com> Date: Fri, 6 Dec 2024 19:23:03 +0800 Subject: [PATCH] feat: increase log len (#750) --- ...44\277\241\346\201\257\351\207\207\351\233\206.md" | 3 +-- requirements.txt | 2 +- swanlab/data/run/main.py | 2 +- swanlab/log/console.py | 9 ++++----- test/unit/log/test_log.py | 11 ++++++----- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git "a/docs/\347\241\254\344\273\266\344\277\241\346\201\257\351\207\207\351\233\206.md" "b/docs/\347\241\254\344\273\266\344\277\241\346\201\257\351\207\207\351\233\206.md" index 36621862..3d98208e 100644 --- "a/docs/\347\241\254\344\273\266\344\277\241\346\201\257\351\207\207\351\233\206.md" +++ "b/docs/\347\241\254\344\273\266\344\277\241\346\201\257\351\207\207\351\233\206.md" @@ -60,10 +60,9 @@ class MonitorCron: 1. 如果没什么好采集的,返回空列表 2. + 如果有需要采集的,列表内的函数签名应该一致——此函数不接受任何参数,返回一个字典,字典类型为[HardwareInfo](/swanlab/data/run/metadata/hardware/type.py) > HardwareInfo字典类型遵循swanlab创建column的协议,包含列名称、图表配置、组配置等信息 -### CPU信息采集 - TODO \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index d598391f..ca34334f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ urllib3>=1.26.0 requests>=2.25.0 click pyyaml -psutil +psutil>=5.0.0 gputil==1.4.0 pynvml rich diff --git a/swanlab/data/run/main.py b/swanlab/data/run/main.py index 7933b2c4..f21677a1 100644 --- a/swanlab/data/run/main.py +++ b/swanlab/data/run/main.py @@ -133,7 +133,7 @@ def _(state: SwanLabRunState): swanlog.debug("Monitor on.") self.monitor_cron = MonitorCron(self.__get_monitor_func()) else: - swanlog.debug("Monitor off because of no monitor funcs.") + swanlog.debug("Monitor off because of no monitor func.") else: swanlog.debug("Monitor off.") diff --git a/swanlab/log/console.py b/swanlab/log/console.py index 20abe948..a33481ca 100644 --- a/swanlab/log/console.py +++ b/swanlab/log/console.py @@ -1,12 +1,11 @@ -import sys import os +import sys from datetime import datetime -from swankit.log import FONT -from swankit.env import create_time -import re +from swankit.env import create_time +from swankit.log import FONT -MAX_UPLOAD_LEN = 200 +MAX_UPLOAD_LEN = 500 class SwanWriterProxy: diff --git a/test/unit/log/test_log.py b/test/unit/log/test_log.py index dc0d41e9..344d80f6 100644 --- a/test/unit/log/test_log.py +++ b/test/unit/log/test_log.py @@ -8,12 +8,13 @@ 测试swanlog类,只需测试其日志监听功能 """ import os -import sys + import pytest +from freezegun import freeze_time +from nanoid import generate + from swanlab.log import swanlog from tutils import TEMP_PATH -from nanoid import generate -from freezegun import freeze_time @pytest.fixture(scope="function", autouse=True) @@ -87,12 +88,12 @@ def test_write_to_file_long_test(self): swanlog.install(console_dir) # 加一行防止其他问题 print("\ntest write to file") - a = generate(size=201) + a = generate(size=501) print(a) files = os.listdir(console_dir) with open(os.path.join(console_dir, files[0]), "r") as f: content = f.readlines() - assert content[-1] == a[:200] + "\n" + assert content[-1] == a[:500] + "\n" def test_write_logging_to_file(self): console_dir = self.create_console_dir()