-
Notifications
You must be signed in to change notification settings - Fork 6
feat: Rust internals #266
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
base: main
Are you sure you want to change the base?
feat: Rust internals #266
Changes from all commits
7e7964b
e8f1415
a00d9c1
e16316d
0dd7f36
5573123
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| {"nodes": [{"value": -1, "outputs": {"value": 5}, "inputs": {}, "type": "const"}, {"value": 1, "outputs": {"value": 4}, "inputs": {}, "type": "const"}, {"name": "n", "outputs": {"n": 7}, "inputs": {}, "type": "input"}, {"name": "factorial", "outputs": {"factorial": 6}, "inputs": {}, "type": "input"}, {"function_name": "builtins.igt", "inputs": {"a": [2, "n"], "b": [1, "value"]}, "outputs": {"value": 9}, "type": "function"}, {"function_name": "builtins.iadd", "inputs": {"a": [0, "value"], "b": [2, "n"]}, "outputs": {"value": 6}, "type": "function"}, {"graph": [3, "factorial"], "inputs": {"n": [5, "value"], "factorial": [3, "factorial"]}, "outputs": {"factorial_output": 7}, "type": "eval"}, {"function_name": "builtins.itimes", "inputs": {"a": [2, "n"], "b": [6, "factorial_output"]}, "outputs": {"value": 9}, "type": "function"}, {"value": 1, "outputs": {"value": 9}, "inputs": {}, "type": "const"}, {"pred": [4, "value"], "if_true": [7, "value"], "if_false": [8, "value"], "outputs": {"value": 10}, "inputs": {}, "type": "ifelse"}, {"inputs": {"factorial_output": [9, "value"]}, "outputs": {}, "type": "output"}], "fixed_inputs": {}, "graph_inputs": ["factorial", "n"], "graph_output_idx": 10} | ||
| {"nodes":[[{"Const":{"value":{"Int":-1}}},{"value":5}],[{"Const":{"value":{"Int":1}}},{"value":4}],[{"Input":{"name":"n"}},{"n":7}],[{"Input":{"name":"factorial"}},{"factorial":6}],[{"Func":{"name":"builtins.igt","inputs":{"a":{"Value":[2,"n"]},"b":{"Value":[1,"value"]}}}},{"value":9}],[{"Func":{"name":"builtins.iadd","inputs":{"a":{"Value":[0,"value"]},"b":{"Value":[2,"n"]}}}},{"value":6}],[{"Eval":{"body":{"Value":[3,"factorial"]},"inputs":{"n":{"Value":[5,"value"]},"factorial":{"Value":[3,"factorial"]}}}},{"factorial_output":7}],[{"Func":{"name":"builtins.itimes","inputs":{"a":{"Value":[2,"n"]},"b":{"Value":[6,"factorial_output"]}}}},{"value":9}],[{"Const":{"value":{"Int":1}}},{"value":9}],[{"IfElse":{"pred":[4,"value"],"if_true":[7,"value"],"if_false":[8,"value"]}},{"value":10}],[{"Output":{"inputs":{"factorial_output":[9,"value"]}}},{}]],"fixed_inputs":{},"graph_inputs":["n","factorial"],"output_idx":10} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| {"nodes": [{"value": 0, "outputs": {"value": 3}, "inputs": {}, "type": "const"}, {"value": 6, "outputs": {"value": 3}, "inputs": {}, "type": "const"}, {"value": {"nodes": [{"name": "doubler_input", "outputs": {"doubler_input": 3}, "inputs": {}, "type": "input"}, {"name": "intercept", "outputs": {"intercept": 4}, "inputs": {}, "type": "input"}, {"value": 2, "outputs": {"value": 3}, "inputs": {}, "type": "const"}, {"function_name": "builtins.itimes", "inputs": {"a": [0, "doubler_input"], "b": [2, "value"]}, "outputs": {"value": 4}, "type": "function"}, {"function_name": "builtins.iadd", "inputs": {"a": [3, "value"], "b": [1, "intercept"]}, "outputs": {"value": 5}, "type": "function"}, {"inputs": {"doubler_output": [4, "value"]}, "outputs": {}, "type": "output"}], "fixed_inputs": {}, "graph_inputs": ["doubler_input", "intercept"], "graph_output_idx": 5}, "outputs": {}, "inputs": {}, "type": "const"}, {"graph": [2, "value"], "inputs": {"doubler_input": [1, "value"], "intercept": [0, "value"]}, "outputs": {"doubler_output": 4}, "type": "eval"}, {"inputs": {"simple_eval_output": [3, "doubler_output"]}, "outputs": {}, "type": "output"}], "fixed_inputs": {}, "graph_inputs": [], "graph_output_idx": 4} | ||
| {"nodes":[[{"Const":{"value":{"Int":0}}},{"value":3}],[{"Const":{"value":{"Int":6}}},{"value":3}],[{"Const":{"value":{"Graph":{"nodes":[[{"Input":{"name":"doubler_input"}},{"doubler_input":3}],[{"Input":{"name":"intercept"}},{"intercept":4}],[{"Const":{"value":{"Int":2}}},{"value":3}],[{"Func":{"name":"builtins.itimes","inputs":{"a":{"Value":[0,"doubler_input"]},"b":{"Value":[2,"value"]}}}},{"value":4}],[{"Func":{"name":"builtins.iadd","inputs":{"a":{"Value":[3,"value"]},"b":{"Value":[1,"intercept"]}}}},{"value":5}],[{"Output":{"inputs":{"doubler_output":[4,"value"]}}},{}]],"fixed_inputs":{},"graph_inputs":["doubler_input","intercept"],"output_idx":5}}}},{}],[{"Eval":{"body":{"Value":[2,"value"]},"inputs":{"doubler_input":{"Value":[1,"value"]},"intercept":{"Value":[0,"value"]}}}},{"doubler_output":4}],[{"Output":{"inputs":{"simple_eval_output":[3,"doubler_output"]}}},{}]],"fixed_inputs":{},"graph_inputs":[],"output_idx":4} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,9 @@ | ||
| import pytest | ||
| from tierkreis.exceptions import TierkreisError | ||
| from tierkreis.controller.data.graph import GraphData | ||
| from tierkreis_core import GraphData | ||
|
|
||
|
|
||
| def test_only_one_output(): | ||
| with pytest.raises(TierkreisError): | ||
| with pytest.raises(ValueError): | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Philosophical question here about whether we should use the standard python errors or custom ones. I can raise a custom exception in the rust code instead but this was easier for me to do at least initially.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personally I prefer errors that reflect what the problem was - "MalformedGraphError" or "GraphTypingError", say, or "TierkreisRuntimeError" (/GraphExecutionError, say). I think it's probably more useful to be able to distinguish between kinds of error (even if (re)using existing python Error classes) rather than to switch all the errors from one type to another. (Ok, there is some value in switching everything from ValueError to TierkreisError because the latter is more distinct from ValueErrors from code that isn't tierkreis at all, but even that would be better done selectively.)
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's certainly some value in custom errors for making the errors more explanatory as well I suppose and custom errors can always inherit from the "pythonic" error base classes.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to double check, something like
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How bad would multiple inheritance be? I could imagine something like class MalformedGraphError(TierkreisError, ValueError):
... |
||
| g = GraphData() | ||
| g.output({"one": g.const(1)}) | ||
| g.output({"two": g.const(2)}) | ||
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.
I guess there is no reason not to move but I do wonder about a re-export in the old location...
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.
We could do, I wasn't a huge fan of the old location (as
GraphDatais used by more things than just the controller).