LAION-AI/dalle2-laion

TypeError: Multiple inheritance with NamedTuple is not supported

Closed this issue · 7 comments

Hello I'm a newby. I am trying to run the code example_inference.py with dream command and I enter a text string to generate the image, but this error comes out:

Traceback (most recent call last):
File "C:\Users\Tullio\Desktop\dalle2\example_inference.py", line 1, in
from dalle2_laion import DalleModelManager, ModelLoadConfig, utils
File "C:\Users\Tullio\Desktop\dalle2\dalle2_laion_init_.py", line 1, in
from dalle2_laion.dalle2_laion import DalleModelManager
File "C:\Users\Tullio\Desktop\dalle2\dalle2_laion\dalle2_laion.py", line 73, in
class ModelInfo(NamedTuple, Generic[ModelType]):
File "C:\Users\Tullio\AppData\Local\Programs\Python\Python39\lib\typing.py", line 1929, in _namedtuple_mro_entries
raise TypeError("Multiple inheritance with NamedTuple is not supported")
TypeError: Multiple inheritance with NamedTuple is not supported

Do you have any suggestions?

If I modify line 73 of the file dalle2_laion.py in
class ModelInfo(Generic[ModelType]):
The code continues and the error disappears.
However this other error comes out:

Traceback (most recent call last):
File "C:\Users\Tullio\Desktop\dalle2\example_inference.py", line 151, in
inference(obj={})
File "C:\Users\Tullio\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1130, in call
return self.main(*args, **kwargs)
File "C:\Users\Tullio\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1055, in main
rv = self.invoke(ctx)
File "C:\Users\Tullio\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\Tullio\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\Tullio\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "C:\Users\Tullio\AppData\Local\Programs\Python\Python39\lib\site-packages\click\decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "C:\Users\Tullio\Desktop\dalle2\example_inference.py", line 43, in dream
dreamer: BasicInference = BasicInference.create(model_config, verbose=verbose)
File "C:\Users\Tullio\Desktop\dalle2\dalle2_laion\scripts\InferenceScript.py", line 29, in create
model_manager = DalleModelManager(config)
File "C:\Users\Tullio\Desktop\dalle2\dalle2_laion\dalle2_laion.py", line 92, in init
self.decoder_info = self.load_decoder(model_load_config.decoder)
File "C:\Users\Tullio\Desktop\dalle2\dalle2_laion\dalle2_laion.py", line 237, in load_decoder
return ModelInfo(decoder, decoder_version, requires_clip, decoder_data_requirements)
TypeError: ModelInfo() takes no arguments

That looks like a version issue. What version of python are you using?

I'm using first 3.10 and next 3.9. The error occurs in both versions.
Do I try the 3.8?

If higher versions of python cause an error I need to fix that. You can fix this for now by taking out the Generic multi-inheritance and then removing the ModelInfo type hint from the other places in the file.

I’m traveling today so I won’t be able to address this immediately.

Ok thanks for the help, i will try your solution

Multi-inheritance for named tuples was removed in 3.9. So actually downgrading to 3.8 would actually have fixed the issue...

Anyways since this feature will not be supported in the future I will remove this usage when I am back on the ground.

PR submitted #19 :)
Unless of course you want to remove it entirely.

Pull request was merged in. This issue should now be fixed.