From 64582e9d4622a7f1f6b1a16a67099e289c03e1b9 Mon Sep 17 00:00:00 2001 From: Jactus Date: Tue, 15 Jun 2021 15:02:11 +0800 Subject: [PATCH] Add QlibException --- qlib/utils/exceptions.py | 12 ++++++++++++ qlib/workflow/__init__.py | 7 +------ 2 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 qlib/utils/exceptions.py diff --git a/qlib/utils/exceptions.py b/qlib/utils/exceptions.py new file mode 100644 index 000000000..69712172b --- /dev/null +++ b/qlib/utils/exceptions.py @@ -0,0 +1,12 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +# Base exception class +class QlibException(Exception): + def __init__(self, message): + super(QlibException, self).__init__(message) + + +# Error type for reinitialization when starting an experiment +class RecorderInitializationError(QlibException): + pass diff --git a/qlib/workflow/__init__.py b/qlib/workflow/__init__.py index 7652ff709..e5cdbb71c 100644 --- a/qlib/workflow/__init__.py +++ b/qlib/workflow/__init__.py @@ -7,6 +7,7 @@ from .expm import MLflowExpManager from .exp import Experiment from .recorder import Recorder from ..utils import Wrapper +from ..utils.exceptions import RecorderInitializationError class QlibRecorder: @@ -525,12 +526,6 @@ class QlibRecorder: self.get_exp().get_recorder().set_tags(**kwargs) -# error type for reinitialization when starting an experiment -class RecorderInitializationError(Exception): - def __init__(self, message): - super(RecorderInitializationError, self).__init__(message) - - class RecorderWrapper(Wrapper): """ Wrapper class for QlibRecorder, which detects whether users reinitialize qlib when already starting an experiment.