-
Notifications
You must be signed in to change notification settings - Fork 37
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
Add option to return json on websocket #15
base: master
Are you sure you want to change the base?
Conversation
try: | ||
parsed = json.loads(status) | ||
except: | ||
continue |
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.
Please handle exception properly.
May I ask what is the main purpose of emitting the data json? All the data is given as 'text' actually too. |
the ansi conversion was making the text hard to parse in the websocket response |
I still don't quite understand. The JSON response is an array of still ANSI-coded gpustat output, right? Why do you need them in the first place? |
Because otherwise websocket returns info formatted with html (with tags, and some stats left out), <span class="ansi36">[0]</span> <span class="ansi34">TITAN RTX </span> |<span class="ansi31"> 26°C</span>, <span class="ansi32"> 0 %</span> | <span class="ansi36"></span><span class="ansi1 ansi36"></span><span class="ansi1 ansi33"> 1</span> / <span class="ansi33">24220</span> MB | ... I want the whole gpu info in json format, like this: [{"hostname": "server1", "query_time": "2021-06-26T17:39:18.868461", "gpus": [{"index": 0, "uuid": .... So that I can do my own parsing and formatting. |
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.
I am not sure if the JSON format here is the best possible one. I think instead of having a list as a top-level element, we should have some dict(object) a la gpustat's JSON output.
I have added the option to also get the results as a json formatted string from the websocket by setting
ws.send_str('json')
.json is more convenient for consuming in other applications, that are piggy-backing off of this library.
I have been using your gpustat & gpustat-web libraries for a while 😄
~ Thank you ~