haywire-core 0.0.2__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.
Files changed (226) hide show
  1. haywire/__init__.py +0 -0
  2. haywire/core/__init__.py +0 -0
  3. haywire/core/adapter/base.py +307 -0
  4. haywire/core/adapter/factory.py +509 -0
  5. haywire/core/adapter/registry.py +285 -0
  6. haywire/core/assembly/__init__.py +35 -0
  7. haywire/core/assembly/control_flow_builder.py +165 -0
  8. haywire/core/assembly/data_flow_builder.py +284 -0
  9. haywire/core/assembly/flow_assembly_manager.py +461 -0
  10. haywire/core/debug/__init__.py +0 -0
  11. haywire/core/debug/configurator.py +139 -0
  12. haywire/core/debug/debug_settings.py +99 -0
  13. haywire/core/debug/keys.py +31 -0
  14. haywire/core/di/__init__.py +6 -0
  15. haywire/core/di/config.py +925 -0
  16. haywire/core/di/context.py +148 -0
  17. haywire/core/di/test_config.py +259 -0
  18. haywire/core/edge/edge.py +52 -0
  19. haywire/core/edge/edge_wrapper.py +896 -0
  20. haywire/core/errors/__init__.py +15 -0
  21. haywire/core/errors/haywire_exception.py +1173 -0
  22. haywire/core/errors/node_exceptions.py +33 -0
  23. haywire/core/errors/utils.py +10 -0
  24. haywire/core/execution/__init__.py +68 -0
  25. haywire/core/execution/callback_manager.py +138 -0
  26. haywire/core/execution/event_source.py +139 -0
  27. haywire/core/execution/execution_context.py +69 -0
  28. haywire/core/execution/flow.py +318 -0
  29. haywire/core/execution/interpreter.py +373 -0
  30. haywire/core/execution/scheduler.py +397 -0
  31. haywire/core/execution/settings.py +27 -0
  32. haywire/core/execution/vm.py +391 -0
  33. haywire/core/graph/__init__.py +19 -0
  34. haywire/core/graph/base.py +1081 -0
  35. haywire/core/graph/editor.py +253 -0
  36. haywire/core/graph/types.py +216 -0
  37. haywire/core/graph/utils/graph_to_python.py +148 -0
  38. haywire/core/graph/validation.py +418 -0
  39. haywire/core/host/__init__.py +8 -0
  40. haywire/core/host/store.py +130 -0
  41. haywire/core/library/__init__.py +3 -0
  42. haywire/core/library/base.py +237 -0
  43. haywire/core/library/decorator.py +94 -0
  44. haywire/core/library/decorator_io.py +34 -0
  45. haywire/core/library/dep_detect.py +377 -0
  46. haywire/core/library/discovery.py +185 -0
  47. haywire/core/library/file_watcher.py +373 -0
  48. haywire/core/library/identity.py +33 -0
  49. haywire/core/library/info.py +30 -0
  50. haywire/core/library/install_type.py +13 -0
  51. haywire/core/library/registry.py +721 -0
  52. haywire/core/library/utils.py +136 -0
  53. haywire/core/marketstall/__init__.py +128 -0
  54. haywire/core/marketstall/cache.py +106 -0
  55. haywire/core/marketstall/errors.py +31 -0
  56. haywire/core/marketstall/helpers.py +237 -0
  57. haywire/core/marketstall/host_providers/__init__.py +38 -0
  58. haywire/core/marketstall/host_providers/base.py +46 -0
  59. haywire/core/marketstall/host_providers/config.py +50 -0
  60. haywire/core/marketstall/host_providers/github.py +58 -0
  61. haywire/core/marketstall/host_providers/gitlab.py +59 -0
  62. haywire/core/marketstall/parsing.py +223 -0
  63. haywire/core/marketstall/platform.py +35 -0
  64. haywire/core/marketstall/refresh.py +313 -0
  65. haywire/core/marketstall/subscribe.py +139 -0
  66. haywire/core/marketstall/types.py +150 -0
  67. haywire/core/marketstall/url_resolution.py +142 -0
  68. haywire/core/namespaces.py +14 -0
  69. haywire/core/node/__init__.py +48 -0
  70. haywire/core/node/base.py +1345 -0
  71. haywire/core/node/behavior.py +125 -0
  72. haywire/core/node/dataclasses.py +58 -0
  73. haywire/core/node/decorator.py +261 -0
  74. haywire/core/node/factory.py +285 -0
  75. haywire/core/node/identity.py +15 -0
  76. haywire/core/node/info.py +13 -0
  77. haywire/core/node/node_wrapper.py +709 -0
  78. haywire/core/node/properties.py +118 -0
  79. haywire/core/node/registry.py +109 -0
  80. haywire/core/node/user_data.py +290 -0
  81. haywire/core/registry/base.py +957 -0
  82. haywire/core/registry/dependency_graph.py +674 -0
  83. haywire/core/registry/folder_scan.py +206 -0
  84. haywire/core/registry/identity.py +18 -0
  85. haywire/core/registry/lifecycle_event.py +235 -0
  86. haywire/core/session/__init__.py +88 -0
  87. haywire/core/session/context.py +113 -0
  88. haywire/core/session/handlers.py +279 -0
  89. haywire/core/session/protocols.py +35 -0
  90. haywire/core/session/session.py +137 -0
  91. haywire/core/session/session_manager.py +143 -0
  92. haywire/core/session/signals/__init__.py +44 -0
  93. haywire/core/session/signals/bus.py +173 -0
  94. haywire/core/session/signals/descriptor.py +215 -0
  95. haywire/core/session/signals/host.py +33 -0
  96. haywire/core/session/signals/signal.py +38 -0
  97. haywire/core/session/signals/vocabulary.py +176 -0
  98. haywire/core/session/workspace/__init__.py +0 -0
  99. haywire/core/session/workspace/manager.py +54 -0
  100. haywire/core/settings/__init__.py +55 -0
  101. haywire/core/settings/base.py +102 -0
  102. haywire/core/settings/decorator.py +112 -0
  103. haywire/core/settings/descriptor.py +340 -0
  104. haywire/core/settings/enums.py +14 -0
  105. haywire/core/settings/node_settings.py +38 -0
  106. haywire/core/settings/registry.py +972 -0
  107. haywire/core/settings/schema.py +176 -0
  108. haywire/core/settings/settings.py +282 -0
  109. haywire/core/settings/types.py +59 -0
  110. haywire/core/settings/value.py +49 -0
  111. haywire/core/state/__init__.py +23 -0
  112. haywire/core/state/base.py +212 -0
  113. haywire/core/state/container.py +622 -0
  114. haywire/core/state/data_namespace.py +63 -0
  115. haywire/core/state/decorator.py +88 -0
  116. haywire/core/state/identity.py +23 -0
  117. haywire/core/state/registry.py +101 -0
  118. haywire/core/types/__init__.py +60 -0
  119. haywire/core/types/base.py +398 -0
  120. haywire/core/types/decorator.py +165 -0
  121. haywire/core/types/enums.py +60 -0
  122. haywire/core/types/event.py +219 -0
  123. haywire/core/types/fields.py +340 -0
  124. haywire/core/types/identity.py +99 -0
  125. haywire/core/types/interface.py +485 -0
  126. haywire/core/types/pipe.py +94 -0
  127. haywire/core/types/port.py +640 -0
  128. haywire/core/types/registry.py +199 -0
  129. haywire/core/types/utils.py +209 -0
  130. haywire/core/undo/__init__.py +1 -0
  131. haywire/core/undo/actions/__init__.py +1 -0
  132. haywire/core/undo/actions/graph_actions.py +457 -0
  133. haywire/core/undo/base_action.py +269 -0
  134. haywire/core/undo/config.py +112 -0
  135. haywire/core/undo/history_manager.py +483 -0
  136. haywire/core/undo/interfaces.py +180 -0
  137. haywire/core/undo/no_op_history_manager.py +71 -0
  138. haywire/core/utils.py +5 -0
  139. haywire/core/validation/interface.py +59 -0
  140. haywire/core/validation/structural_validator.py +373 -0
  141. haywire/py.typed +0 -0
  142. haywire/ui/app/icon_slot.py +163 -0
  143. haywire/ui/app/shell.py +652 -0
  144. haywire/ui/app/slot.py +826 -0
  145. haywire/ui/app/tab_slot.py +138 -0
  146. haywire/ui/components/__init__.py +3 -0
  147. haywire/ui/components/graph/canvas.py +110 -0
  148. haywire/ui/components/graph/canvas.vue +2408 -0
  149. haywire/ui/components/graph/event_definitions.py +391 -0
  150. haywire/ui/components/graph/generated/graph_events.js +336 -0
  151. haywire/ui/components/graph/generators.py +189 -0
  152. haywire/ui/components/minimap/minimap.py +113 -0
  153. haywire/ui/components/minimap/minimap.vue +412 -0
  154. haywire/ui/components/minimap/settings.py +52 -0
  155. haywire/ui/components/number/drag.py +68 -0
  156. haywire/ui/components/number/drag.vue +347 -0
  157. haywire/ui/components/popup/__init__.py +8 -0
  158. haywire/ui/components/popup/popup.py +195 -0
  159. haywire/ui/components/popup/popup.vue +343 -0
  160. haywire/ui/components/zoom/pan.py +385 -0
  161. haywire/ui/components/zoom/pan.vue +672 -0
  162. haywire/ui/components/zoom/settings.py +38 -0
  163. haywire/ui/console_bridge.py +140 -0
  164. haywire/ui/editor/__init__.py +19 -0
  165. haywire/ui/editor/base.py +151 -0
  166. haywire/ui/editor/decorator.py +95 -0
  167. haywire/ui/editor/identity.py +51 -0
  168. haywire/ui/editor/registry.py +125 -0
  169. haywire/ui/editor/wrapper.py +595 -0
  170. haywire/ui/elements/__init__.py +20 -0
  171. haywire/ui/elements/elements.py +975 -0
  172. haywire/ui/elements/icons.py +200 -0
  173. haywire/ui/errors/error_info.py +136 -0
  174. haywire/ui/errors/haywire_exception.py +327 -0
  175. haywire/ui/modals/__init__.py +21 -0
  176. haywire/ui/modals/confirm_modal.py +75 -0
  177. haywire/ui/modals/diff_modal.py +153 -0
  178. haywire/ui/modals/info_modal.py +54 -0
  179. haywire/ui/modals/install_safety_modal.py +108 -0
  180. haywire/ui/modals/pick_modal.py +86 -0
  181. haywire/ui/modals/rename_modal.py +140 -0
  182. haywire/ui/modals/save_as_modal.py +190 -0
  183. haywire/ui/panel/__init__.py +37 -0
  184. haywire/ui/panel/base.py +68 -0
  185. haywire/ui/panel/context_menu_base.py +89 -0
  186. haywire/ui/panel/decorator.py +126 -0
  187. haywire/ui/panel/error_boundary.py +42 -0
  188. haywire/ui/panel/focus.py +81 -0
  189. haywire/ui/panel/identity.py +56 -0
  190. haywire/ui/panel/layout.py +142 -0
  191. haywire/ui/panel/registry.py +172 -0
  192. haywire/ui/panel/render_utils.py +492 -0
  193. haywire/ui/prefs/__init__.py +23 -0
  194. haywire/ui/prefs/canvas.py +51 -0
  195. haywire/ui/prefs/edge_ui.py +91 -0
  196. haywire/ui/prefs/editor.py +161 -0
  197. haywire/ui/skin/base.py +126 -0
  198. haywire/ui/skin/decorator.py +88 -0
  199. haywire/ui/skin/factory.py +344 -0
  200. haywire/ui/skin/interface.py +12 -0
  201. haywire/ui/skin/nodecard.py +51 -0
  202. haywire/ui/skin/registry.py +229 -0
  203. haywire/ui/skin/settings.py +50 -0
  204. haywire/ui/themes/__init__.py +23 -0
  205. haywire/ui/themes/decorator.py +87 -0
  206. haywire/ui/themes/icon-preview.html +299 -0
  207. haywire/ui/themes/icons.py +90 -0
  208. haywire/ui/themes/identity.py +10 -0
  209. haywire/ui/themes/node_theme.py +38 -0
  210. haywire/ui/themes/registry.py +127 -0
  211. haywire/ui/themes/workbench.py +149 -0
  212. haywire/ui/utils.py +185 -0
  213. haywire/ui/widget/base.py +208 -0
  214. haywire/ui/widget/binding.py +321 -0
  215. haywire/ui/widget/converters.py +327 -0
  216. haywire/ui/widget/decorator.py +95 -0
  217. haywire/ui/widget/factory.py +182 -0
  218. haywire/ui/widget/factory_interface.py +28 -0
  219. haywire/ui/widget/globals.py +108 -0
  220. haywire/ui/widget/identity.py +13 -0
  221. haywire/ui/widget/interface.py +85 -0
  222. haywire/ui/widget/registry.py +96 -0
  223. haywire/ui/widget/simple.py +178 -0
  224. haywire_core-0.0.2.dist-info/METADATA +18 -0
  225. haywire_core-0.0.2.dist-info/RECORD +226 -0
  226. haywire_core-0.0.2.dist-info/WHEEL +4 -0
haywire/__init__.py ADDED
File without changes
File without changes
@@ -0,0 +1,307 @@
1
+ """
2
+ Base adapter classes for type conversion
3
+ """
4
+
5
+ from abc import ABC, abstractmethod
6
+ from typing import TYPE_CHECKING, Any, Callable, ClassVar, List, Optional, Type, TypeVar
7
+ from dataclasses import dataclass
8
+
9
+ from haywire.core.library.identity import LibraryIdentity
10
+ from haywire.core.registry.identity import BaseIdentity
11
+ from haywire.core.library.utils import ADAPTER, derive_library_identity, reg_key
12
+
13
+ if TYPE_CHECKING:
14
+ from haywire.core.types.interface import IType
15
+
16
+ # ============================================================================
17
+ # Decorator
18
+ # ============================================================================
19
+
20
+ T = TypeVar("T")
21
+
22
+
23
+ def adapter(**kwargs: Any) -> Callable[[Type[T]], Type[T]]:
24
+ """
25
+ Decorator to register a class as a type adapter.
26
+
27
+ Always invoked with parentheses — `@adapter(...)`. The bare `@adapter`
28
+ form (no parens) is not supported; `converts_from` and `converts_to`
29
+ are required.
30
+
31
+ Accepts any AdapterIdentity field as a keyword argument.
32
+
33
+ Args:
34
+ label (str, optional): Human-readable display name.
35
+ Defaults to class name if not provided.
36
+ description (str, optional): Human-readable description.
37
+ Defaults to empty string.
38
+ converts_from (type[IType], required): Source IType class.
39
+ converts_to (type[IType], required): Target IType class.
40
+ priority (int, optional): Priority (higher = preferred).
41
+ Defaults to 0.
42
+ deprecation_warning (str, optional): Deprecation warning message.
43
+ Defaults to empty string.
44
+ registry_id (str, optional): Unique identifier for the adapter.
45
+ Defaults to class name if not provided.
46
+
47
+ Any other keyword arguments will be passed through to AdapterIdentity.
48
+ See the AdapterIdentity dataclass for complete list of fields.
49
+
50
+ Usage:
51
+ # Common customization
52
+ @adapter(
53
+ description="Temperature to float conversion",
54
+ converts_from=Temperature,
55
+ converts_to=FLOAT,
56
+ )
57
+ class MyAdapter(BaseAdapter): ...
58
+
59
+ # Full customization with IType classes
60
+ @adapter(
61
+ description="Convert Temperature (Celsius) to FLOAT",
62
+ converts_from=Temperature,
63
+ converts_to=FLOAT,
64
+ priority=5
65
+ )
66
+ class TempToFloatAdapter(BaseAdapter): ...
67
+
68
+ # Multi-hop chain example
69
+ @adapter(
70
+ converts_from=Temperature,
71
+ converts_to=Kelvin,
72
+ priority=10,
73
+ description="Celsius to Kelvin"
74
+ )
75
+ class TempToKelvinAdapter(BaseAdapter): ...
76
+ """
77
+
78
+ def decorator(inner_cls: Type[T]) -> Type[T]:
79
+ if not issubclass(inner_cls, BaseAdapter):
80
+ raise TypeError(f"@adapter can only be applied to BaseAdapter subclasses, got {inner_cls}")
81
+
82
+ # Set defaults from class name if not provided
83
+ kwargs.setdefault("registry_id", inner_cls.__name__)
84
+ kwargs.setdefault("label", inner_cls.__name__)
85
+
86
+ # Get library identity (survives hot-reload)
87
+ library_identity = derive_library_identity(inner_cls)
88
+
89
+ # Auto-derive registry_key
90
+ kwargs["registry_key"] = reg_key(library_identity.id, ADAPTER, kwargs["registry_id"])
91
+
92
+ # Set source info from the class itself
93
+ kwargs["class_name"] = inner_cls.__name__
94
+ kwargs["module"] = inner_cls.__module__
95
+
96
+ # Create and attach identity and library
97
+ inner_cls.class_identity = AdapterIdentity(**kwargs)
98
+ inner_cls.class_library = library_identity
99
+ return inner_cls
100
+
101
+ return decorator
102
+
103
+
104
+ @dataclass(kw_only=True)
105
+ class AdapterIdentity(BaseIdentity):
106
+ """
107
+ Core identifying attributes of an adapter.
108
+
109
+ IType-based: converts_from and converts_to are IType classes.
110
+ """
111
+
112
+ converts_from: type["IType"] # Source IType (FLOAT, Temperature, etc.)
113
+ converts_to: type["IType"] # Target IType (INT, MeshData, etc.)
114
+ priority: int = 0 # Priority (higher = preferred)
115
+
116
+
117
+ # ============================================================================
118
+ # Adapter Interface
119
+ # ============================================================================
120
+
121
+
122
+ class IAdapter(ABC):
123
+ """
124
+ Interface for all adapters.
125
+
126
+ All adapters must implement:
127
+ - convert(): Transform a value
128
+ - execute(): Execute this adapter, then chain to next
129
+ - get_registry_keys(): Get all registry keys in chain
130
+ """
131
+
132
+ # IDENTITY ATTRIBUTES (set by @type decorator)
133
+ class_identity: ClassVar[AdapterIdentity]
134
+ class_library: ClassVar[LibraryIdentity]
135
+
136
+ @abstractmethod
137
+ def convert(self, value: Any) -> Any:
138
+ """
139
+ Method to convert value.
140
+ This method ONLY performs conversion.
141
+ Use execute() to run the full adapter chain.
142
+ Args:
143
+ value: Input value to convert
144
+ Returns:
145
+ Converted value by this adapter only
146
+ """
147
+ pass
148
+
149
+ @abstractmethod
150
+ def execute(self, value: Any) -> Any:
151
+ """
152
+ Main method to execute adapter-chain
153
+ Args:
154
+ value: Input value to convert
155
+ Returns:
156
+ Converted value after executing entire chain
157
+ """
158
+ pass
159
+
160
+ @abstractmethod
161
+ def _get_registry_keys(self) -> List[str]:
162
+ """Get all registry keys in chain"""
163
+ pass
164
+
165
+ @abstractmethod
166
+ def get_test_value(self) -> Any:
167
+ """
168
+ method returns a sample value of the type this adapter
169
+ is converting from for testing this adapter
170
+
171
+ Returns: sample value of the expected input type
172
+ """
173
+ return True
174
+
175
+ def get_test_repetitions(self) -> int:
176
+ """method returns the number of repetitions the test needs to run"""
177
+ return 1
178
+
179
+ @abstractmethod
180
+ def test(self, value: Any) -> Any:
181
+ """
182
+ Tests this adapter with sample data
183
+
184
+ Args:
185
+ value: Sample input value of the type this adapter expects
186
+ """
187
+ return True
188
+
189
+
190
+ # ============================================================================
191
+ # Base Adapter Class
192
+ # ============================================================================
193
+
194
+
195
+ class ReturnAdapter(IAdapter):
196
+ """
197
+ Terminal adapter that returns values unchanged.
198
+
199
+ Used as the default terminal adapter in chains.
200
+ Does not have a registry key (not registered).
201
+ """
202
+
203
+ def convert(self, value: Any) -> Any:
204
+ """Pass through unchanged"""
205
+ return value
206
+
207
+ def execute(self, value: Any) -> Any:
208
+ """Terminal - just return value"""
209
+ return value
210
+
211
+ def get_test_value(self) -> Any:
212
+ """Terminal - always succeeds"""
213
+ return True
214
+
215
+ def test(self, value: int) -> Any:
216
+ return self.execute(value)
217
+
218
+ def _get_registry_keys(self) -> List[str]:
219
+ """Terminal - no registry keys"""
220
+ return []
221
+
222
+
223
+ class BaseAdapter(IAdapter):
224
+ """
225
+ Base class for type adapters.
226
+
227
+ Key design:
228
+ - Type-level operations use IType classes (for registration, matching)
229
+ - Value-level operations use unwrapped primitives/instances (for conversion)
230
+ - Chaining via _chain attribute for recursive execution
231
+
232
+ This creates clean separation between type system and runtime values.
233
+
234
+ Example:
235
+ # Register with type classes
236
+ registry.register_adapter(
237
+ source=Temperature, # IType class
238
+ target=FLOAT, # IType class
239
+ adapter=TemperatureToFloatAdapter
240
+ )
241
+
242
+ # Convert with unwrapped values
243
+ adapter = TemperatureToFloatAdapter()
244
+ result = adapter.convert(25.0) # float -> float (not FLOAT -> FLOAT)
245
+ """
246
+
247
+ def __init__(self, child: Optional[IAdapter] = None):
248
+ """Initialize adapter with child in chain"""
249
+ self._chain: IAdapter = child if child is not None else ReturnAdapter()
250
+
251
+ @abstractmethod
252
+ def convert(self, value: Any) -> Any:
253
+ """
254
+ Value-level conversion: Convert UNWRAPPED value.
255
+ DO NOT USE THIS METHOD FOR CONVERSION. USE execute() INSTEAD.
256
+
257
+ This is where actual data transformation happens.
258
+ Operates on unwrapped primitives or instances, not IType wrappers.
259
+
260
+ Args:
261
+ value: Unwrapped value from source field
262
+ - For primitives: 25.0 (not FLOAT(25.0))
263
+ - For complex: MeshData(...) instance
264
+
265
+ Returns:
266
+ Unwrapped value for target field
267
+ - For primitives: 77.0 (not FLOAT(77.0))
268
+ - For complex: PointCloud(...) instance
269
+ """
270
+ pass
271
+
272
+ def execute(self, value: Any) -> Any:
273
+ """
274
+ Execute this adapter, then delegate to chain.
275
+
276
+ Args:
277
+ value: Input value (unwrapped)
278
+
279
+ Returns:
280
+ Transformed value after executing entire chain
281
+ """
282
+ converted = self.convert(value)
283
+ return self._chain.execute(converted)
284
+
285
+ def test(self, value: int) -> Any:
286
+ return self.execute(value)
287
+
288
+ def _get_registry_keys(self) -> List[str]:
289
+ """
290
+ Get all registry keys for this adapter and any nested adapters.
291
+
292
+ Base implementation returns this adapter's key plus chained keys.
293
+ Compound adapters (ArrayArrayAdapter, StructuralAdapter) should
294
+ override to include nested adapter keys.
295
+
296
+ Returns:
297
+ List of registry keys for hot-reload dependency tracking
298
+ """
299
+ keys = [self.class_identity.registry_key]
300
+ keys.extend(self._chain._get_registry_keys())
301
+ return keys
302
+
303
+
304
+ class ConversionError(Exception):
305
+ """Raised when a type conversion fails"""
306
+
307
+ pass