(1) Fix /0 bug in double_ensemble, (2) remove _default_uri for R/expm, (3) support model size in pytorch models#314
(1) Fix /0 bug in double_ensemble, (2) remove _default_uri for R/expm, (3) support model size in pytorch models#314you-n-g merged 17 commits intomicrosoft:mainfrom D-X-Y:fshare
Conversation
qlib/workflow/expm.py
Outdated
| ) | ||
|
|
||
| def reset_default_uri(self, uri: Text): | ||
| self._default_uri = uri |
There was a problem hiding this comment.
Is any reason that you want to add this method? From my perspective, default_uri should be initialized and fixed when users call qlib.init. It seems there is no need to have such method here.
There was a problem hiding this comment.
A simple case is:
after we run many different experiments (with different uri), we may want to compare their performance. To query the metrics of each of these experiments, we need to let R know their uri.
There was a problem hiding this comment.
@D-X-Y We have uri in C, default_uri and current_uri here.
I think this will make users confusing.
Do you think combining uri in C and default_uri is a good idea?
qlib/workflow/recorder.py
Outdated
| return self._artifact_uri | ||
|
|
||
| @property | ||
| def root_uri(self): |
There was a problem hiding this comment.
What is this method for? Can you give us more explanation about it?
There was a problem hiding this comment.
This is to return the path of a specific record. For example, you can call R.get_recorder().root_uri and it will return: ml-runs/2/32792162f0f44951b1285c0b2e489252.
There was a problem hiding this comment.
Please update the related docs.
qlib/workflow/__init__.py
Outdated
| """ | ||
| return self.exp_manager.uri | ||
|
|
||
| def reset_default_uri(self, uri: Text): |
There was a problem hiding this comment.
Yeap, to provide an api to reset default uri. Use to query experiments with different uri.
qlib/log.py
Outdated
| logging_config.dictConfig(log_config) | ||
|
|
||
|
|
||
| def set_log_basic_config(filename: Optional[Text] = None, format: Optional[Text] = None, level: Optional[int] = None): |
There was a problem hiding this comment.
Most of the loggers used in Qlib are initialized through the function get_module_logger. If you want to do some enhancement about setting the logger, you may want to make some modifications upon that function instead of creating a new one. This function seems to be a little bit redundant.
There was a problem hiding this comment.
The motivation is that get_module_logger is called in different separate Python files, and it is hard for users to control the detailed behavior of get_module_logger function in each file.
This function provides a global control for logging, a case is that before each experiment runs, we can use this function to save the following logs into a file under the recorder directory (without caring about the kwargs of get_module_logger in each file).
There was a problem hiding this comment.
We think config logging using Config will make it easier for user to manage all the configurations.
https://github.com/microsoft/qlib/blob/main/qlib/config.py#L266
@D-X-Y
You can set it in the C instead of create a new function
There was a problem hiding this comment.
We think the original Python logging system is not user-friendly.
Qlib may use loguru in the future #7
qlib/contrib/model/pytorch_utils.py
Outdated
| import torch.nn as nn | ||
|
|
||
|
|
||
| def count_parameters(models_or_parameters, unit="mb"): |
There was a problem hiding this comment.
What do you mean by mb?
If it is a storage size unit. the byte length of each number should be considered.
Otherwise, please give explanation of the b
There was a problem hiding this comment.
If it is a storage size unit, please use 2**10 instead of 1e3
qlib/log.py
Outdated
| logging_config.dictConfig(log_config) | ||
|
|
||
|
|
||
| def set_log_basic_config(filename: Optional[Text] = None, format: Optional[Text] = None, level: Optional[int] = None): |
There was a problem hiding this comment.
We think config logging using Config will make it easier for user to manage all the configurations.
https://github.com/microsoft/qlib/blob/main/qlib/config.py#L266
@D-X-Y
You can set it in the C instead of create a new function
qlib/log.py
Outdated
| logging_config.dictConfig(log_config) | ||
|
|
||
|
|
||
| def set_log_basic_config(filename: Optional[Text] = None, format: Optional[Text] = None, level: Optional[int] = None): |
There was a problem hiding this comment.
We think the original Python logging system is not user-friendly.
Qlib may use loguru in the future #7
qlib/workflow/expm.py
Outdated
| ) | ||
|
|
||
| def reset_default_uri(self, uri: Text): | ||
| self._default_uri = uri |
There was a problem hiding this comment.
@D-X-Y We have uri in C, default_uri and current_uri here.
I think this will make users confusing.
Do you think combining uri in C and default_uri is a good idea?
qlib/workflow/recorder.py
Outdated
| def root_uri(self): | ||
| start_str = "file:" | ||
| if self.artifact_uri is not None: | ||
| xpath = self.artifact_uri.strip(start_str) |
There was a problem hiding this comment.
lstrip will be more accurate
qlib/workflow/recorder.py
Outdated
| return self._artifact_uri | ||
|
|
||
| @property | ||
| def root_uri(self): |
There was a problem hiding this comment.
If the funtion aims to get the path in a filesystem, it should raise error(e.g. NotImplementError) when the uri is not file system.
Besides, the root_uri is not a good name for user.
|
@you-n-g do you have any suggested name for root_uri? |
|
Following our offline discussion, I have:
Please let me know if you have any other concerns about the current version. |
|
@Derek-Wds Thanks for your prompt response. |
(1) Fix /0 bug in double_ensemble, (2) remove _default_uri for R/expm, (3) support model size in pytorch models
Four changes:
Description
Motivation and Context
Make it more friendly for researchers.
How Has This Been Tested?
pytest qlib/tests/test_all_pipeline.pyunder upper directory ofqlib.Screenshots of Test Results (if appropriate):
I run

pytest -W ignore::DeprecationWarning qlib/tests/test_all_pipeline.py, below is the screenshot:Types of changes