Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions devenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
packages = [
pkgs.just
pkgs.graphviz
pkgs.zlib
] ++ lib.optionals pkgs.stdenv.isDarwin (with pkgs.darwin.apple_sdk; [
frameworks.CoreServices
frameworks.CoreFoundation
Expand Down
4 changes: 4 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
extensions = ["autodoc2", "myst_nb"]
autodoc2_packages = [
"../../tierkreis/tierkreis",
"../../tierkreis_core/python/tierkreis_core",
{
"path": "../../tierkreis_workers/aer_worker/main.py",
"module": "aer_worker",
Expand All @@ -29,6 +30,9 @@
"module": "pytket_worker",
},
]
autodoc2_module_all_regexes = [
r"tierkreis_core",
]
autodoc2_hidden_objects = ["private"]

templates_path = ["_templates"]
Expand Down
10 changes: 9 additions & 1 deletion examples/example_workers/auth_worker/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions examples/example_workers/chemistry_worker/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions examples/example_workers/error_worker/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions examples/example_workers/hello_world_worker/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion examples/example_workers/qsci_worker/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion examples/example_workers/scipy_worker/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion examples/example_workers/substitution_worker/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[tool.uv.workspace]
members = [
"tierkreis",
"tierkreis_core",
"tierkreis_visualization",
"tierkreis_workers/*worker",
]
Expand Down Expand Up @@ -33,3 +34,13 @@ docs = [
"furo>=2025.7.19",
]
examples = ["pyscf>=2.9.0"]

[tool.uv.sources]
tierkreis_core = { workspace = true }
quantinuum-sphinx = { git = "https://github.com/CQCL/quantinuum-sphinx.git" }

[tool.maturin]
module-name = "tierkreis_core._tierkreis_core"
python-source = "tierkreis_core/python/"
manifest-path = "tierkreis_core/Cargo.toml"
features = ["pyo3/extension-module"]
1 change: 1 addition & 0 deletions tierkreis/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ authors = [
requires-python = ">=3.12"
dependencies = [
"pydantic~=2.5",
"tierkreis_core",
]

[dependency-groups]
Expand Down
2 changes: 1 addition & 1 deletion tierkreis/tests/cli/data/factorial
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}
2 changes: 1 addition & 1 deletion tierkreis/tests/cli/data/sample_graph
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}
2 changes: 1 addition & 1 deletion tierkreis/tests/cli/test_run_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from unittest import mock


from tierkreis.controller.data.graph import GraphData
from tierkreis.cli.run_workflow import run_workflow
from tests.controller.sample_graphdata import simple_eval
from tierkreis.controller.data.types import ptype_from_bytes
from tierkreis_core import GraphData

logger = logging.getLogger(__name__)

Expand Down
3 changes: 2 additions & 1 deletion tierkreis/tests/cli/test_tkr.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
from uuid import UUID

from tierkreis.cli.tkr import load_graph, _load_inputs, main
from tierkreis.controller.data.graph import GraphData
from tierkreis.controller.data.types import PType
from tierkreis.exceptions import TierkreisError
from tierkreis_core import GraphData

from tests.controller.sample_graphdata import simple_eval

simple_eval_graph = simple_eval()


graph_params = [
("tests.controller.sample_graphdata:simple_eval", simple_eval_graph),
("tierkreis/tests/controller/sample_graphdata.py:simple_eval", simple_eval_graph),
Expand Down
3 changes: 2 additions & 1 deletion tierkreis/tests/controller/loop_graphdata.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from typing import NamedTuple

import tierkreis.builtins.stubs as tkr_builtins
from tierkreis.controller.data.core import EmptyModel
from tierkreis_core import GraphData
Copy link
Contributor

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...

Copy link
Collaborator Author

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 GraphData is used by more things than just the controller).

from tierkreis.builder import GraphBuilder
from tierkreis.controller.data.graph import GraphData
from tierkreis.models import TKR


Expand Down
2 changes: 1 addition & 1 deletion tierkreis/tests/controller/partial_graphdata.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from tierkreis.controller.data.graph import GraphData
from tierkreis_core import GraphData


def ternary_add() -> GraphData:
Expand Down
2 changes: 1 addition & 1 deletion tierkreis/tests/controller/sample_graphdata.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from tierkreis import Labels
from tierkreis.controller.data.graph import GraphData
from tierkreis_core import GraphData


def doubler_plus() -> GraphData:
Expand Down
2 changes: 1 addition & 1 deletion tierkreis/tests/controller/test_eagerifelse.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from tierkreis.controller.executor.shell_executor import ShellExecutor
from tierkreis.controller.executor.uv_executor import UvExecutor
from tierkreis.controller.storage.filestorage import ControllerFileStorage
from tierkreis.controller.data.graph import GraphData
from tierkreis_core import GraphData


def eagerifelse_long_running() -> GraphData:
Expand Down
5 changes: 2 additions & 3 deletions tierkreis/tests/controller/test_graphdata.py
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):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The 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.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to double check, something like MalformedGraphError would be a subclass of TierkreisError? If so then I'm in favour.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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)})
Loading