funcnodes 0.3.2__tar.gz → 0.3.3__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.
- {funcnodes-0.3.2 → funcnodes-0.3.3}/PKG-INFO +2 -2
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/__init__.py +2 -1
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/__main__.py +25 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/io.py +110 -57
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/utils/__init__.py +2 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/utils/data.py +1 -1
- funcnodes-0.3.3/funcnodes/utils/plugins.py +10 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/utils/serialization.py +1 -1
- {funcnodes-0.3.2 → funcnodes-0.3.3}/pyproject.toml +2 -2
- {funcnodes-0.3.2 → funcnodes-0.3.3}/LICENSE +0 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/README.md +0 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/_logging.py +0 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/config.py +0 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/data.py +0 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/eventmanager.py +0 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/exceptions.py +0 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/graph.py +0 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/lib/__init__.py +0 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/lib/lib.py +0 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/lib/libfinder.py +0 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/lib/libparser.py +0 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/node.py +0 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/nodemaker.py +0 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/nodespace.py +0 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/triggerstack.py +0 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/utils/nodeutils.py +0 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/utils/saving.py +0 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/utils/special_types.py +0 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/worker/__init__.py +0 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/worker/external_worker.py +0 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/worker/loop.py +0 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/worker/remote_worker.py +0 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/worker/websocket.py +0 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/worker/worker.py +0 -0
- {funcnodes-0.3.2 → funcnodes-0.3.3}/funcnodes/worker/worker_manager.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: funcnodes
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: funcnodes
|
|
5
5
|
Author: Julian Kimmig
|
|
6
6
|
Author-email: julian.kimmig@linkdlab.de
|
|
@@ -8,7 +8,7 @@ Requires-Python: >=3.11,<4.0
|
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
9
9
|
Classifier: Programming Language :: Python :: 3.11
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
-
Requires-Dist: exposedfunctionality (>=0.3.
|
|
11
|
+
Requires-Dist: exposedfunctionality (>=0.3.8)
|
|
12
12
|
Requires-Dist: funcnodes-basic
|
|
13
13
|
Requires-Dist: funcnodes-react-flow (>=0.1.0,<0.2.0)
|
|
14
14
|
Requires-Dist: networkx (>=3.3,<4.0)
|
|
@@ -178,6 +178,26 @@ def start_worker_manager(args: argparse.Namespace):
|
|
|
178
178
|
fn.worker.worker_manager.start_worker_manager()
|
|
179
179
|
|
|
180
180
|
|
|
181
|
+
def task_modules(args: argparse.Namespace):
|
|
182
|
+
"""
|
|
183
|
+
Performs a task on modules.
|
|
184
|
+
|
|
185
|
+
Args:
|
|
186
|
+
args (argparse.Namespace): The arguments passed to the function.
|
|
187
|
+
|
|
188
|
+
Returns:
|
|
189
|
+
None
|
|
190
|
+
|
|
191
|
+
Examples:
|
|
192
|
+
>>> task_modules(args)
|
|
193
|
+
None
|
|
194
|
+
"""
|
|
195
|
+
if args.moduletask == "list":
|
|
196
|
+
pprint(fn.utils.plugins.get_installed_modules())
|
|
197
|
+
else:
|
|
198
|
+
raise Exception(f"Unknown moduletask: {args.moduletask}")
|
|
199
|
+
|
|
200
|
+
|
|
181
201
|
def main():
|
|
182
202
|
"""
|
|
183
203
|
The main function.
|
|
@@ -235,6 +255,9 @@ def main():
|
|
|
235
255
|
"--version", action="version", version=f"%(prog)s {fn.__version__}"
|
|
236
256
|
)
|
|
237
257
|
|
|
258
|
+
modules_parser = subparsers.add_parser("modules", help="")
|
|
259
|
+
modules_parser.add_argument("moduletask", help="The task to run on the modules")
|
|
260
|
+
|
|
238
261
|
args = parser.parse_args()
|
|
239
262
|
# try:
|
|
240
263
|
if args.task == "runserver":
|
|
@@ -243,6 +266,8 @@ def main():
|
|
|
243
266
|
task_worker(args)
|
|
244
267
|
elif args.task == "startworkermanager":
|
|
245
268
|
start_worker_manager(args)
|
|
269
|
+
elif args.task == "modules":
|
|
270
|
+
task_modules(args)
|
|
246
271
|
else:
|
|
247
272
|
raise Exception(f"Unknown task: {args.task}")
|
|
248
273
|
# except Exception as exc:
|
|
@@ -11,11 +11,14 @@ from typing import (
|
|
|
11
11
|
Union,
|
|
12
12
|
Tuple,
|
|
13
13
|
Required,
|
|
14
|
-
Dict,
|
|
15
14
|
)
|
|
16
15
|
from uuid import uuid4
|
|
17
16
|
from exposedfunctionality import FunctionInputParam, FunctionOutputParam
|
|
18
|
-
from exposedfunctionality.function_parser.types import
|
|
17
|
+
from exposedfunctionality.function_parser.types import (
|
|
18
|
+
string_to_type,
|
|
19
|
+
SerializedType,
|
|
20
|
+
EnumOf,
|
|
21
|
+
)
|
|
19
22
|
from exposedfunctionality import serialize_type
|
|
20
23
|
from .eventmanager import (
|
|
21
24
|
AsyncEventManager,
|
|
@@ -36,16 +39,19 @@ if TYPE_CHECKING:
|
|
|
36
39
|
from .node import Node
|
|
37
40
|
|
|
38
41
|
|
|
39
|
-
class NodeIOSerialization(
|
|
42
|
+
class NodeIOSerialization(
|
|
43
|
+
TypedDict,
|
|
44
|
+
total=False,
|
|
45
|
+
):
|
|
40
46
|
"""Typing definition for serialized Node Input/Output serialization."""
|
|
41
47
|
|
|
42
48
|
name: str
|
|
43
|
-
description:
|
|
44
|
-
type:
|
|
45
|
-
allow_multiple:
|
|
49
|
+
description: str
|
|
50
|
+
type: Required[SerializedType]
|
|
51
|
+
allow_multiple: bool
|
|
46
52
|
id: Required[str]
|
|
47
53
|
value: Required[Any]
|
|
48
|
-
is_input: bool
|
|
54
|
+
is_input: Required[bool]
|
|
49
55
|
render_options: IORenderOptions
|
|
50
56
|
value_options: ValueOptions
|
|
51
57
|
|
|
@@ -55,7 +61,7 @@ class NodeInputSerialization(NodeIOSerialization, total=False):
|
|
|
55
61
|
|
|
56
62
|
required: bool
|
|
57
63
|
does_trigger: bool
|
|
58
|
-
default:
|
|
64
|
+
default: Any
|
|
59
65
|
|
|
60
66
|
|
|
61
67
|
class NodeOutputSerialization(NodeIOSerialization):
|
|
@@ -67,9 +73,9 @@ class NodeIOClassSerialization(TypedDict, total=False):
|
|
|
67
73
|
|
|
68
74
|
name: str
|
|
69
75
|
description: Optional[str]
|
|
70
|
-
type:
|
|
76
|
+
type: SerializedType
|
|
71
77
|
allow_multiple: Optional[bool]
|
|
72
|
-
uuid: str
|
|
78
|
+
uuid: Required[str]
|
|
73
79
|
|
|
74
80
|
|
|
75
81
|
class FullNodeIOJSON(TypedDict):
|
|
@@ -78,7 +84,7 @@ class FullNodeIOJSON(TypedDict):
|
|
|
78
84
|
id: str
|
|
79
85
|
full_id: str | None
|
|
80
86
|
name: str
|
|
81
|
-
type:
|
|
87
|
+
type: SerializedType
|
|
82
88
|
is_input: bool
|
|
83
89
|
connected: bool
|
|
84
90
|
node: str | None
|
|
@@ -97,6 +103,8 @@ class FullNodeInputJSON(FullNodeIOJSON):
|
|
|
97
103
|
|
|
98
104
|
# A unique object that represents the absence of a value
|
|
99
105
|
class NoValueType:
|
|
106
|
+
"""A unique object that represents the absence of a value."""
|
|
107
|
+
|
|
100
108
|
_instance = None
|
|
101
109
|
|
|
102
110
|
def __new__(cls):
|
|
@@ -115,27 +123,33 @@ NoValue: NoValueType = NoValueType()
|
|
|
115
123
|
|
|
116
124
|
|
|
117
125
|
class IOReadyState(TypedDict):
|
|
126
|
+
"""Typing definition for Node Input/Output ready state."""
|
|
127
|
+
|
|
118
128
|
node: bool
|
|
119
129
|
|
|
120
130
|
|
|
121
131
|
class InputReadyState(IOReadyState):
|
|
132
|
+
"""Typing definition for Node Input ready state."""
|
|
133
|
+
|
|
122
134
|
value: bool
|
|
123
135
|
|
|
124
136
|
|
|
125
|
-
def
|
|
137
|
+
def novalue_endocer(obj, preview=False):
|
|
138
|
+
"""Encodes NoValue objects."""
|
|
126
139
|
if obj is NoValue:
|
|
127
140
|
return "<NoValue>", True
|
|
128
141
|
return obj, False
|
|
129
142
|
|
|
130
143
|
|
|
131
|
-
def
|
|
144
|
+
def novalue_decoder(obj):
|
|
145
|
+
"""Decodes NoValue objects."""
|
|
132
146
|
if obj == "<NoValue>":
|
|
133
147
|
return NoValue, True
|
|
134
148
|
return obj, False
|
|
135
149
|
|
|
136
150
|
|
|
137
|
-
JSONDecoder.add_decoder(
|
|
138
|
-
JSONEncoder.add_encoder(
|
|
151
|
+
JSONDecoder.add_decoder(novalue_decoder)
|
|
152
|
+
JSONEncoder.add_encoder(novalue_endocer, enc_cls=[NoValueType])
|
|
139
153
|
|
|
140
154
|
|
|
141
155
|
class NodeIOError(Exception):
|
|
@@ -155,11 +169,14 @@ class SameNodeConnectionError(NodeConnectionError):
|
|
|
155
169
|
|
|
156
170
|
|
|
157
171
|
class MultipleConnectionsError(NodeConnectionError):
|
|
158
|
-
"""
|
|
172
|
+
"""
|
|
173
|
+
Exception raised when attempting to connect an IO that does not allow
|
|
174
|
+
multiple connections.
|
|
175
|
+
"""
|
|
159
176
|
|
|
160
177
|
|
|
161
178
|
class NodeIOStatus(TypedDict):
|
|
162
|
-
"""Typing definition for Node
|
|
179
|
+
"""Typing definition for Node IO status."""
|
|
163
180
|
|
|
164
181
|
has_value: bool
|
|
165
182
|
has_node: bool
|
|
@@ -168,10 +185,13 @@ class NodeIOStatus(TypedDict):
|
|
|
168
185
|
|
|
169
186
|
|
|
170
187
|
class NodeInputStatus(NodeIOStatus):
|
|
188
|
+
"""Typing definition for Node Input status."""
|
|
189
|
+
|
|
171
190
|
required: bool
|
|
172
191
|
|
|
173
192
|
|
|
174
|
-
class NodeOutputStatus(NodeIOStatus):
|
|
193
|
+
class NodeOutputStatus(NodeIOStatus):
|
|
194
|
+
"""Typing definition for Node Output status."""
|
|
175
195
|
|
|
176
196
|
|
|
177
197
|
def raise_allow_connections(src: NodeIO, trg: NodeIO):
|
|
@@ -186,7 +206,8 @@ def raise_allow_connections(src: NodeIO, trg: NodeIO):
|
|
|
186
206
|
|
|
187
207
|
Raises:
|
|
188
208
|
NodeConnectionError: If attempting to connect two outputs or two inputs.
|
|
189
|
-
MultipleConnectionsError: If either the source or target does not allow
|
|
209
|
+
MultipleConnectionsError: If either the source or target does not allow
|
|
210
|
+
multiple connections.
|
|
190
211
|
"""
|
|
191
212
|
# Check if connection is not allowed between two outputs or two inputs
|
|
192
213
|
if isinstance(src, NodeOutput):
|
|
@@ -233,8 +254,6 @@ class IORenderOptions(TypedDict, total=False):
|
|
|
233
254
|
class GenericValueOptions(TypedDict, total=False):
|
|
234
255
|
"""Typing definition for Node Input/Output generic value options."""
|
|
235
256
|
|
|
236
|
-
pass
|
|
237
|
-
|
|
238
257
|
|
|
239
258
|
class NumberValueOptions(GenericValueOptions, total=False):
|
|
240
259
|
"""Typing definition for Node Input/Output number value options."""
|
|
@@ -247,13 +266,13 @@ class NumberValueOptions(GenericValueOptions, total=False):
|
|
|
247
266
|
class EnumValueOptions(GenericValueOptions, total=False):
|
|
248
267
|
"""Typing definition for Node Input/Output enum value options."""
|
|
249
268
|
|
|
250
|
-
options:
|
|
269
|
+
options: EnumOf
|
|
251
270
|
|
|
252
271
|
|
|
253
272
|
class LiteralValueOptions(GenericValueOptions, total=False):
|
|
254
273
|
"""Typing definition for Node Input/Output literal value options."""
|
|
255
274
|
|
|
256
|
-
options: List[str, int, float]
|
|
275
|
+
options: List[Union[str, int, float]]
|
|
257
276
|
|
|
258
277
|
|
|
259
278
|
ValueOptions = Union[
|
|
@@ -265,38 +284,57 @@ NodeIOType = TypeVar("NodeIOType")
|
|
|
265
284
|
|
|
266
285
|
|
|
267
286
|
class IOOptions(NodeIOSerialization, total=False):
|
|
287
|
+
"""Typing definition for Node Input/Output options."""
|
|
288
|
+
|
|
268
289
|
emit_value_set: bool
|
|
269
290
|
|
|
270
291
|
|
|
271
292
|
class NodeInputOptions(IOOptions, NodeInputSerialization, total=False):
|
|
272
|
-
|
|
293
|
+
"""Typing definition for Node Input options."""
|
|
273
294
|
|
|
274
295
|
|
|
275
296
|
class NodeOutputOptions(IOOptions, NodeOutputSerialization, total=False):
|
|
276
|
-
|
|
297
|
+
"""Typing definition for Node Output options."""
|
|
277
298
|
|
|
278
299
|
|
|
279
|
-
def
|
|
280
|
-
|
|
300
|
+
def generate_value_options(
|
|
301
|
+
_type: SerializedType, value_options: Optional[GenericValueOptions] = None
|
|
302
|
+
) -> ValueOptions:
|
|
303
|
+
"""Generates value options for a NodeIO instance based on the type.
|
|
281
304
|
|
|
305
|
+
Args:
|
|
306
|
+
_type: The type of the NodeIO instance.
|
|
307
|
+
value_options: Optional value options to update.
|
|
282
308
|
|
|
283
|
-
|
|
309
|
+
Returns:
|
|
310
|
+
The generated value options.
|
|
311
|
+
"""
|
|
284
312
|
if value_options is not None:
|
|
285
|
-
|
|
313
|
+
opts = value_options
|
|
314
|
+
else:
|
|
315
|
+
opts = GenericValueOptions()
|
|
286
316
|
|
|
287
|
-
opts = {}
|
|
288
317
|
if isinstance(_type, dict) and "type" in _type and _type["type"] == "enum":
|
|
289
|
-
opts
|
|
318
|
+
opts.update(
|
|
319
|
+
EnumValueOptions(
|
|
320
|
+
options=_type,
|
|
321
|
+
)
|
|
322
|
+
)
|
|
290
323
|
|
|
291
324
|
if isinstance(_type, dict) and "anyOf" in _type:
|
|
292
|
-
nopts =
|
|
325
|
+
nopts = GenericValueOptions()
|
|
293
326
|
for _t in _type["anyOf"]:
|
|
294
|
-
nopts.update(generate_value_options(
|
|
295
|
-
|
|
327
|
+
nopts.update(generate_value_options(_t, None))
|
|
328
|
+
nopts.update(opts)
|
|
329
|
+
opts = nopts
|
|
296
330
|
|
|
297
331
|
if isinstance(_type, str):
|
|
298
332
|
if _type == "int":
|
|
299
|
-
opts
|
|
333
|
+
opts.update(
|
|
334
|
+
NumberValueOptions(
|
|
335
|
+
step=1,
|
|
336
|
+
)
|
|
337
|
+
)
|
|
300
338
|
|
|
301
339
|
return opts
|
|
302
340
|
|
|
@@ -309,7 +347,7 @@ class NodeIO(EventEmitterMixin, Generic[NodeIOType]):
|
|
|
309
347
|
def __init__(
|
|
310
348
|
self,
|
|
311
349
|
name: Optional[str] = None,
|
|
312
|
-
type:
|
|
350
|
+
type: SerializedType | Type = "Any",
|
|
313
351
|
description: Optional[str] = None,
|
|
314
352
|
allow_multiple: Optional[bool] = None,
|
|
315
353
|
uuid: Optional[str] = None,
|
|
@@ -340,16 +378,24 @@ class NodeIO(EventEmitterMixin, Generic[NodeIOType]):
|
|
|
340
378
|
self._allow_multiple: Optional[bool] = allow_multiple
|
|
341
379
|
self._node: Optional[weakref.ref[Node]] = None
|
|
342
380
|
if isinstance(type, str):
|
|
343
|
-
type = string_to_type(type)
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
381
|
+
true_type: type = string_to_type(type)
|
|
382
|
+
ser_type = serialize_type(true_type)
|
|
383
|
+
elif isinstance(type, dict):
|
|
384
|
+
ser_type = type
|
|
385
|
+
else:
|
|
386
|
+
ser_type = serialize_type(type)
|
|
387
|
+
if not isinstance(ser_type, (str, dict)):
|
|
388
|
+
raise TypeError(
|
|
389
|
+
f"type must be a string or a dict (exposedfunctionality.SerializedType) or type not {ser_type}"
|
|
390
|
+
)
|
|
391
|
+
|
|
392
|
+
self._sertype: SerializedType = ser_type
|
|
347
393
|
|
|
348
394
|
self.eventmanager = AsyncEventManager(self)
|
|
349
|
-
self._value_options: ValueOptions =
|
|
395
|
+
self._value_options: ValueOptions = GenericValueOptions()
|
|
350
396
|
self._default_render_options = render_options or {}
|
|
351
397
|
self._default_value_options = generate_value_options(
|
|
352
|
-
|
|
398
|
+
self._sertype, value_options
|
|
353
399
|
)
|
|
354
400
|
self._emit_value_set = emit_value_set
|
|
355
401
|
|
|
@@ -371,11 +417,12 @@ class NodeIO(EventEmitterMixin, Generic[NodeIOType]):
|
|
|
371
417
|
"""
|
|
372
418
|
ser = NodeIOSerialization(
|
|
373
419
|
name=self._name,
|
|
374
|
-
type=self.
|
|
420
|
+
type=self._sertype,
|
|
375
421
|
id=self._uuid,
|
|
376
422
|
is_input=self.is_input(),
|
|
377
423
|
render_options=self.render_options,
|
|
378
424
|
value_options=self.value_options,
|
|
425
|
+
value=self.value,
|
|
379
426
|
)
|
|
380
427
|
if self._description is not None:
|
|
381
428
|
ser["description"] = self._description
|
|
@@ -386,13 +433,13 @@ class NodeIO(EventEmitterMixin, Generic[NodeIOType]):
|
|
|
386
433
|
ser["allow_multiple"] = self.allow_multiple
|
|
387
434
|
|
|
388
435
|
if drop:
|
|
389
|
-
if ser["name"] == ser["id"]:
|
|
436
|
+
if "name" in ser and ser["name"] == ser["id"]:
|
|
390
437
|
del ser["name"]
|
|
391
438
|
|
|
392
|
-
if len(ser["render_options"]) == 0:
|
|
439
|
+
if "render_options" in ser and len(ser["render_options"]) == 0:
|
|
393
440
|
del ser["render_options"]
|
|
394
441
|
|
|
395
|
-
if len(ser["value_options"]) == 0:
|
|
442
|
+
if "value_options" in ser and len(ser["value_options"]) == 0:
|
|
396
443
|
del ser["value_options"]
|
|
397
444
|
|
|
398
445
|
return ser
|
|
@@ -573,14 +620,14 @@ class NodeIO(EventEmitterMixin, Generic[NodeIOType]):
|
|
|
573
620
|
def serialize_class(self) -> NodeIOClassSerialization:
|
|
574
621
|
ser = NodeIOClassSerialization(
|
|
575
622
|
name=self.name,
|
|
576
|
-
type=self.
|
|
623
|
+
type=self._sertype,
|
|
577
624
|
description=self._description,
|
|
578
625
|
uuid=self.uuid,
|
|
579
626
|
)
|
|
580
627
|
if self._allow_multiple is not None:
|
|
581
628
|
ser["allow_multiple"] = self._allow_multiple
|
|
582
629
|
|
|
583
|
-
if ser["name"] == ser["uuid"]:
|
|
630
|
+
if "name" in ser and ser["name"] == ser["uuid"]:
|
|
584
631
|
del ser["name"]
|
|
585
632
|
return ser
|
|
586
633
|
|
|
@@ -596,7 +643,7 @@ class NodeIO(EventEmitterMixin, Generic[NodeIOType]):
|
|
|
596
643
|
id=self.uuid,
|
|
597
644
|
full_id=self.full_id,
|
|
598
645
|
name=self.name,
|
|
599
|
-
type=self.
|
|
646
|
+
type=self._sertype,
|
|
600
647
|
is_input=self.is_input(),
|
|
601
648
|
connected=self.is_connected(),
|
|
602
649
|
node=self.node.uuid if self.node else None,
|
|
@@ -633,8 +680,8 @@ class NodeIO(EventEmitterMixin, Generic[NodeIOType]):
|
|
|
633
680
|
@property
|
|
634
681
|
def value_options(self) -> ValueOptions:
|
|
635
682
|
return deep_fill_dict(
|
|
636
|
-
self._default_value_options,
|
|
637
|
-
self._value_options,
|
|
683
|
+
self._default_value_options, # type: ignore
|
|
684
|
+
self._value_options, # type: ignore
|
|
638
685
|
inplace=False,
|
|
639
686
|
overwrite_existing=True,
|
|
640
687
|
)
|
|
@@ -642,13 +689,19 @@ class NodeIO(EventEmitterMixin, Generic[NodeIOType]):
|
|
|
642
689
|
@value_options.setter
|
|
643
690
|
def value_options(self, value_options: ValueOptions):
|
|
644
691
|
self._value_options = deep_remove_dict_on_equal(
|
|
645
|
-
value_options,
|
|
692
|
+
value_options, # type: ignore
|
|
693
|
+
self._default_value_options, # type: ignore
|
|
694
|
+
inplace=False,
|
|
646
695
|
)
|
|
647
696
|
|
|
648
697
|
@emit_after()
|
|
649
|
-
def update_value_options(self, **kwargs):
|
|
698
|
+
def update_value_options(self, **kwargs) -> ValueOptions:
|
|
699
|
+
|
|
650
700
|
deep_fill_dict(
|
|
651
|
-
self._value_options,
|
|
701
|
+
self._value_options, # type: ignore
|
|
702
|
+
kwargs, # type: ignore
|
|
703
|
+
inplace=True,
|
|
704
|
+
overwrite_existing=True,
|
|
652
705
|
)
|
|
653
706
|
|
|
654
707
|
return self.value_options
|
|
@@ -700,7 +753,7 @@ class NodeInput(NodeIO, Generic[NodeIOType]):
|
|
|
700
753
|
self._default = default
|
|
701
754
|
|
|
702
755
|
@property
|
|
703
|
-
def value(self) -> NodeIOType
|
|
756
|
+
def value(self) -> Union[NodeIOType, NoValueType]:
|
|
704
757
|
"""Gets the current value of the NodeIO."""
|
|
705
758
|
return self._value if self._value is not NoValue else self._default
|
|
706
759
|
|
|
@@ -946,7 +999,7 @@ class NodeOutput(NodeIO):
|
|
|
946
999
|
@property
|
|
947
1000
|
def connections(self) -> List[NodeInput]:
|
|
948
1001
|
"""Gets a list of NodeIO instances connected to this one."""
|
|
949
|
-
return list(self._connected)
|
|
1002
|
+
return list(self._connected) # type: ignore connected has to be a list of NodeInput since outputs dont connect
|
|
950
1003
|
|
|
951
1004
|
def set_value(self, value: object, does_trigger: Optional[bool] = None) -> None:
|
|
952
1005
|
"""Sets the internal value of the NodeIO.
|
|
@@ -998,7 +1051,7 @@ class NodeOutput(NodeIO):
|
|
|
998
1051
|
# this can happen e.g. if the outputs connects to two inputs of one node,
|
|
999
1052
|
# resulting in a double trigger, which will likely raise an InTriggerError
|
|
1000
1053
|
connection.trigger(triggerstack=triggerstack)
|
|
1001
|
-
except Exception
|
|
1054
|
+
except Exception:
|
|
1002
1055
|
pass
|
|
1003
1056
|
return triggerstack
|
|
1004
1057
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from .nodeutils import get_deep_connected_nodeset, run_until_complete
|
|
2
2
|
from .serialization import JSONEncoder, JSONDecoder
|
|
3
3
|
from .data import deep_fill_dict, deep_remove_dict_on_equal
|
|
4
|
+
from . import plugins
|
|
4
5
|
|
|
5
6
|
__all__ = [
|
|
6
7
|
"get_deep_connected_nodeset",
|
|
@@ -9,4 +10,5 @@ __all__ = [
|
|
|
9
10
|
"JSONDecoder",
|
|
10
11
|
"deep_fill_dict",
|
|
11
12
|
"deep_remove_dict_on_equal",
|
|
13
|
+
"plugins",
|
|
12
14
|
]
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
def get_installed_modules():
|
|
2
|
+
import pkg_resources
|
|
3
|
+
|
|
4
|
+
named_objects = {}
|
|
5
|
+
for ep in pkg_resources.iter_entry_points(group="funcnodes.module"):
|
|
6
|
+
if ep.module_name not in named_objects:
|
|
7
|
+
named_objects[ep.module_name] = {}
|
|
8
|
+
named_objects[ep.module_name][ep.name] = ep.load()
|
|
9
|
+
|
|
10
|
+
return named_objects
|
|
@@ -80,7 +80,7 @@ class JSONEncoder(json.JSONEncoder):
|
|
|
80
80
|
|
|
81
81
|
Args:
|
|
82
82
|
enc (encodertyoe): A function that takes in an object and a boolean indicating whether or not to use a default preview and returns a tuple containing the encoded object and a boolean indicating whether or not the object was encoded.
|
|
83
|
-
|
|
83
|
+
enc_cls (Optional[List[type]]): A list of classes that the encoder should be applied to primarily.
|
|
84
84
|
Examples:
|
|
85
85
|
>>> def complex_encoder(obj, preview=False):
|
|
86
86
|
... if isinstance(obj, complex):
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "funcnodes"
|
|
3
|
-
version = "0.3.
|
|
3
|
+
version = "0.3.3"
|
|
4
4
|
description = "funcnodes"
|
|
5
5
|
authors = ["Julian Kimmig <julian.kimmig@linkdlab.de>"]
|
|
6
6
|
readme = "README.md"
|
|
7
7
|
|
|
8
8
|
[tool.poetry.dependencies]
|
|
9
9
|
python = "^3.11"
|
|
10
|
-
exposedfunctionality = ">=0.3.
|
|
10
|
+
exposedfunctionality = ">=0.3.8"
|
|
11
11
|
websockets = "^12.0"
|
|
12
12
|
virtualenv = "*"
|
|
13
13
|
poetry-plugin-export = "^1.7"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|