diff --git a/visualdl/server/data_manager.py b/visualdl/server/data_manager.py index 83ee8a0c02976edc5cccaca400e72a8fcf23f220..f1645ec846c944fb725dcb5d383d2efc60648270 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 264b6a25dcd4042f4408306b107ff8f6c61e1126..3c0beec46eaec9733d42e9e5980e32e335966963 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 7841720984ab9b66788110f45a6fb2ab1f1eaccc..afb9b21dd8ccf4b6b0722d0dea7b90878d14d4ab 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))