feat(sdk): live logs for jobs#35
Conversation
7b4ac3f to
7ffbd9c
Compare
7ffbd9c to
26b0121
Compare
lianakoleva
left a comment
There was a problem hiding this comment.
awesome! 3 comments. please add testing as well.
justusschock
left a comment
There was a problem hiding this comment.
how does job.stream_logs() behave when calling it twice? will it only return the logs emitted after the first one or all of them?
Also should we unify this with .logs? so depending on the state, it will either do the streaming or all of them? all the flags (tail, rank & follow) should work with both of them
d8efc2a to
b7e9982
Compare
On calling twice: it's stateless, each call will open a fresh stream starting from the job's creation time (or the last tail N lines), so you get the full logs again, not just the delta since the last call. We don't persist a cursor between calls.
|
Summary
Currently the SDK has no way to stream a job's logs. Job.logs only returned the finished log and raised an error while the job was running. Live logs existed in lightning deployment logs only.
This PR adds a way to stream a job's logs live from the Python SDK.
Job.stream_logs(follow=True, tail=..., rank=..., idle_timeout=...)yields log lines as a generator, backed byJobApiV2.stream_logsthat follows the controlplane log websocket.demo: https://www.loom.com/share/2017cb29696542bc96d20c91d03cb940
I will follow up with a
lightning job logsCLI command.Usage