Split FinishedGraph off from GraphBuilder, return from worker#381
Split FinishedGraph off from GraphBuilder, return from worker#381
Conversation
e8d272b to
7e92fcb
Compare
dc8ba1f to
e8ce026
Compare
| """ | ||
| if isinstance(graph_data, GraphBuilder): | ||
| graph_data = graph_data.get_data() | ||
| if isinstance(graph_data, FinishedGraph): |
There was a problem hiding this comment.
This has probably just broken visualization of half-built/in-progress graphs. I might need to take a GraphData | GraphBuilder | FinishedGraph here (and bring back some way to get_data the GraphData out of a GraphBuilder)
…puts_type before outputs_type (#391) Also remove some overloads that seem pointless (??), and tidy some imports Removing generics_in_ptype as a preliminary to #381 because it's hard to handle parametrized FinishedGraph. `TypedGraphRef[Inputs, Outputs]` was constructed via `TypedGraphRef(outputs_type, inputs_type)`, so reorder the latter. (Although the `inputs_type` field is unused it helps `pyright` figure out the `Inputs` type parameter when in strict mode or with `reportUnknownVariableType` so keep it for now.)
e8ce026 to
969cd0f
Compare
…ke & stubs import FinGraph, regen stubs+import FinishedGraph...tests pass but pyright fails
This reverts commit f27123875cf5369f14b5207964a8fa3bc787d0fa.
969cd0f to
66ec5c5
Compare
These all work as things stand, but are intended as fodder for #381 - they need a lot of manual typing with opportunities for error....
25881e4 to
8c2ba50
Compare
|
|
||
| This will evaluate a nested graph with the given inputs. | ||
|
|
||
| :param A the input type of the graph. |
There was a problem hiding this comment.
Hmmm I mean do we need these :types? Are they not inferred from the type annotations?
| graph: GraphBuilder[A, B], | ||
| graph: FinishedGraph[A, B], | ||
| ) -> TypedGraphRef[A, B]: | ||
| # TODO @philipp-seitz: Turn this into a public method? |
There was a problem hiding this comment.
I'd +1 this, shall I do it in this PR?
|
Why do we need both |
As per last paragraph in the description (TODOs/future work):
I.e. I think we need GraphData as an internal struct, for (a) serialization, and (b) passing from GraphBuilder into FinishedGraph, but we could hide it from the user with more updates to tests etc. Except this may restrict |
FinishedGraphholding a GraphData and outputs_type.GraphBuilder.outputsrenamed tofinish_with_outputsand returns a FinishedGraphloop,eval) to take FinishedGraph's, removing check inembedthat the Output node is present (this is now guaranteed if your python code is well-typed - I was surprised not to find more such checks in map/loop/eval/const/etc.)FinishedGraphs asGraphDatas in the runtime. (That is, they are a build-time-only construct).ModelConvertibleor similar intypes.pyimplemented by FinishedGraph (which then is used only in the builder and worker IDL).Structs (by adding anis_ptypefield to GenericType - this is not super-neat, suggestions of better ways to do this welcome, but my previous attempt was even (much) worse]: 454c18f)@runtime_checkablefrom theRestrictedNamedTuplesubclasses/instantiations, but leaving that for Another PRworkflow = g.finish_with_outputs(...)The end result is that you need fewer
TypedGraphRefs (but still some), and when you do need one,pyrightshould catch cases of providing the wrongoutputs_type(because this is now just a runtime reification of a type thatpyrightknows statically).Other possible TODOs (maybe too much for one PR??)
fn graph_ref(self)moved into this Recursive variant)finish_with_outputs-> finish/compile/into_workflow/???