-
Notifications
You must be signed in to change notification settings - Fork 6
tests: more fun with workers making graphs #392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c2391c4
add some interesting functions to worker (and, update justfile)
acl-cqc 9f1bf66
tests
acl-cqc 4307b17
Merge remote-tracking branch 'origin/main' into acl/test_worker_graphs
acl-cqc 75e2a38
Hide ApplyTwiceInput
acl-cqc 408ffe5
Merge remote-tracking branch 'origin/main' into acl/test_worker_graphs
acl-cqc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| from typing import NamedTuple | ||
|
|
||
| from tests.workers.graph.stubs import doubler_plus_graph | ||
| from tests.workers.graph.stubs import doubler_plus_graph, graph_of_graph, apply_twice | ||
| from tierkreis.builder import GraphBuilder, TypedGraphRef | ||
| from tierkreis.builtins import ( | ||
| conjugate, | ||
|
|
@@ -15,7 +15,7 @@ | |
| tkr_str, | ||
| ) | ||
| from tierkreis.controller.data.core import EmptyModel | ||
| from tierkreis.controller.data.models import TKR | ||
| from tierkreis.controller.data.models import TKR, OpaqueType | ||
|
|
||
|
|
||
| class DoublerInput(NamedTuple): | ||
|
|
@@ -167,6 +167,40 @@ def eval_body_is_from_worker() -> GraphBuilder[TKR[int], TKR[int]]: | |
| return g | ||
|
|
||
|
|
||
| class ApplyTwiceInput(NamedTuple): | ||
| # Note we mangle this as the stub generator does, unlike | ||
|
||
| # the original worker ApplyTwiceInput which takes TKR[GraphData] | ||
| graph: TKR[OpaqueType["tierkreis.controller.data.graph.GraphData"]] # noqa: F821 | ||
| value: TKR[int] | ||
|
|
||
|
|
||
| def eval_from_worker_with_graph_from_worker() -> GraphBuilder[TKR[int], TKR[int]]: | ||
| g = GraphBuilder(TKR[int], TKR[int]) | ||
| graph = g.task(doubler_plus_graph()) | ||
| # This is ok, but we can't pass the graph_ref into ApplyTwiceInputs | ||
| # graph_ref = TypedGraphRef(graph.value_ref(), TKR[int], TKR[int]) | ||
| inputs = ApplyTwiceInput(graph=graph, value=g.inputs) | ||
|
|
||
| ap2 = g.task(apply_twice()) | ||
| # TypedGraphRef Constructor takes outputs then inputs, but type-params are inputs then outputs: | ||
acl-cqc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ap2_ref = TypedGraphRef(ap2.value_ref(), TKR[int], ApplyTwiceInput) | ||
| out = g.eval(ap2_ref, inputs) | ||
| g.outputs(out) | ||
| return g | ||
|
|
||
|
|
||
| def eval_graph_of_graph() -> GraphBuilder[TKR[int], TKR[int]]: | ||
| g = GraphBuilder(TKR[int], TKR[int]) | ||
| graph = g.task(doubler_plus_graph()) | ||
| # This is ok, but we can't pass the graph_ref into exponentiate_graph: | ||
| # graph_ref = TypedGraphRef(graph.value_ref(), TKR[int], TKR[int]) | ||
| eg = g.task(graph_of_graph(graph, g.const(3))) | ||
| exp_graph = TypedGraphRef(eg.value_ref(), TKR[int], TKR[int]) | ||
| out = g.eval(exp_graph, g.inputs) | ||
| g.outputs(out) | ||
| return g | ||
|
|
||
|
|
||
| def embed_graph(): | ||
| class InnerOutput(NamedTuple): | ||
| log: TKR[str] | ||
|
|
||
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added in #322 but lost in #314