Fix circular imports related to SCHEDULER_NAME_VALUES #6582
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR makes the following changes:
SCHEDULER_NAME_VALUES
toinvokeai/backend/
. Previously, it was located ininvokeai/app/invocations/
. In its old location, it was causing bidirectional imports betweeninvokeai/backend/
andinvokeai/app/invocations/
and thus contributing to circular import issues. This change helps to move towards havinginvokeai/app/invocations/
import frominvokeai/backend/
and not the other way around. (More info on why this is important here: Improve InvokeAI import patterns #6575)Literal[tuple(SCHEDULER_MAP.keys())]
.Related Issues / Discussions
An issue was raised on Discord where custom nodes fail to import due to a circular import error: https://discord.com/channels/1020123559063990373/1049495067846524939/1258727169417543752
This custom node import issue was introduced by #6576 , which began enforcing absolute imports. The change to absolute imports changed the order of imports in some files, which caused the circular import - highlighting yet again the fragility of the current import system.
Note: This change fixes one source of circular imports. I'm sure that others exist. I'm hopeful that this will fix most custom nodes, but there's a risk that it won't.
QA Instructions
I tested this change with the https://github.com/skunkworxdark/XYGrid_nodes custom nodes. On
main
, loading these nodes caused an import error. After this PR, I was able to run this workflow with custom nodes successfully: https://github.com/skunkworxdark/XYGrid_nodes/blob/ac72baf3472f47112fbbcb9ef0eff574a0ee267b/workflows/xygrid_model-cfg_wf.jsonI also verified that the list of Schedulers still populates properly in the UI (both on nodes, and in the Linear UI).
Merge Plan
No special instructions.
Checklist