-
Notifications
You must be signed in to change notification settings - Fork 282
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
Config #151
base: master
Are you sure you want to change the base?
Config #151
Conversation
Hello @jenuk, thanks so much for your work and great suggestion! This looks like an amazing contribution. I will be happy to discuss and work with you to make this landed in the near future. It'd be quite an involved job to come up with a right design on config classes and customizable APIs. I find the use of dataclass (requires python 3.7+ though) useful, which allows users to write their own config at ease. We can decide between declarative APIs (e.g. dataclass config) or imperative APIs (or something like plugins, see #152). I will take a detailed look later, but here are some first-impression thoughts or questions:
As a final remark, I was thinking about having a more flexible plugin architecture (#152) which would also allow custom formatting but at a slightly different approach. We could even merge these approaches too. Thank you again! |
A plugin based solution seems viable to me, since the current implementation is only really dependent on the json returned by the query. Though I have to say that I have no experience writing plugins for anything, so I don't know what exactly would need doing.
Right now that was more part of testing, and just activates my print instead of the default one. But my intention was to set it to a path to a config (yaml) file, that would then be loaded to override all given options from Additionally, with things like OmegaConf there is also the option to automatically parse nested assignment into the config. E.g. putting
So you are talking about the Regarding dataclasses being python 3.7, there are a couple of options:
|
FYI, Python 3.6 reached its end-of-life schedule 1 year and 3 months ago (23 Dec 2021). Python 3.7 will end its maintenance in 2 months and 2 weeks (27 Jun 2023). The default |
Hello @wookayin !
First of all, thank you so much for this package.
I have implemented a a new function to format the output of gpustat using a python dataclass. The class saves a color for each entry provided by gpustat, names are the same as in the json (except for replacing
.
with_
), as well as having a template to layout the final string. This should address issues #51 and #9. Here are two example outputs using it:The output is determined by three strings that are formatted using
str.format
, one for the header, the gpu info and the process info. In that environment the corresponding information is provided, and can be used using the standard{name:specifier}
. I have added an additional parsing for... $name:specifier$ ...
to input the correct color before and switch back to normal formatting afterward. Also as in your code there are some extra things added like the gpu-name width, the blessed terminal interface and an empty string (to repeat a characterwidth
times).There are some open todos that need to be implemented before this should be pushed, but I wanted to ask for your opinion so far before I continue this.
Remaining todos:
Do you have any additional feedback/wishes for this? If you are happy with this, I will finish it.