gpustat-web
gpustat-web copied to clipboard
Add option to return json on websocket
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 ~
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),
due to conversion done here:
return ansi_conv.convert(body, full=False)
the response looks like this:
<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.