From 148e2a04ab6bf7c4b7951dec8ed924c5bbc9049d Mon Sep 17 00:00:00 2001 From: ShenYuhan Date: Wed, 23 Sep 2020 18:01:15 +0800 Subject: [PATCH] add config.json for component sampling. --- visualdl/server/data_manager.py | 34 ++++++++++++++++++++++++--------- visualdl/server/serve.py | 2 +- visualdl/utils/dir.py | 2 +- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/visualdl/server/data_manager.py b/visualdl/server/data_manager.py index 83ee8a0c..f1645ec8 100644 --- a/visualdl/server/data_manager.py +++ b/visualdl/server/data_manager.py @@ -16,17 +16,33 @@ from __future__ import absolute_import import threading import random +import json import collections -DEFAULT_PLUGIN_MAXSIZE = { - "scalar": 1000, - "image": 10, - "histogram": 100, - "embeddings": 50000, - "audio": 10, - "pr_curve": 300, - "meta_data": 100 -} +from visualdl.utils.dir import CONFIG_PATH + +try: + with open(CONFIG_PATH, 'r', encoding='utf-8') as fp: + data = json.load(fp) + DEFAULT_PLUGIN_MAXSIZE = { + "scalar": data.get('scalar_sample', 1000), + "image": data.get('image_sample', 10), + "histogram": data.get('histogram_sample', 100), + "embeddings": data.get('embedding_sample', 50000), + "audio": data.get('audio_sample', 10), + "pr_curve": data.get('pr_curve_sample', 300), + "meta_data": 100 + } +except Exception: + DEFAULT_PLUGIN_MAXSIZE = { + "scalar": 1000, + "image": 10, + "histogram": 100, + "embeddings": 50000, + "audio": 10, + "pr_curve": 300, + "meta_data": 100 + } class Reservoir(object): diff --git a/visualdl/server/serve.py b/visualdl/server/serve.py index 264b6a25..3c0beec4 100644 --- a/visualdl/server/serve.py +++ b/visualdl/server/serve.py @@ -25,7 +25,7 @@ from visualdl.server.log import logger def get_server_url(): - with open(CONFIG_PATH, 'r') as fp: + with open(CONFIG_PATH, 'r', encoding='utf-8') as fp: server_url = json.load(fp)['server_url'] return server_url diff --git a/visualdl/utils/dir.py b/visualdl/utils/dir.py index 78417209..afb9b21d 100644 --- a/visualdl/utils/dir.py +++ b/visualdl/utils/dir.py @@ -33,5 +33,5 @@ def init_vdl_config(): if not os.path.exists(CONF_HOME): os.makedirs(CONF_HOME) if not os.path.exists(CONFIG_PATH) or 0 == os.path.getsize(CONFIG_PATH): - with open(CONFIG_PATH, 'w') as fp: + with open(CONFIG_PATH, 'w', encoding='utf-8') as fp: fp.write(json.dumps(default_vdl_config)) -- GitLab