-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat: nodes denylist #4474
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
feat: nodes denylist #4474
Conversation
Allow denying and explicitly allowing nodes. When a not-allowed node is used, a pydantic `ValidationError` will be raised. - When collecting all invocations, check against the allowlist and denylist first. When pydantic constructs any unions related to nodes, the denied nodes will be omitted - Add `allow_nodes` and `deny_nodes` to `InvokeAIAppConfig`. These are `Union[list[str], None]`, and may be populated with the `type` of invocations. - When `allow_nodes` is `None`, allow all nodes, else if it is `list[str]`, only allow nodes in the list - When `deny_nodes` is `None`, deny no nodes, else if it is `list[str]`, deny nodes in the list - `deny_nodes` overrides `allow_nodes`
This simply hides nodes from the workflow editor. The nodes will still work if an API request is made with them. For example, you could hide `iterate` nodes from the workflow editor, but if the Linear UI makes use of those nodes, they will still function. - Update `AppConfig` with optional property `nodesDenylist: string[]` - If provided, nodes are filtered out by `type` in the workflow editor
|
@ebr it's unfortunately rather tricky to change this because almost all pydantic errors are the same type - ValidationError. There's no easy way to filter out this specific error because invalid discriminator can happen in many cases, and it is an error you'd want to see. Could truncate the error messages when they exceed a limit though. |
|
I've truncated the error messages to 128 characters, and added |
Do not throw when parsing unknown args, instead parse only known args print the unknown ones (supersedes #4216)
We need to parse the config before doing anything related to invocations to ensure that the invocations union picks up on denied nodes. - Move that to the top of api_app and cli_app - Wrap subsequent imports in `if True:`, as a hack to satisfy flake8 and not have to noqa every line or the whole file - Add tests to ensure graph validation fails when using a denied node, and that the invocations union does not have denied nodes (this indirectly provides confidence that the generated OpenAPI schema will not include denied nodes)
|
I think this is ready for merge, with a caveat:
|
lstein
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any problem with the changes to base.py.

What type of PR is this? (check all applicable)
Have you discussed this change with the InvokeAI team?
Description
feat(backend): allow/deny nodes
Allow denying and explicitly allowing nodes. When a not-allowed node is used, a pydantic
ValidationErrorwill be raised.allow_nodesanddeny_nodestoInvokeAIAppConfig. These areUnion[list[str], None], and may be populated with thetypeof invocations.allow_nodesisNone, allow all nodes, else if it islist[str], only allow nodes in the listdeny_nodesisNone, deny no nodes, else if it islist[str], deny nodes in the listdeny_nodesoverridesallow_nodesfeat(ui): add UI-level nodes denylist
This simply hides nodes from the workflow editor. The nodes will still work if an API request is made with them. For example, you could hide
iteratenodes from the workflow editor, but if the Linear UI makes use of those nodes, they will still function.AppConfigwith optional propertynodesDenylist: string[]typein the workflow editorQA Instructions, Screenshots, Recordings
Testing the backend denylist handling
Test the existing behaviour:
Float PrimitivenodeTest allowing/denying nodes:
invokeai.yamlfile, adding a new category forNodeswith keys forallow_nodesanddeny_nodes. Suggest using this example stanza:floatnode, as we haven't denied it yetShowImagein the add nodes search box, because it is deniedAdd node to denylist that is already in-use in a workflow:
invokeai.yaml, addfloattodeny_nodesSlightly different case
floatnode and try to add it again - you shouldn't be able to find it in the listTesting the UI-level denylist handling
invokeai/frontend/web/src/main.tsxiteratenodes, but because this is only a UI-level denylist, the backend will still process everything as you'd expect)