Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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') ```
- Loading branch information