diff --git a/qlib/workflow/__init__.py b/qlib/workflow/__init__.py index 347c31771..cae050b64 100644 --- a/qlib/workflow/__init__.py +++ b/qlib/workflow/__init__.py @@ -8,6 +8,7 @@ from .exp import Experiment from .recorder import Recorder from ..utils import Wrapper from ..utils.exceptions import RecorderInitializationError +from qlib.config import C class QlibRecorder: @@ -351,7 +352,7 @@ class QlibRecorder: @contextmanager def uri_context(self, uri: Text): """ - Temporarily set the exp_manager's uri to uri + Temporarily set the exp_manager's **default_uri** to uri NOTE: - Please refer to the NOTE in the `set_uri` @@ -361,12 +362,12 @@ class QlibRecorder: uri : Text the temporal uri """ - prev_uri = self.exp_manager._current_uri - self.exp_manager.set_uri(uri) + prev_uri = self.exp_manager.default_uri + C.exp_manager["kwargs"]["uri"] = uri try: yield finally: - self.exp_manager.set_uri(prev_uri) + C.exp_manager["kwargs"]["uri"] = prev_uri def get_recorder( self, diff --git a/qlib/workflow/expm.py b/qlib/workflow/expm.py index e93cd7f89..01844b528 100644 --- a/qlib/workflow/expm.py +++ b/qlib/workflow/expm.py @@ -353,6 +353,8 @@ class MLflowExpManager(ExpManager): if self.active_experiment is not None: self.active_experiment.end(recorder_status) self.active_experiment = None + # When an experiment end, we will release the current uri. + self._current_uri = None def create_exp(self, experiment_name: Optional[Text] = None): assert experiment_name is not None