GraphBuilder->Graph with separate Workflow type#381
Open
Conversation
e8d272b to
7e92fcb
Compare
dc8ba1f to
e8ce026
Compare
acl-cqc
commented
Mar 4, 2026
tierkreis_visualization/tierkreis_visualization/visualize_graph.py
Outdated
Show resolved
Hide resolved
acl-cqc
added a commit
that referenced
this pull request
Mar 5, 2026
…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
acl-cqc
commented
Mar 5, 2026
…ke & stubs import FinGraph, regen stubs+import FinishedGraph...tests pass but pyright fails
This reverts commit f27123875cf5369f14b5207964a8fa3bc787d0fa.
969cd0f to
66ec5c5
Compare
acl-cqc
added a commit
that referenced
this pull request
Mar 9, 2026
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
acl-cqc
commented
Mar 9, 2026
|
|
||
| This will evaluate a nested graph with the given inputs. | ||
|
|
||
| :param A the input type of the graph. |
Contributor
Author
There was a problem hiding this comment.
Hmmm I mean do we need these :types? Are they not inferred from the type annotations?
acl-cqc
commented
Mar 9, 2026
| graph: GraphBuilder[A, B], | ||
| graph: FinishedGraph[A, B], | ||
| ) -> TypedGraphRef[A, B]: | ||
| # TODO @philipp-seitz: Turn this into a public method? |
Contributor
Author
There was a problem hiding this comment.
I'd +1 this, shall I do it in this PR?
Collaborator
|
Why do we need both |
Contributor
Author
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 |
…es from types.py (still defined at bottom)
07f9b93 to
6ccf080
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Workflowholding a GraphData and outputs_type..outputsrenamed to.finish_with_outputswhich returns a Workflowfinish_with_outputstobuild??loop,eval) to take Workflow'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.)ModelConvertibleprotocol like DictConvertible/etc. but that works for parametrized types. (This was a bit of a can of worms, there are some slightly suspect bits intypes.py.) Workflow implements this, and serializes as aGraphData. (Type erasure: Workflow is a build-time-only construct).PType's which was a bit hacky (special-case, awkward circular import, etc.) but a lot shorter/easier (andDictConvertiblemakes me worry about robustness and parametrization). Thoughts?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 PRThe 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)