-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
AttributeError: type object 'Constructor' has no attribute 'add_to_loader_class' #133
Comments
Looks like yaml.add_constructor("!include", yaml_include.Constructor(base_dir=ASSET_DIR), GridYamlLoader) |
(Asking ChatGPT for help, does not help. I love AI and all but, like, it's an LLM with no understanding of context and just says things) Does the new commit fix it? |
No, it actually made things worse and broke loading the old library as well. Applying this seems to work: diff --git a/gridgencore.py b/gridgencore.py
index 76d093d..a1f9416 100644
--- a/gridgencore.py
+++ b/gridgencore.py
@@ -5,15 +5,10 @@ from copy import copy
from PIL import Image
from git import Repo
-class GridYamlLoader(yaml.SafeLoader):
- pass
-
try:
from yamlinclude import YamlIncludeConstructor
- YamlIncludeConstructor.add_to_loader_class(loader_class=GridYamlLoader, base_dir=ASSET_DIR)
-except:
+except ImportError:
from yaml_include import Constructor as YamlIncludeConstructor
- yaml.add_constructor("!include", Constructor(base_dir=ASSET_DIR), GridYamlLoader)
######################### Core Variables #########################
@@ -256,6 +251,10 @@ def validate_single_param(p: str, v):
######################### YAML Parsing and Processing #########################
+class GridYamlLoader(yaml.SafeLoader):
+ pass
+yaml.add_constructor("!include", YamlIncludeConstructor(base_dir=ASSET_DIR), GridYamlLoader)
+
class AxisValue:
def __init__(self, axis, grid, key: str, val):
self.axis = axis |
ohp, that's what I get for not doing a test launch -- fixed on old lib. New lib still don't know if it works or not naturally. |
I thought it would explain my issue better than I could, that's all. Sorry, I didn't mean any offense.
No, unfortunately. Still same error. I updated both WebUI and Forge. Thank you for trying, and thank you for getting back to me so promptly. I do appreciate it. 👍 |
still no?! Argh. What's the new error? |
It seems to load fine for me with either version of |
I cannot get this script to work on Forge or A1111. This is the error:
I'm not a programmer. This is what ChatGPT said to me:
===
The error occurs when the system tries to load the
infinity_grid.py
script, which in turn importsgridgencore.py
. The actual error is thrown ingridgencore.py
where it tries to useadd_to_loader_class
onYamlIncludeConstructor
.Given the code and the traceback, here are some thoughts:
Import Error Handling: The script
infinity_grid.py
importsgridgencore
which seems to rely onYamlIncludeConstructor
. If the fallback import is used (from yaml_include import Constructor as YamlIncludeConstructor
), it indicates that the direct import ofYamlIncludeConstructor
failed. This could mean that theyamlinclude
library isn't installed properly or the wrong library is being imported due to a name mismatch.Attribute Error: The error
AttributeError: type object 'Constructor' has no attribute 'add_to_loader_class'
suggests that the importedConstructor
class (aliased asYamlIncludeConstructor
) doesn't have the methodadd_to_loader_class
. This might indicate a version mismatch or incorrect library usage.Dynamic Module Loading: The function
load_module
dynamically loads a module from the given path. This dynamic loading happens inscript_loading.py
, which successfully loads the module but fails when executing its contents due to the attribute error mentioned.Path and Module Resolution: The
load_module
function usesimportlib.util.spec_from_file_location
to create a module spec from the given file location, then loads the module based on this spec. The module loads, but the issue arises when executing its content, specifically the part involvingYamlIncludeConstructor
.The text was updated successfully, but these errors were encountered: