Skip to content
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

fix: make dev_reload work for files in nodes/ #7819

Merged
merged 1 commit into from
Mar 24, 2025

Conversation

keturn
Copy link
Contributor

@keturn keturn commented Mar 21, 2025

Summary

The dev_reload option to load Python changes on the fly should work for custom nodes as well as Invoke's own sources.

(Have y'all been trying to write nodes without this? Or do you have another hot-reloading mechanism you've been using instead?)

QA Instructions

  1. have some code in a nodes/ subdirectory.
  2. Run invoke with INVOKEAI_DEV_RELOAD=true environment variable. (Or set dev_reload = True in your `invokeai.yaml'.)
  3. Run invokeai-web
  4. Startup logs should include a [jurigged] Watch line for your nodes source.
  5. When you edit that file, the log should include a [jurigged] Update line for it.

Merge Plan

N/A

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • N/A Tests added / updated (if applicable)
  • N/A Documentation added / updated (if applicable)
  • Updated What's New copy (if doing a release after this PR)

@keturn
Copy link
Contributor Author

keturn commented Mar 21, 2025

Alternatively, we could make load_custom_nodes explicitly communicate with jurigged, but this is easier and almost as effective.

The one gap is if someday in the future we change it so load_custom_nodes is called again later somewhere else.

@keturn keturn force-pushed the fix/nodes-hot-reload branch 2 times, most recently from b1b2c33 to 41950d8 Compare March 21, 2025 17:51
Copy link
Collaborator

@psychedelicious psychedelicious left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks.

I expect this to work only for internal logic changes to the nodes.

For example, the logic within the invoke() method.

I don't think it will work to add/remove nodes or change node input/output signatures.

Calling BaseInvocation.invalidate_typeadapter() after the hot-reload should fix adding/removing nodes and changed node input signatures.

In #7826, invocation registration is updated and a new method to invalidate the output classes is added. So calling InvocationRegistry.invalidate_invocation_typeadapter() and InvocationRegistry.invalidate_output_typeadapter() should fully enable hot-reload for nodes.

@psychedelicious
Copy link
Collaborator

Merging this as-is now to unblock anything you may be done - we can get the full hot reload working in the future.

@psychedelicious psychedelicious enabled auto-merge (rebase) March 24, 2025 22:52
@psychedelicious psychedelicious merged commit 98fd1d9 into invoke-ai:main Mar 24, 2025
15 checks passed
@keturn keturn deleted the fix/nodes-hot-reload branch March 25, 2025 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python PRs that change python files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants