mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-03 11:00:57 +08:00
Add reset_default_uri func for R and expm
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
# Licensed under the MIT License.
|
||||
|
||||
from contextlib import contextmanager
|
||||
from typing import Text, Optional
|
||||
from .expm import MLflowExpManager
|
||||
from .exp import Experiment
|
||||
from .recorder import Recorder
|
||||
@@ -20,7 +21,9 @@ class QlibRecorder:
|
||||
return "{name}(manager={manager})".format(name=self.__class__.__name__, manager=self.exp_manager)
|
||||
|
||||
@contextmanager
|
||||
def start(self, experiment_name=None, recorder_name=None, uri=None):
|
||||
def start(
|
||||
self, experiment_name: Optional[Text] = None, recorder_name: Optional[Text] = None, uri: Optional[Text] = None
|
||||
):
|
||||
"""
|
||||
Method to start an experiment. This method can only be called within a Python's `with` statement. Here is the example code:
|
||||
|
||||
@@ -282,6 +285,12 @@ class QlibRecorder:
|
||||
"""
|
||||
return self.exp_manager.uri
|
||||
|
||||
def reset_default_uri(self, uri: Text):
|
||||
"""
|
||||
Method to reset the default uri of current experiment manager.
|
||||
"""
|
||||
self.exp_manager.reset_default_uri(uri)
|
||||
|
||||
def get_recorder(self, recorder_id=None, recorder_name=None, experiment_name=None):
|
||||
"""
|
||||
Method for retrieving a recorder.
|
||||
|
||||
@@ -23,7 +23,7 @@ class Experiment:
|
||||
self.active_recorder = None # only one recorder can running each time
|
||||
|
||||
def __repr__(self):
|
||||
return "{name}(info={info})".format(name=self.__class__.__name__, info=self.info)
|
||||
return "{name}(id={id}, info={info})".format(name=self.__class__.__name__, id=self.id, info=self.info)
|
||||
|
||||
def __str__(self):
|
||||
return str(self.info)
|
||||
@@ -175,6 +175,9 @@ class MLflowExperiment(Experiment):
|
||||
self._default_rec_name = "mlflow_recorder"
|
||||
self._client = mlflow.tracking.MlflowClient(tracking_uri=self._uri)
|
||||
|
||||
def __repr__(self):
|
||||
return "{name}(id={id}, info={info})".format(name=self.__class__.__name__, id=self.id, info=self.info)
|
||||
|
||||
def start(self, recorder_name=None):
|
||||
logger.info(f"Experiment {self.id} starts running ...")
|
||||
# set up recorder
|
||||
|
||||
@@ -33,6 +33,10 @@ class ExpManager:
|
||||
name=self.__class__.__name__, duri=self._default_uri, curi=self._current_uri
|
||||
)
|
||||
|
||||
def reset_default_uri(self, uri: Text):
|
||||
self._default_uri = uri
|
||||
self.set_uri(None)
|
||||
|
||||
def start_exp(
|
||||
self,
|
||||
experiment_name: Optional[Text] = None,
|
||||
|
||||
Reference in New Issue
Block a user