-
-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Node Import System #1679
New Node Import System #1679
Conversation
…roof-of-concept-2
👍
Input/output declarations, side effects, etc. are also metadata. They describe the behavior of the node. Literally everything except the One question I would like to raise is whether nodes should be classes. Conceptually, nodes are just function + metadata, so why would we need a class? Using functions for nodes would also simplify the API. Example: @register(
schema_id="chainner:image:load",
group=node_group,
name="Load Image",
description="Load image from specified file.",
icon="BsFillImageFill",
inputs=[
ImageFileInput(primary_input=True),
],
outputs=[
LargeImageOutput(),
DirectoryOutput("Image Directory", of_input=0),
FileNameOutput("Image Name", of_input=0),
],
)
def load_image(path: str) -> Tuple[np.ndarray, str, str]:
... Of course, internally in the registry, we still need (data)classes to hold the function + metadata pair. |
I actually completely agree with that. Especially since I've been getting a warning not to use decorators with classes 😆 This would basically make them the equivalent of function components in react 👍 Side thought: i still would absolutely love if there was a way to type validate the "props" of the run function based on the inputs metadata. I doubt that's possible, but i wish it was. |
Python's type system doesn't have powerful-enough generics and literal types. It would be possible in TypeScript, not python. We could do runtime checks, though. The >>> def foo(a: int, b: str) -> float:
... return 0
>>> foo.__annotations__
{'a': <class 'int'>, 'b': <class 'str'>, 'return': <class 'float'>}
>>> def bar(a, b: str):
... pass
>>> bar.__annotations__
{'b': <class 'str'>} |
Theoretically, could it be done through a vscode extension or something? So not through python directly EDIT: Or maybe even as a CI step? |
13e8ccb
to
8d891ae
Compare
I have no idea why the CI is failing. As in, I don't know why the dictionary size is changing during iteration. I don't get that same issue locally EDIT: wrapped it in |
Co-authored-by: Michael Schmidt <mitchi5000.ms@googlemail.com>
Co-authored-by: Michael Schmidt <mitchi5000.ms@googlemail.com>
…' into import-system-proof-of-concept-2
idk how it got so messed up
There are still a couple of minor things that we should consider changing (node function names, name enforcement, implementation details of registry, node order), but none are pressing enough to warrant holding this PR back. We can make follow-up PRs for those. |
This is based on #1430.
Summary of what I've done on top of that:
I'm not 100% sold on this system and will probably go back to how it was before, but basically, now categories and node groups have their variables defined in the__init__.py
files and are generically named so they can be moved around freely to re-categorize them without needing code changes. This means in order to reorder node groups or categories, you need to name the folders in the alphabetical order you want to use them in. Since that's kinda weird, I'll probably go back to the other system where categories and node groups are defined one level up and then imported. in each node. Though, one potential idea to get around that could be just using the__init__.py
file in each node group folder to import the node group and then export it again asnode_group
. That would have the best of both systems.Anyway, this is still heavily WIP as I've only ported over the image category, but I want to gett an opinion before working on it more.
Checklist:
Other things:
To be accomplished in separate PRs after this one: