From 750ad907dffbdbb8ea33482a0911aac425aba85f Mon Sep 17 00:00:00 2001 From: wuzewu Date: Mon, 2 Nov 2020 20:13:03 +0800 Subject: [PATCH] Fix crash caused by non-existent configuration file --- paddlehub/config.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/paddlehub/config.py b/paddlehub/config.py index 4e074b3e..5d0bfa70 100644 --- a/paddlehub/config.py +++ b/paddlehub/config.py @@ -32,6 +32,11 @@ class HubConfig: def __init__(self): self._initialize() self.file = os.path.join(hubenv.CONF_HOME, 'config.yaml') + + if not os.path.exists(self.file): + self.flush() + return + with open(self.file, 'r') as file: try: cfg = yaml.load(file, Loader=yaml.FullLoader) -- GitLab