grida 0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
grida/__init__.py ADDED
@@ -0,0 +1,22 @@
1
+ """Grida's minimal node-based workflow orchestration API."""
2
+
3
+ from .workflow import (
4
+ CycleError,
5
+ DuplicateNodeError,
6
+ Node,
7
+ UnknownDependencyError,
8
+ Workflow,
9
+ WorkflowError,
10
+ )
11
+
12
+ __all__ = [
13
+ "CycleError",
14
+ "DuplicateNodeError",
15
+ "Node",
16
+ "UnknownDependencyError",
17
+ "Workflow",
18
+ "WorkflowError",
19
+ ]
20
+
21
+ __version__ = "0.0.1"
22
+
grida/py.typed ADDED
@@ -0,0 +1 @@
1
+
grida/workflow.py ADDED
@@ -0,0 +1,145 @@
1
+ """Small, dependency-free primitives for executing node graphs."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass
6
+ from types import MappingProxyType
7
+ from typing import Any, Callable, Dict, List, Mapping, Optional, Sequence, Tuple
8
+
9
+
10
+ NodeInputs = Mapping[str, Any]
11
+ NodeOperation = Callable[[NodeInputs], Any]
12
+
13
+
14
+ class WorkflowError(Exception):
15
+ """Base exception for invalid workflows."""
16
+
17
+
18
+ class DuplicateNodeError(WorkflowError):
19
+ """Raised when two nodes have the same name."""
20
+
21
+
22
+ class UnknownDependencyError(WorkflowError):
23
+ """Raised when a node depends on a node that is not in its workflow."""
24
+
25
+
26
+ class CycleError(WorkflowError):
27
+ """Raised when workflow dependencies contain a cycle."""
28
+
29
+
30
+ @dataclass(frozen=True)
31
+ class Node:
32
+ """A named operation and the node outputs it requires."""
33
+
34
+ name: str
35
+ operation: NodeOperation
36
+ needs: Tuple[str, ...] = ()
37
+
38
+ def __post_init__(self) -> None:
39
+ if not isinstance(self.name, str) or not self.name.strip():
40
+ raise ValueError("A node name must be a non-empty string.")
41
+ if not callable(self.operation):
42
+ raise TypeError("A node operation must be callable.")
43
+
44
+ normalized_needs = tuple(self.needs)
45
+ if any(not isinstance(name, str) or not name.strip() for name in normalized_needs):
46
+ raise ValueError("Dependency names must be non-empty strings.")
47
+ if len(set(normalized_needs)) != len(normalized_needs):
48
+ raise ValueError("A node cannot list the same dependency more than once.")
49
+ object.__setattr__(self, "needs", normalized_needs)
50
+
51
+
52
+ class Workflow:
53
+ """A collection of nodes that can be validated and run locally."""
54
+
55
+ def __init__(self, name: str) -> None:
56
+ if not isinstance(name, str) or not name.strip():
57
+ raise ValueError("A workflow name must be a non-empty string.")
58
+ self.name = name
59
+ self._nodes: Dict[str, Node] = {}
60
+
61
+ @property
62
+ def nodes(self) -> Mapping[str, Node]:
63
+ """Return a read-only view of the workflow's nodes."""
64
+
65
+ return MappingProxyType(self._nodes)
66
+
67
+ def add(self, node: Node) -> "Workflow":
68
+ """Add a node and return this workflow for fluent declarations."""
69
+
70
+ if node.name in self._nodes:
71
+ raise DuplicateNodeError(f"Node {node.name!r} is already defined.")
72
+ self._nodes[node.name] = node
73
+ return self
74
+
75
+ def order(self) -> Tuple[str, ...]:
76
+ """Validate dependencies and return deterministic execution order."""
77
+
78
+ self._validate_dependencies()
79
+ ordered: List[str] = []
80
+ visiting: List[str] = []
81
+ visited = set()
82
+
83
+ def visit(name: str) -> None:
84
+ if name in visited:
85
+ return
86
+ if name in visiting:
87
+ cycle_start = visiting.index(name)
88
+ cycle = visiting[cycle_start:] + [name]
89
+ raise CycleError("Workflow contains a cycle: " + " -> ".join(cycle))
90
+
91
+ visiting.append(name)
92
+ for dependency in self._nodes[name].needs:
93
+ visit(dependency)
94
+ visiting.pop()
95
+ visited.add(name)
96
+ ordered.append(name)
97
+
98
+ for node_name in self._nodes:
99
+ visit(node_name)
100
+ return tuple(ordered)
101
+
102
+ def run(self, targets: Optional[Sequence[str]] = None) -> Dict[str, Any]:
103
+ """Execute all nodes, or only the dependency closure of target nodes."""
104
+
105
+ order = self.order()
106
+ selected = self._selected_nodes(targets)
107
+ outputs: Dict[str, Any] = {}
108
+
109
+ for name in order:
110
+ if name not in selected:
111
+ continue
112
+ node = self._nodes[name]
113
+ inputs = MappingProxyType(
114
+ {dependency: outputs[dependency] for dependency in node.needs}
115
+ )
116
+ outputs[name] = node.operation(inputs)
117
+ return outputs
118
+
119
+ def _validate_dependencies(self) -> None:
120
+ for node in self._nodes.values():
121
+ for dependency in node.needs:
122
+ if dependency not in self._nodes:
123
+ raise UnknownDependencyError(
124
+ f"Node {node.name!r} depends on unknown node {dependency!r}."
125
+ )
126
+
127
+ def _selected_nodes(self, targets: Optional[Sequence[str]]) -> set:
128
+ if targets is None:
129
+ return set(self._nodes)
130
+
131
+ selected = set()
132
+
133
+ def select(name: str) -> None:
134
+ if name not in self._nodes:
135
+ raise UnknownDependencyError(f"Unknown target node {name!r}.")
136
+ if name in selected:
137
+ return
138
+ selected.add(name)
139
+ for dependency in self._nodes[name].needs:
140
+ select(dependency)
141
+
142
+ for target in targets:
143
+ select(target)
144
+ return selected
145
+
@@ -0,0 +1,93 @@
1
+ Metadata-Version: 2.4
2
+ Name: grida
3
+ Version: 0.0.1
4
+ Summary: A node-based workflow orchestration SDK for digital content creation tools.
5
+ License-Expression: MIT
6
+ Keywords: dcc,pipeline,workflow,orchestration,node-graph
7
+ Classifier: Development Status :: 2 - Pre-Alpha
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3 :: Only
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Topic :: Multimedia :: Graphics
18
+ Classifier: Typing :: Typed
19
+ Requires-Python: >=3.9
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Dynamic: license-file
23
+
24
+ # Grida
25
+
26
+ Grida is an early-stage, node-based workflow orchestration SDK for digital
27
+ content creation (DCC) pipelines.
28
+
29
+ Version `0.0.1` provides a small, working graph kernel for declaring dependent
30
+ operations, validating the graph, and executing nodes in deterministic
31
+ topological order. It has no runtime dependencies.
32
+
33
+ > **Early preview:** This release establishes the package name and the first
34
+ > usable API. The API may change substantially before `1.0`.
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ python -m pip install grida
40
+ ```
41
+
42
+ ## Example
43
+
44
+ ```python
45
+ from grida import Node, Workflow
46
+
47
+ workflow = Workflow("character-export")
48
+ workflow.add(Node("scene", lambda inputs: "hero.ma"))
49
+ workflow.add(
50
+ Node(
51
+ "export",
52
+ lambda inputs: inputs["scene"].replace(".ma", ".fbx"),
53
+ needs=("scene",),
54
+ )
55
+ )
56
+
57
+ outputs = workflow.run()
58
+ assert outputs["export"] == "hero.fbx"
59
+ ```
60
+
61
+ A node receives a read-only mapping containing the outputs of its direct
62
+ dependencies. In a real DCC integration, its operation can call the host API,
63
+ launch a subprocess, or invoke an adapter captured by the operation.
64
+
65
+ ## Current scope
66
+
67
+ Included in `0.0.1`:
68
+
69
+ - Node and workflow declarations
70
+ - Dependency validation
71
+ - Cycle detection
72
+ - Deterministic in-process execution
73
+ - Typed exceptions for invalid graphs
74
+
75
+ Not yet included:
76
+
77
+ - Maya, Blender, Houdini, Unreal, or other host adapters
78
+ - Persistent graphs or a graph file format
79
+ - Distributed execution, caching, retries, or a scheduler
80
+ - Stability guarantees for the public API
81
+
82
+ ## Development
83
+
84
+ Run the tests with the Python standard library:
85
+
86
+ ```bash
87
+ python -m unittest discover -s tests -v
88
+ ```
89
+
90
+ ## License
91
+
92
+ MIT
93
+
@@ -0,0 +1,8 @@
1
+ grida/__init__.py,sha256=1uy1l_Se-Xaog69XokkHDxUIdtOmIz-CnHxIKdGEWdw,361
2
+ grida/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
3
+ grida/workflow.py,sha256=P9zYeKbBBkrm0NoADV8YVJmG45b3t3px9MHkJG_1jxc,4820
4
+ grida-0.0.1.dist-info/licenses/LICENSE,sha256=sPPlBAJFhKmZdrOAgOEY0qycNv0RMAUole4mpxyUcfc,1076
5
+ grida-0.0.1.dist-info/METADATA,sha256=kR5d_l8L_SKje3OSQYgeK7YeUu23FvqjN02Pf5u3bF8,2540
6
+ grida-0.0.1.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
7
+ grida-0.0.1.dist-info/top_level.txt,sha256=Z9xz2YoszSIieuC4icN99_SyV6KqPsGtVUv0fAPkfJY,6
8
+ grida-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Grida contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1 @@
1
+ grida