koode-taskgraph 0.4.1__tar.gz → 0.5.0__tar.gz

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 (35) hide show
  1. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/PKG-INFO +25 -17
  2. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/README.md +24 -16
  3. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/koode_taskgraph.egg-info/PKG-INFO +25 -17
  4. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/koode_taskgraph.egg-info/SOURCES.txt +3 -0
  5. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/pyproject.toml +1 -1
  6. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/taskgraph/cli.py +1 -1
  7. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/taskgraph/core/model.py +172 -4
  8. koode_taskgraph-0.5.0/taskgraph/nodes/builtin.py +96 -0
  9. koode_taskgraph-0.5.0/taskgraph/nodes/systems.py +265 -0
  10. koode_taskgraph-0.5.0/taskgraph/nodes/utils.py +24 -0
  11. koode_taskgraph-0.5.0/taskgraph/ui/code_editor.py +69 -0
  12. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/taskgraph/ui/items.py +3 -2
  13. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/taskgraph/ui/plugins.py +5 -90
  14. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/taskgraph/ui/properties.py +15 -63
  15. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/taskgraph/ui/theme.py +4 -0
  16. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/tests/test_core.py +73 -4
  17. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/tests/test_gui_plugins.py +92 -66
  18. koode_taskgraph-0.4.1/taskgraph/nodes/builtin.py +0 -156
  19. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/LICENSE +0 -0
  20. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/koode_taskgraph.egg-info/dependency_links.txt +0 -0
  21. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/koode_taskgraph.egg-info/entry_points.txt +0 -0
  22. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/koode_taskgraph.egg-info/requires.txt +0 -0
  23. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/koode_taskgraph.egg-info/top_level.txt +0 -0
  24. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/setup.cfg +0 -0
  25. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/taskgraph/__init__.py +0 -0
  26. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/taskgraph/__main__.py +0 -0
  27. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/taskgraph/app.py +0 -0
  28. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/taskgraph/core/__init__.py +0 -0
  29. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/taskgraph/core/executor.py +0 -0
  30. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/taskgraph/core/registry.py +0 -0
  31. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/taskgraph/core/serialization.py +0 -0
  32. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/taskgraph/nodes/__init__.py +0 -0
  33. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/taskgraph/ui/__init__.py +0 -0
  34. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/taskgraph/ui/main_window.py +0 -0
  35. {koode_taskgraph-0.4.1 → koode_taskgraph-0.5.0}/taskgraph/ui/scene.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: koode-taskgraph
3
- Version: 0.4.1
3
+ Version: 0.5.0
4
4
  Summary: An extensible process node graph built with QtPy and PySide6
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -93,15 +93,26 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for pull request guidelines.
93
93
 
94
94
  ## Built-in Nodes
95
95
 
96
- - Built-in nodes are organized as **System → Run Command/Print**,
97
- **Utils → Format Text**, and **Inputs → Text/Number**.
98
- - **Inputs → Text** outputs a user-provided text value.
96
+ - Built-in nodes are organized as **System → Run Command/Python Script/Print**,
97
+ **Utils → Format Text**, and **Inputs → String/Number/Path/List/Dict**.
98
+ - **Inputs → String** outputs a user-provided string value.
99
99
  - **Inputs → Number** outputs a user-provided numeric value.
100
+ - **Inputs → Path** outputs a user-selected file or directory path.
101
+ - **Inputs → List** outputs a JSON-authored Python list.
102
+ - **Inputs → Dict** outputs a JSON-authored Python dictionary.
100
103
  - **System → Print** prints an incoming value and supports an optional prefix.
101
104
  - **System → Run Command** executes a command and exposes stdout, stderr, and
102
105
  return code outputs. It supports an optional working directory, shell mode,
103
106
  timeout, and failure on non-zero exit. Shell mode executes exactly what the
104
107
  graph author enters, so only run trusted graphs.
108
+ - **System → Python Script** runs user-provided Python code in a subprocess.
109
+ The script must define `process(inputs)` and return a dictionary. Connected
110
+ values arrive through the multi-input `value` port as `inputs["value"]` and
111
+ `inputs["values"]`. The node exposes `result`, captured `stdout`, and
112
+ captured `stderr`. The code editor uses a monospace font, keeps line wrapping
113
+ off, inserts spaces with **Tab**, and unindents with **Shift+Tab**. Python
114
+ Script runs arbitrary code with the same user permissions as TaskGraph, so
115
+ only run trusted graphs.
105
116
  - **Utils → Format Text** accepts multiple connections into its `value` input.
106
117
  Use positional placeholders such as `{0}`, `{1}`, and `{2}` in the template.
107
118
  `{value}` remains available as the first input value for simple one-input
@@ -183,7 +194,7 @@ node to edit its properties, then click **Run graph**.
183
194
  Create a module in `taskgraph/nodes/` and define a `ProcessNode` subclass:
184
195
 
185
196
  ```python
186
- from taskgraph.core.model import NodeProperty, PortSpec, ProcessNode
197
+ from taskgraph.core.model import PortSpec, ProcessNode, TextProperty
187
198
  from taskgraph.core.registry import register_node
188
199
 
189
200
  @register_node
@@ -194,17 +205,17 @@ class PrefixText(ProcessNode):
194
205
  inputs = (PortSpec("value", "any"),)
195
206
  outputs = (PortSpec("text", "text"),)
196
207
  properties = (
197
- NodeProperty("prefix", "Prefix", "text", "Result: "),
208
+ TextProperty("prefix", "Prefix", "Result: "),
198
209
  )
199
210
 
200
211
  def process(self, inputs):
201
212
  return {"text": f"{self.prefix}{inputs.get('value', '')}"}
202
213
  ```
203
214
 
204
- Property kinds map to generated controls in the Properties panel: `"text"` for
205
- a line edit, `"file"` for a file path field with a Browse button, `"bool"` for
206
- a checkbox, `"int"`/`"float"` for numeric fields, and `"choice"` for a
207
- dropdown using `choices`.
215
+ Property specs map to generated controls in the Properties panel:
216
+ `TextProperty`, `MultilineProperty`, `BoolProperty`, `IntProperty`,
217
+ `FloatProperty`, `ChoiceProperty`, and `PathProperty`. Use typed specs for new
218
+ nodes so property-specific behavior stays with the property declaration.
208
219
 
209
220
  Modules in `taskgraph/nodes/` are discovered automatically. Custom modules can
210
221
  also live anywhere on disk:
@@ -272,9 +283,9 @@ class Plugin(TaskGraphGuiPlugin):
272
283
 
273
284
  def build_daily_report(self):
274
285
  text = self.graph.create_node(
275
- "input.text",
286
+ "input.string",
276
287
  name="Report Title",
277
- values={"text": "Daily Production Report"},
288
+ values={"string": "Daily Production Report"},
278
289
  position=(0, 0),
279
290
  )
280
291
  printer = self.graph.create_node(
@@ -283,7 +294,7 @@ class Plugin(TaskGraphGuiPlugin):
283
294
  position=(320, 0),
284
295
  )
285
296
  self.graph.connect_dependency(text, printer)
286
- self.graph.connect_attribute(text, "text", printer, "value")
297
+ self.graph.connect_attribute(text, "string", printer, "value")
287
298
  self.graph.add_backdrop(
288
299
  title="Daily Report Template",
289
300
  note="This graph was created by a GUI plugin.",
@@ -292,10 +303,7 @@ class Plugin(TaskGraphGuiPlugin):
292
303
  )
293
304
  ```
294
305
 
295
- Older flat helpers such as `api.create_node(...)` and
296
- `api.add_menu_action(...)`, plus the old `register_taskgraph_plugin(api)`
297
- function entrypoint, are still supported for compatibility. New plugins should
298
- use the OOP `Plugin` class and namespaced API.
306
+ GUI plugins must define an OOP `Plugin` class and use the namespaced API.
299
307
 
300
308
  Load GUI plugins from **Plugins → Add GUI Plugin Location…** for the current
301
309
  session. GUI plugin locations are not saved or automatically reloaded on the
@@ -82,15 +82,26 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for pull request guidelines.
82
82
 
83
83
  ## Built-in Nodes
84
84
 
85
- - Built-in nodes are organized as **System → Run Command/Print**,
86
- **Utils → Format Text**, and **Inputs → Text/Number**.
87
- - **Inputs → Text** outputs a user-provided text value.
85
+ - Built-in nodes are organized as **System → Run Command/Python Script/Print**,
86
+ **Utils → Format Text**, and **Inputs → String/Number/Path/List/Dict**.
87
+ - **Inputs → String** outputs a user-provided string value.
88
88
  - **Inputs → Number** outputs a user-provided numeric value.
89
+ - **Inputs → Path** outputs a user-selected file or directory path.
90
+ - **Inputs → List** outputs a JSON-authored Python list.
91
+ - **Inputs → Dict** outputs a JSON-authored Python dictionary.
89
92
  - **System → Print** prints an incoming value and supports an optional prefix.
90
93
  - **System → Run Command** executes a command and exposes stdout, stderr, and
91
94
  return code outputs. It supports an optional working directory, shell mode,
92
95
  timeout, and failure on non-zero exit. Shell mode executes exactly what the
93
96
  graph author enters, so only run trusted graphs.
97
+ - **System → Python Script** runs user-provided Python code in a subprocess.
98
+ The script must define `process(inputs)` and return a dictionary. Connected
99
+ values arrive through the multi-input `value` port as `inputs["value"]` and
100
+ `inputs["values"]`. The node exposes `result`, captured `stdout`, and
101
+ captured `stderr`. The code editor uses a monospace font, keeps line wrapping
102
+ off, inserts spaces with **Tab**, and unindents with **Shift+Tab**. Python
103
+ Script runs arbitrary code with the same user permissions as TaskGraph, so
104
+ only run trusted graphs.
94
105
  - **Utils → Format Text** accepts multiple connections into its `value` input.
95
106
  Use positional placeholders such as `{0}`, `{1}`, and `{2}` in the template.
96
107
  `{value}` remains available as the first input value for simple one-input
@@ -172,7 +183,7 @@ node to edit its properties, then click **Run graph**.
172
183
  Create a module in `taskgraph/nodes/` and define a `ProcessNode` subclass:
173
184
 
174
185
  ```python
175
- from taskgraph.core.model import NodeProperty, PortSpec, ProcessNode
186
+ from taskgraph.core.model import PortSpec, ProcessNode, TextProperty
176
187
  from taskgraph.core.registry import register_node
177
188
 
178
189
  @register_node
@@ -183,17 +194,17 @@ class PrefixText(ProcessNode):
183
194
  inputs = (PortSpec("value", "any"),)
184
195
  outputs = (PortSpec("text", "text"),)
185
196
  properties = (
186
- NodeProperty("prefix", "Prefix", "text", "Result: "),
197
+ TextProperty("prefix", "Prefix", "Result: "),
187
198
  )
188
199
 
189
200
  def process(self, inputs):
190
201
  return {"text": f"{self.prefix}{inputs.get('value', '')}"}
191
202
  ```
192
203
 
193
- Property kinds map to generated controls in the Properties panel: `"text"` for
194
- a line edit, `"file"` for a file path field with a Browse button, `"bool"` for
195
- a checkbox, `"int"`/`"float"` for numeric fields, and `"choice"` for a
196
- dropdown using `choices`.
204
+ Property specs map to generated controls in the Properties panel:
205
+ `TextProperty`, `MultilineProperty`, `BoolProperty`, `IntProperty`,
206
+ `FloatProperty`, `ChoiceProperty`, and `PathProperty`. Use typed specs for new
207
+ nodes so property-specific behavior stays with the property declaration.
197
208
 
198
209
  Modules in `taskgraph/nodes/` are discovered automatically. Custom modules can
199
210
  also live anywhere on disk:
@@ -261,9 +272,9 @@ class Plugin(TaskGraphGuiPlugin):
261
272
 
262
273
  def build_daily_report(self):
263
274
  text = self.graph.create_node(
264
- "input.text",
275
+ "input.string",
265
276
  name="Report Title",
266
- values={"text": "Daily Production Report"},
277
+ values={"string": "Daily Production Report"},
267
278
  position=(0, 0),
268
279
  )
269
280
  printer = self.graph.create_node(
@@ -272,7 +283,7 @@ class Plugin(TaskGraphGuiPlugin):
272
283
  position=(320, 0),
273
284
  )
274
285
  self.graph.connect_dependency(text, printer)
275
- self.graph.connect_attribute(text, "text", printer, "value")
286
+ self.graph.connect_attribute(text, "string", printer, "value")
276
287
  self.graph.add_backdrop(
277
288
  title="Daily Report Template",
278
289
  note="This graph was created by a GUI plugin.",
@@ -281,10 +292,7 @@ class Plugin(TaskGraphGuiPlugin):
281
292
  )
282
293
  ```
283
294
 
284
- Older flat helpers such as `api.create_node(...)` and
285
- `api.add_menu_action(...)`, plus the old `register_taskgraph_plugin(api)`
286
- function entrypoint, are still supported for compatibility. New plugins should
287
- use the OOP `Plugin` class and namespaced API.
295
+ GUI plugins must define an OOP `Plugin` class and use the namespaced API.
288
296
 
289
297
  Load GUI plugins from **Plugins → Add GUI Plugin Location…** for the current
290
298
  session. GUI plugin locations are not saved or automatically reloaded on the
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: koode-taskgraph
3
- Version: 0.4.1
3
+ Version: 0.5.0
4
4
  Summary: An extensible process node graph built with QtPy and PySide6
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -93,15 +93,26 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for pull request guidelines.
93
93
 
94
94
  ## Built-in Nodes
95
95
 
96
- - Built-in nodes are organized as **System → Run Command/Print**,
97
- **Utils → Format Text**, and **Inputs → Text/Number**.
98
- - **Inputs → Text** outputs a user-provided text value.
96
+ - Built-in nodes are organized as **System → Run Command/Python Script/Print**,
97
+ **Utils → Format Text**, and **Inputs → String/Number/Path/List/Dict**.
98
+ - **Inputs → String** outputs a user-provided string value.
99
99
  - **Inputs → Number** outputs a user-provided numeric value.
100
+ - **Inputs → Path** outputs a user-selected file or directory path.
101
+ - **Inputs → List** outputs a JSON-authored Python list.
102
+ - **Inputs → Dict** outputs a JSON-authored Python dictionary.
100
103
  - **System → Print** prints an incoming value and supports an optional prefix.
101
104
  - **System → Run Command** executes a command and exposes stdout, stderr, and
102
105
  return code outputs. It supports an optional working directory, shell mode,
103
106
  timeout, and failure on non-zero exit. Shell mode executes exactly what the
104
107
  graph author enters, so only run trusted graphs.
108
+ - **System → Python Script** runs user-provided Python code in a subprocess.
109
+ The script must define `process(inputs)` and return a dictionary. Connected
110
+ values arrive through the multi-input `value` port as `inputs["value"]` and
111
+ `inputs["values"]`. The node exposes `result`, captured `stdout`, and
112
+ captured `stderr`. The code editor uses a monospace font, keeps line wrapping
113
+ off, inserts spaces with **Tab**, and unindents with **Shift+Tab**. Python
114
+ Script runs arbitrary code with the same user permissions as TaskGraph, so
115
+ only run trusted graphs.
105
116
  - **Utils → Format Text** accepts multiple connections into its `value` input.
106
117
  Use positional placeholders such as `{0}`, `{1}`, and `{2}` in the template.
107
118
  `{value}` remains available as the first input value for simple one-input
@@ -183,7 +194,7 @@ node to edit its properties, then click **Run graph**.
183
194
  Create a module in `taskgraph/nodes/` and define a `ProcessNode` subclass:
184
195
 
185
196
  ```python
186
- from taskgraph.core.model import NodeProperty, PortSpec, ProcessNode
197
+ from taskgraph.core.model import PortSpec, ProcessNode, TextProperty
187
198
  from taskgraph.core.registry import register_node
188
199
 
189
200
  @register_node
@@ -194,17 +205,17 @@ class PrefixText(ProcessNode):
194
205
  inputs = (PortSpec("value", "any"),)
195
206
  outputs = (PortSpec("text", "text"),)
196
207
  properties = (
197
- NodeProperty("prefix", "Prefix", "text", "Result: "),
208
+ TextProperty("prefix", "Prefix", "Result: "),
198
209
  )
199
210
 
200
211
  def process(self, inputs):
201
212
  return {"text": f"{self.prefix}{inputs.get('value', '')}"}
202
213
  ```
203
214
 
204
- Property kinds map to generated controls in the Properties panel: `"text"` for
205
- a line edit, `"file"` for a file path field with a Browse button, `"bool"` for
206
- a checkbox, `"int"`/`"float"` for numeric fields, and `"choice"` for a
207
- dropdown using `choices`.
215
+ Property specs map to generated controls in the Properties panel:
216
+ `TextProperty`, `MultilineProperty`, `BoolProperty`, `IntProperty`,
217
+ `FloatProperty`, `ChoiceProperty`, and `PathProperty`. Use typed specs for new
218
+ nodes so property-specific behavior stays with the property declaration.
208
219
 
209
220
  Modules in `taskgraph/nodes/` are discovered automatically. Custom modules can
210
221
  also live anywhere on disk:
@@ -272,9 +283,9 @@ class Plugin(TaskGraphGuiPlugin):
272
283
 
273
284
  def build_daily_report(self):
274
285
  text = self.graph.create_node(
275
- "input.text",
286
+ "input.string",
276
287
  name="Report Title",
277
- values={"text": "Daily Production Report"},
288
+ values={"string": "Daily Production Report"},
278
289
  position=(0, 0),
279
290
  )
280
291
  printer = self.graph.create_node(
@@ -283,7 +294,7 @@ class Plugin(TaskGraphGuiPlugin):
283
294
  position=(320, 0),
284
295
  )
285
296
  self.graph.connect_dependency(text, printer)
286
- self.graph.connect_attribute(text, "text", printer, "value")
297
+ self.graph.connect_attribute(text, "string", printer, "value")
287
298
  self.graph.add_backdrop(
288
299
  title="Daily Report Template",
289
300
  note="This graph was created by a GUI plugin.",
@@ -292,10 +303,7 @@ class Plugin(TaskGraphGuiPlugin):
292
303
  )
293
304
  ```
294
305
 
295
- Older flat helpers such as `api.create_node(...)` and
296
- `api.add_menu_action(...)`, plus the old `register_taskgraph_plugin(api)`
297
- function entrypoint, are still supported for compatibility. New plugins should
298
- use the OOP `Plugin` class and namespaced API.
306
+ GUI plugins must define an OOP `Plugin` class and use the namespaced API.
299
307
 
300
308
  Load GUI plugins from **Plugins → Add GUI Plugin Location…** for the current
301
309
  session. GUI plugin locations are not saved or automatically reloaded on the
@@ -18,7 +18,10 @@ taskgraph/core/registry.py
18
18
  taskgraph/core/serialization.py
19
19
  taskgraph/nodes/__init__.py
20
20
  taskgraph/nodes/builtin.py
21
+ taskgraph/nodes/systems.py
22
+ taskgraph/nodes/utils.py
21
23
  taskgraph/ui/__init__.py
24
+ taskgraph/ui/code_editor.py
22
25
  taskgraph/ui/items.py
23
26
  taskgraph/ui/main_window.py
24
27
  taskgraph/ui/plugins.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "koode-taskgraph"
7
- version = "0.4.1"
7
+ version = "0.5.0"
8
8
  readme = "README.md"
9
9
  description = "An extensible process node graph built with QtPy and PySide6"
10
10
  requires-python = ">=3.10"
@@ -40,7 +40,7 @@ def build_parser() -> argparse.ArgumentParser:
40
40
  )
41
41
  parser.add_argument(
42
42
  "--file", "-f", required=True, type=Path,
43
- help="path to a .taskgraph or compatible JSON graph file",
43
+ help="path to a .taskgraph file",
44
44
  )
45
45
  parser.add_argument(
46
46
  "--workers", "-w", type=worker_count, default=4,
@@ -21,12 +21,180 @@ class PortSpec:
21
21
  class NodeProperty:
22
22
  name: str
23
23
  label: str
24
- kind: str
25
24
  default: Any = None
26
- choices: tuple[Any, ...] = ()
27
- minimum: float | None = None
28
- maximum: float | None = None
29
25
 
26
+ def create_editor(self, node: ProcessNode, value: Any, on_change, parent=None):
27
+ raise NotImplementedError
28
+
29
+
30
+ class TextProperty(NodeProperty):
31
+ def __init__(self, name: str, label: str, default: str = ""):
32
+ super().__init__(name, label, default)
33
+
34
+ def create_editor(self, node: ProcessNode, value: Any, on_change, parent=None):
35
+ from qtpy.QtWidgets import QLineEdit
36
+
37
+ widget = QLineEdit("" if value is None else str(value), parent)
38
+ widget.editingFinished.connect(
39
+ lambda editor=widget: on_change(self.name, editor.text())
40
+ )
41
+ return widget
42
+
43
+
44
+ class MultilineProperty(NodeProperty):
45
+ def __init__(self, name: str, label: str, default: str = ""):
46
+ super().__init__(name, label, default)
47
+
48
+ def create_editor(self, node: ProcessNode, value: Any, on_change, parent=None):
49
+ from taskgraph.ui.code_editor import CodeEditor
50
+
51
+ widget = CodeEditor("" if value is None else str(value), parent)
52
+ widget.textChanged.connect(
53
+ lambda editor=widget: on_change(self.name, editor.toPlainText())
54
+ )
55
+ return widget
56
+
57
+
58
+ class BoolProperty(NodeProperty):
59
+ def __init__(self, name: str, label: str, default: bool = False):
60
+ super().__init__(name, label, default)
61
+
62
+ def create_editor(self, node: ProcessNode, value: Any, on_change, parent=None):
63
+ from qtpy.QtWidgets import QCheckBox
64
+
65
+ widget = QCheckBox(parent)
66
+ widget.setChecked(bool(value))
67
+ widget.toggled.connect(lambda checked: on_change(self.name, checked))
68
+ return widget
69
+
70
+
71
+ class IntProperty(NodeProperty):
72
+ def __init__(
73
+ self,
74
+ name: str,
75
+ label: str,
76
+ default: int = 0,
77
+ minimum: int | None = None,
78
+ maximum: int | None = None,
79
+ ):
80
+ super().__init__(name, label, default)
81
+ object.__setattr__(self, "minimum", minimum)
82
+ object.__setattr__(self, "maximum", maximum)
83
+
84
+ def create_editor(self, node: ProcessNode, value: Any, on_change, parent=None):
85
+ from qtpy.QtWidgets import QSpinBox
86
+
87
+ widget = QSpinBox(parent)
88
+ widget.setRange(
89
+ int(self.minimum if self.minimum is not None else -1_000_000),
90
+ int(self.maximum if self.maximum is not None else 1_000_000),
91
+ )
92
+ widget.setValue(int(value or 0))
93
+ widget.valueChanged.connect(lambda number: on_change(self.name, number))
94
+ return widget
95
+
96
+
97
+ class FloatProperty(NodeProperty):
98
+ def __init__(
99
+ self,
100
+ name: str,
101
+ label: str,
102
+ default: float = 0.0,
103
+ minimum: float | None = None,
104
+ maximum: float | None = None,
105
+ ):
106
+ super().__init__(name, label, default)
107
+ object.__setattr__(self, "minimum", minimum)
108
+ object.__setattr__(self, "maximum", maximum)
109
+
110
+ def create_editor(self, node: ProcessNode, value: Any, on_change, parent=None):
111
+ from qtpy.QtWidgets import QDoubleSpinBox
112
+
113
+ widget = QDoubleSpinBox(parent)
114
+ widget.setDecimals(4)
115
+ widget.setRange(
116
+ self.minimum if self.minimum is not None else -1e12,
117
+ self.maximum if self.maximum is not None else 1e12,
118
+ )
119
+ widget.setValue(float(value or 0))
120
+ widget.valueChanged.connect(lambda number: on_change(self.name, number))
121
+ return widget
122
+
123
+
124
+ class ChoiceProperty(NodeProperty):
125
+ def __init__(
126
+ self,
127
+ name: str,
128
+ label: str,
129
+ choices: tuple[Any, ...],
130
+ default: Any = None,
131
+ ):
132
+ if default is None and choices:
133
+ default = choices[0]
134
+ super().__init__(name, label, default)
135
+ object.__setattr__(self, "choices", choices)
136
+
137
+ def create_editor(self, node: ProcessNode, value: Any, on_change, parent=None):
138
+ from qtpy.QtWidgets import QComboBox
139
+
140
+ widget = QComboBox(parent)
141
+ widget.addItems([str(choice) for choice in self.choices])
142
+ if value in self.choices:
143
+ widget.setCurrentIndex(self.choices.index(value))
144
+ widget.currentIndexChanged.connect(
145
+ lambda index: on_change(self.name, self.choices[index])
146
+ )
147
+ return widget
148
+
149
+
150
+ class PathProperty(NodeProperty):
151
+ def __init__(
152
+ self,
153
+ name: str,
154
+ label: str,
155
+ default: str = "",
156
+ directory: bool = False,
157
+ ):
158
+ super().__init__(name, label, default)
159
+ object.__setattr__(self, "directory", directory)
160
+
161
+ def create_editor(self, node: ProcessNode, value: Any, on_change, parent=None):
162
+ from qtpy.QtWidgets import (
163
+ QFileDialog,
164
+ QHBoxLayout,
165
+ QLineEdit,
166
+ QPushButton,
167
+ QWidget,
168
+ )
169
+
170
+ widget = QWidget(parent)
171
+ layout = QHBoxLayout(widget)
172
+ layout.setContentsMargins(0, 0, 0, 0)
173
+ layout.setSpacing(6)
174
+ path = QLineEdit("" if value is None else str(value), widget)
175
+ browse = QPushButton("Browse...", widget)
176
+
177
+ def commit_path() -> None:
178
+ on_change(self.name, path.text())
179
+
180
+ def browse_path() -> None:
181
+ if self.directory:
182
+ selected_path = QFileDialog.getExistingDirectory(
183
+ widget, f"Select {self.label}", path.text()
184
+ )
185
+ else:
186
+ selected_path, _ = QFileDialog.getOpenFileName(
187
+ widget, f"Select {self.label}", path.text()
188
+ )
189
+ if selected_path:
190
+ path.setText(selected_path)
191
+ commit_path()
192
+
193
+ browse.clicked.connect(browse_path)
194
+ path.editingFinished.connect(commit_path)
195
+ layout.addWidget(path, 1)
196
+ layout.addWidget(browse)
197
+ return widget
30
198
 
31
199
  class ProcessNode:
32
200
  type_id: ClassVar[str] = "core.process"
@@ -0,0 +1,96 @@
1
+ import json
2
+
3
+ from taskgraph.core.model import (
4
+ FloatProperty,
5
+ MultilineProperty,
6
+ PathProperty,
7
+ PortSpec,
8
+ ProcessNode,
9
+ TextProperty,
10
+ )
11
+ from taskgraph.core.registry import register_node
12
+
13
+
14
+ @register_node
15
+ class StringValue(ProcessNode):
16
+ type_id = "input.string"
17
+ title = "String"
18
+ category = "Inputs"
19
+ color = "#087f8c"
20
+ outputs = (PortSpec("string", "string"),)
21
+ properties = (TextProperty("string", "String", "Hello graph"),)
22
+
23
+ def process(self, inputs):
24
+ return {"string": self.string}
25
+
26
+
27
+ @register_node
28
+ class NumberValue(ProcessNode):
29
+ type_id = "input.number"
30
+ title = "Number"
31
+ category = "Inputs"
32
+ color = "#087f8c"
33
+ outputs = (PortSpec("number", "number"),)
34
+ properties = (FloatProperty("number", "Number", 1.0),)
35
+
36
+ def process(self, inputs):
37
+ return {"number": self.number}
38
+
39
+
40
+ @register_node
41
+ class PathValue(ProcessNode):
42
+ type_id = "input.path"
43
+ title = "Path"
44
+ category = "Inputs"
45
+ color = "#087f8c"
46
+ outputs = (PortSpec("path", "string"),)
47
+ properties = (
48
+ PathProperty("path", "Path", ""),
49
+ )
50
+
51
+ def process(self, inputs):
52
+ return {"path": self.path}
53
+
54
+
55
+ @register_node
56
+ class ListValue(ProcessNode):
57
+ type_id = "input.list"
58
+ title = "List"
59
+ category = "Inputs"
60
+ color = "#087f8c"
61
+ outputs = (PortSpec("list", "list"),)
62
+ properties = (
63
+ MultilineProperty(
64
+ "items",
65
+ "Items (JSON List)",
66
+ "[\n \"item 1\",\n \"item 2\"\n]",
67
+ ),
68
+ )
69
+
70
+ def process(self, inputs):
71
+ value = json.loads(self.items)
72
+ if not isinstance(value, list):
73
+ raise ValueError("List node value must be a JSON list")
74
+ return {"list": value}
75
+
76
+
77
+ @register_node
78
+ class DictValue(ProcessNode):
79
+ type_id = "input.dict"
80
+ title = "Dict"
81
+ category = "Inputs"
82
+ color = "#087f8c"
83
+ outputs = (PortSpec("dict", "dict"),)
84
+ properties = (
85
+ MultilineProperty(
86
+ "items",
87
+ "Items (JSON Dict)",
88
+ "{\n \"key\": \"value\"\n}",
89
+ ),
90
+ )
91
+
92
+ def process(self, inputs):
93
+ value = json.loads(self.items)
94
+ if not isinstance(value, dict):
95
+ raise ValueError("Dict node value must be a JSON object")
96
+ return {"dict": value}