Skip to content

feat(deployments): add logs to python package#382

Merged
cwetherill-ps merged 1 commit intomasterfrom
cwetherill/nb-417-access-deployments-logs-through-the-cli
Jan 21, 2022
Merged

feat(deployments): add logs to python package#382
cwetherill-ps merged 1 commit intomasterfrom
cwetherill/nb-417-access-deployments-logs-through-the-cli

Conversation

@cwetherill-ps
Copy link
Contributor

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')

Copy link
Contributor

@lamroger lamroger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reminder to remove the comment

return client.execute(query, variable_values=params)['deleteDeployment']


# my disappointment is immeasurable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hope your weekend goes better

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

lol strictly OOP Python always ends up being a hot friggin mess

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')
```
@cwetherill-ps cwetherill-ps force-pushed the cwetherill/nb-417-access-deployments-logs-through-the-cli branch from 8169819 to 468299f Compare January 21, 2022 20:07
@cwetherill-ps cwetherill-ps merged commit c0e0625 into master Jan 21, 2022
@cwetherill-ps cwetherill-ps deleted the cwetherill/nb-417-access-deployments-logs-through-the-cli branch January 21, 2022 20:08
@PSBOT
Copy link

PSBOT commented Jan 21, 2022

🎉 This PR is included in version 1.10.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@PSBOT PSBOT added the released label Jan 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants