Add GraphRun object to make use of next
more ergonomic
#833
+66
−12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the result of trying to reduce the amount of stuff happening in
Graph.run
that wasn't just innext
.I made some related improvements I discovered while working on this in #834, but I think there are still some advantages to a
GraphRun
object.The main two benefits of this are:
state
,deps
,history
, orinfer_name
after starting the "run". I understand that for the sake of interrupting etc. that that you need to be able to set these things, but it feels reasonable to me to interrupt theGraphRun
as a whole — since we can start/stop runs from any node I don't see a problem with this. (I didn't expose a way to set the history of a run, but it would be trivial to add that.) And needing to keep a reference todeps
etc., or even just pass the relevant arguments just feels kind of non-ergonomic when you just want actual streaming (not interrupts).next
to manage history themselves then the value of this is reduced, but we would still need to basically duplicate the history handling inAgent.next
sinceGraph.next
won't do it for us.I expect we'll close this PR without merging, but I wanted to at least share the implementation as a proof of concept.