-
Notifications
You must be signed in to change notification settings - Fork 27.4k
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: ensure the indexability of dynamically imported packages #15423
Conversation
Signed-off-by: storyicon <[email protected]>
This looks reasonable but can you please give some examples of how this is useful (or how not doing this is harmful)? |
The reason for performing this operation on the extension is similar to what modules/sd_hijack* do. It allows more advanced developers to non-intrusively modify variables or methods within extensions that they do not control, typically to address adaptation or some tricky issues. Intrusive changes are difficult to maintain when the extension is updated. I understand that this might not matter to most users who run webui in client form, but it becomes highly beneficial when maintaining webui in service form or when there are interactions between extensions under development. |
Any code examples? |
To illustrate with a practical scenario: For instance, the If this change is incorporated, advanced developers will be able to patch variables by accessing the corresponding module through There are many similar scenarios. In ComfyUI, we have applied similar non-invasive patches to numerous custom nodes, which is predicated on https://github.com/comfyanonymous/ComfyUI/blob/master/nodes.py#L1888, but progress has been impeded in the webui context. In fact, I can non-invasively alter the behavior of webui by registering the module with
However, from a standardization perspective, allowing a package to be unindexable after dynamic import does not seem like a good idea. I believe this could be helpful for other developers. |
Will it be with this added that script named sys.py will fuck up the |
This is an interesting question, and answering it requires two premises: [1] Referring to the implementation of importlib.util.spec_from_file_location, when the path is relative, it always searches for the package based on the folder This means that when the user calls [2] The working directory is by default considered one of the Python module search paths. From [1], we know that if we want to break the import of the requests library through Therefore, this is a paradox, and I don't believe that |
This was registering scripts under full path in |
Certainly, that is feasible as well. Thank you kindly for your efforts. |
Does this fix cause no attribute 'text_cond' appear again? |
We should ensure the indexing of dynamically imported packages to prevent them from being completely anonymous, which is crucial for some scenarios that require dynamic patch extension methods or variables.