Commit c0e0625
authored
feat(deployments): add logs to python package (#382)
This hijacks some old crufty log machinery to enable log streaming from
the new Deployments V3. This exposes two new methods, one generator and
one that just dumps a buttload of logs in your lap.
By way of example:
```
>>> from gradient import gradient_deployments
>>> import json
>>>
>>>
>>> logs = gradient_deployments.get_deployment_logs(
... deployment_id='6753a6cc-393a-478d-bc29-9e8828a0aa2f',
... limit=5,
... api_key='<REDACTED>')
>>> print(json.dumps(logs, indent=4))
[
[
2,
"",
"2021-12-13T21:41:39.711Z"
],
[
3,
" Welcome to Streamlit. Check out our demo in your browser.",
"2021-12-13T21:41:39.711Z"
],
[
4,
"",
"2021-12-13T21:41:39.711Z"
],
[
5,
" Network URL: http://10.42.40.230:8501",
"2021-12-13T21:41:39.711Z"
],
[
6,
" External URL: http://172.83.13.4:8501",
"2021-12-13T21:41:39.711Z"
]
]
>>>
>>> logs = gradient_deployments.yield_deployment_logs(
... deployment_id='6753a6cc-393a-478d-bc29-9e8828a0aa2f',
... limit=5,
... api_key='<REDACTED>')
>>> next(logs)
LogRow(line=2, message='', timestamp='2021-12-13T21:41:39.711Z')
```1 parent 0daa2c7 commit c0e0625
File tree
2 files changed
+31
-1
lines changed- gradient/api_sdk/repositories
2 files changed
+31
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
| |||
215 | 217 | | |
216 | 218 | | |
217 | 219 | | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
0 commit comments