-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
util: basic config manager #113
Conversation
pipit/config.py
Outdated
# SPDX-License-Identifier: MIT | ||
|
||
# Private dict that stores global config values | ||
_config = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good for a basic config manager. Here is a draft implementation in Hatchet: https://github.com/hatchet/hatchet/pull/511/files. It's similar to Pandas set_options
. registered_options
stores the default settings and global_config
stores the current settings. The get_option
, set_option
, and reset_option
functions are straightforward. There are also some validators to check if the given inputs are correct but I think the validator implementation has not finished yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
pipit/__init__.py
Outdated
@@ -4,3 +4,4 @@ | |||
# SPDX-License-Identifier: MIT | |||
|
|||
from .trace import Trace # noqa: F401 | |||
from .config import get_option, set_option # noqa: F401 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add reset_option
@@ -0,0 +1,47 @@ | |||
import pipit as pp | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a function in which we might want to use global config? For example, in Hatchet we have the tree
function that prints the CCT. One of the parameters it takes is colormap
. We want to change colormap globally using set_option
. Do we have a function like this in Pipit? If yes, can we add a test that it works?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a set_option
function that is exposed to users. I'm not sure if this is what you mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Hatchet, if we specify a colormap
parameter for the tree
function, does it set the colormap
globally? Or just once, for that specific tree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it just changes the colormap for that call. If we want to change it globally, we have to use set_option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, we should be able to do the same in Pipit for timeline, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was asking if we could add a test for something like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand what you're getting at, the timeline function would say something like:
def timeline( ..., colormap = None):
...
if colormap = None:
colormap = pp.get_config("colormap")
...
We currently have tests for pp.get_config
. I think a specific test for the code above would be in the timeline test? Please correct me if I'm misunderstanding anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think that makes sense. Let's discuss this with @bhatele later.
Usage: