-
-
Notifications
You must be signed in to change notification settings - Fork 587
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
[Bug]: Web Mode not working 'NoneType' object is not callable #799
Comments
my real problem it was never working code == 0 . because of it the image never loads in web mode and constantly gives a nonetype error. |
I thought this was the part that caused this error, maybe it could be something else, I'm not sure. I was running it in Linux without using stream and it was working. In Windows, it does not work in normal mode or stream mode. I also tried it in the manual section via web mode, not as API, but it did not work. |
@frederik-uni can you help please. i |
@eren-ay for explanation. code == 0 is a context dump, code > 0 are strings like progress & error. the pattern in which it is encoded is 1 byte status code, 4 bytes data chunk size, n bytes data. could you tell me which variable is of type NoneType? |
import asyncio async def stream(messages): def notify(code: int, data: bytes, transform_to_bytes, messages: asyncio.Queue) -> bytes: my commandline is: |
Which one did you say was nonetype? When I looked before, the last value is nonetype. value length is 5 |
the issue isn't with the server.
this is the error handling from the server. the translate function failed to translate was caught and was returned as an error |
for more information modify the encoding manga_translator/mode/share.py:71 to go into more detail to debug the actual issue. |
you could also log method, **attributes in line 62 to verify that this is correct & matches the shape it should have |
this problem with the utf-8. I ran Python with utf-8 the problem used to be: Error: 'charmap' codec can't encode characters in position 25-26: character maps to error |
and you r right it was the line run method exception: line 61 |
everything after 61 and the line l61: async def run_method(self, method, **attributes):
try:
# im pretty sure it reaches here
# print(method, attributes)
if asyncio.iscoroutinefunction(method):
result = await method(**attributes)
else:
result = method(**attributes)
# does it reach here? if not translate failed. checkout what the server logged for method & attributes
result_bytes = pickle.dumps(result)
# if it fails here, than the translate function did not return anything. None is the default return type. if it failed at line result_bytes = pickle.dumps(result) than there is an issue with the translate function where it returns nothing instead of a context
encoded_result = b'\x00' + len(result_bytes).to_bytes(4, 'big') + result_bytes
await self.progress_queue.put(encoded_result)
except Exception as e:
err_bytes = str(e).encode("utf-8")
encoded_result = b'\x02' + len(err_bytes).to_bytes(4, 'big') + err_bytes
await self.progress_queue.put(encoded_result)
finally:
self.lock.release() |
result_bytes = pickle.dumps(result) |
Is this problem only with me? I reinstalled it, I'm running it from the manual section in the url without any changes, I don't understand why it happened. |
the issue is with line 173 actually in the function
This should work, but is not fixing the underlying issue that _translate(config, ctx) should return ctx but is not. |
@eren-ay someone prob made a change. I am not running on the latest version & there might be some special cases where the function does not execute to the end where it is returned, but stops midway and returns nothing. |
oh wait can you print the result before it is dumped? |
yes |
this is probably the issue. |
and this solution not worked if i don't use await it gives error |
wait i'm looking |
could you add a print(result) above |
would help quite a bit what it tries to dump to pinpoint the data that causes the error |
Context(input=<PIL.PngImagePlugin.PngImageFile image mode=P size=533x464 at 0x264CB02E170>, result=<PIL.Image.Image image mode=RGBA size=533x464 at 0x264CB943C40>, img_colorized=<PIL.PngImagePlugin.PngImageFile image mode=P size=533x464 at 0x264CB02E170>, upscaled=<PIL.PngImagePlugin.PngImageFile image mode=P size=533x464 at 0x264CB02E170>, img_rgb=array([[[255, 255, 255],
|
what python version are you using. pickle should be able to handle None types as far as I know. |
3.10.11 |
windows 3.10.11 |
kinda hard to find the issue: does this test script run on your machine?
|
python .\example.py |
wtf is the damn issue. It works on my machine(Python 3.12.3 (v3.12.3:f6650f9ad7, Apr 9 2024, 08:18:47) [Clang 13.0.0 (clang-1300.0.29.30)]). you verified that the issue is
|
(venv) PS C:\Users\eren-\projects\mangaTranslator\new-manga-translator> python .\example.py same issue |
well at least we isolated the issue |
I will download this version and try it |
wait a minute, let me switch to Ubuntu and try again, there was version 3.12.6 if I'm not mistaken. |
I would assume that the attributes that are actually functions are the issue and they changed how they behave in newer versions. __getattr__ = dict.get
__setattr__ = dict.__setitem__
__delattr__ = dict.__delitem__ maybe rewriting the functions will help def __getattr__(self, name):
try:
return self[name]
except KeyError:
raise AttributeError(f"'Context' object has no attribute '{name}'")
def __setattr__(self, name, value):
self[name] = value
def __delattr__(self, name):
try:
del self[name]
except KeyError:
raise AttributeError(f"'Context' object has no attribute '{name}'") |
I looked at Linux, there is version 3.10.6, same error. |
Now I will switch to Windows and update Python |
try the fix above first. that may be faster |
Where are these functions I couldn't find them in the library packages |
the simple test that failed
|
I think it tries to process the lambda functions, but it can't so it fails. making actual functions out of them might fix the issue |
@eren-ay did that fix it? |
None |
would you open a pull request for that? |
sorry for wait |
manga_translator/utils/generic.py is the context location in the project. Such a dumb issue that only affects older python versions |
Okay, I'll fix it now. I bought a new computer. I don't know why. I've encountered some ridiculous problems in Linux. |
sorry i tried now it's giving error encoded result is from the exception: b"\x02\x00\x00\x003'Context' object has no get attribute 'render_mask'" excepstion is: 'Context' object has no get attribute 'render_mask' Additionally, it worked when I made the following change: in the manga_translator.py |
ctx.render_mask = None |
that should make it work
|
@frederik-uni It works fine but I still installed version 3.12.3 |
no clue. id suggest to create a pull request if you haven't already which adds the changes |
I am using the current version, I updated it yesterday. |
the issue was that the functions were defined as arguments. My runtime ignores lambda functions & just treats them like functions, but this does not seem to be the same for you. I have no clue why it is working in my machine ;D |
zyddnys#799 it teems like some runtimes do not like lambda attributes in pickle.dumps
Issue
notify function never returns 0
Command Line Arguments
No response
Console logs
The text was updated successfully, but these errors were encountered: