From 592db903b3afbfd1628fd7e6ad4f150a5c5d13cc Mon Sep 17 00:00:00 2001 From: D-X-Y <280835372@qq.com> Date: Thu, 4 Mar 2021 05:02:56 +0000 Subject: [PATCH] Update repr for Experiment & Recorder --- qlib/workflow/__init__.py | 6 ++++-- qlib/workflow/exp.py | 4 ++-- qlib/workflow/expm.py | 2 +- qlib/workflow/recorder.py | 4 ++-- tests/test_all_pipeline.py | 4 ++++ 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/qlib/workflow/__init__.py b/qlib/workflow/__init__.py index 9602963d8..c6bf0c86c 100644 --- a/qlib/workflow/__init__.py +++ b/qlib/workflow/__init__.py @@ -38,8 +38,10 @@ class QlibRecorder: recorder_name : str name of the recorder under the experiment one wants to start. uri : str - the tracking uri of the experiment, where all the artifacts/metrics etc. will be stored. - The default uri are set in the qlib.config. + The tracking uri of the experiment, where all the artifacts/metrics etc. will be stored. + The default uri are set in the qlib.config. Note that this uri argument will not change the one defined in the config file. + Therefore, the next time when user call this function in the same experiment, + they have to also specify this argument with the same value. Otherwise, inconsistent uri may occur. """ run = self.start_exp(experiment_name, recorder_name, uri) try: diff --git a/qlib/workflow/exp.py b/qlib/workflow/exp.py index c2548971a..7c98fd68f 100644 --- a/qlib/workflow/exp.py +++ b/qlib/workflow/exp.py @@ -11,7 +11,7 @@ from ..log import get_module_logger logger = get_module_logger("workflow", "INFO") -class Experiment: +class Experiment(object): """ This is the `Experiment` class for each experiment being run. The API is designed similar to mlflow. (The link: https://mlflow.org/docs/latest/python_api/mlflow.html) @@ -23,7 +23,7 @@ class Experiment: self.active_recorder = None # only one recorder can running each time def __repr__(self): - return str(self.info) + return "{name}(info={info})".format(name=self.__class__.__name__, info=self.info) def __str__(self): return str(self.info) diff --git a/qlib/workflow/expm.py b/qlib/workflow/expm.py index e905434cb..541507a73 100644 --- a/qlib/workflow/expm.py +++ b/qlib/workflow/expm.py @@ -14,7 +14,7 @@ from ..log import get_module_logger logger = get_module_logger("workflow", "INFO") -class ExpManager: +class ExpManager(object): """ This is the `ExpManager` class for managing experiments. The API is designed similar to mlflow. (The link: https://mlflow.org/docs/latest/python_api/mlflow.html) diff --git a/qlib/workflow/recorder.py b/qlib/workflow/recorder.py index ceb57150c..31077176d 100644 --- a/qlib/workflow/recorder.py +++ b/qlib/workflow/recorder.py @@ -11,7 +11,7 @@ from ..log import get_module_logger logger = get_module_logger("workflow", "INFO") -class Recorder: +class Recorder(object): """ This is the `Recorder` class for logging the experiments. The API is designed similar to mlflow. (The link: https://mlflow.org/docs/latest/python_api/mlflow.html) @@ -34,7 +34,7 @@ class Recorder: self.status = Recorder.STATUS_S def __repr__(self): - return str(self.info) + return "{name}(info={info})".format(name=self.__class__.__name__, info=self.info) def __str__(self): return str(self.info) diff --git a/tests/test_all_pipeline.py b/tests/test_all_pipeline.py index f6e77cba4..97f3f986a 100644 --- a/tests/test_all_pipeline.py +++ b/tests/test_all_pipeline.py @@ -110,7 +110,10 @@ def train(): # model initiaiton model = init_instance_by_config(task["model"]) + print(model) dataset = init_instance_by_config(task["dataset"]) + print(dataset) + print(R) # start exp with R.start(experiment_name="workflow"): @@ -119,6 +122,7 @@ def train(): # prediction recorder = R.get_recorder() + print(recorder) rid = recorder.id sr = SignalRecord(model, dataset, recorder) sr.generate()