Skip to content
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

KeyError: 'max_similairty' when using import-from-url/booru commands #58

Open
FrameEnder opened this issue Oct 22, 2024 · 3 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@FrameEnder
Copy link

FrameEnder commented Oct 22, 2024

I've a fresh install of Szurubooru in my Docker, as well as using the pip version of Szurubooru-Toolkit it's on 1.02. wanted to test out importing images via the URL/Booru commands, but have ran into this error along the way when running the command on Windows here is the command log that resulted in the failure I can provide more if a more detailed logging solution is suggested

C:\Users\Vega>szuru-toolkit import-from-url "https://danbooru.donmai.us/posts/8304527?q=megumin"
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Scripts\szuru-toolkit.exe\__main__.py", line 7, in <module>
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\szurubooru_toolkit\scripts\szuru_toolkit.py", line 499, in click_import_from_url
    module = setup_module('import_from_url', ctx)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\szurubooru_toolkit\scripts\szuru_toolkit.py", line 35, in setup_module
    config.override_config(click_context.obj)
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\szurubooru_toolkit\config.py", line 190, in override_config
    self.update_upload_media_config(section)
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\szurubooru_toolkit\config.py", line 363, in update_upload_media_config
    self.upload_media[option] = config_src_obj[option]
                                ~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'max_similarity'

I have tried reinstalling the pip package, restarting, reloading, or rebooting everything in the chain from windows to the server, and even providing the options associated in the KeyError, only to cascade the issue into all options being associated to the key error, I do suspect an issue might stim with Gallery-DL I did not see documentation on if that needs to be installed separately of the Szuru, nor where it would need to be installed too, or what version is preferred if it isn't already built in, but that's just a hypothesis, cause ATM I'm kinda clueless to the root cause.

@reluce reluce self-assigned this Oct 22, 2024
@reluce reluce added the bug Something isn't working label Oct 22, 2024
@reluce
Copy link
Owner

reluce commented Oct 22, 2024

I fixed a push in the linked branch. Any chance you can test it out there before I create a patch release?

The error occurs when options for the file upload (upload-media) are being left out in the CLI arguments or in the config.toml for import-from-booru or import-from-url. I'm just ignoring KeyErrors in case they're not specified, so the default values for upload-media are assumed.

@FrameEnder
Copy link
Author

I fixed a push in the linked branch. Any chance you can test it out there before I create a patch release?

The error occurs when options for the file upload (upload-media) are being left out in the CLI arguments or in the config.toml for import-from-booru or import-from-url. I'm just ignoring KeyErrors in case they're not specified, so the default values for upload-media are assumed.

Thank-you for your quick response. I gave the branch a look, it's now seeming to give a NoneType error relating to the path when I send the command

here's the console log to hopefully clarify it a bit more

C:\Users\Vega>szuru-toolkit --url http://192.168.1.8:8080 --username vega --api-token b32a52ac-2cb7-4518-b3e6-08eb661a1fad import-from-url "https://danbooru.donmai.us/posts/8304527?q=megumin"
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Scripts\szuru-toolkit.exe\__main__.py", line 7, in <module>
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\szurubooru_toolkit\scripts\szuru_toolkit.py", line 487, in click_import_from_url
    module = setup_module('import_from_url', ctx)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\szurubooru_toolkit\scripts\szuru_toolkit.py", line 41, in setup_module
    config.validate_path()
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\szurubooru_toolkit\config.py", line 197, in validate_path
    src_path = Path(self.upload_media['src_path'])
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\pathlib.py", line 871, in __new__
    self = cls._from_parts(args)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\pathlib.py", line 509, in _from_parts
    drv, root, parts = self._parse_args(args)
                       ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\pathlib.py", line 493, in _parse_args
    a = os.fspath(a)
        ^^^^^^^^^^^^
TypeError: expected str, bytes or os.PathLike object, not NoneType

If I try to set the src_path, and tmp_path path's in the config manually it results in seemingly the same error as before

C:\Users\Vega>szuru-toolkit --url http://192.168.1.8:8080 --username vega --api-token b32a52ac-2cb7-4518-b3e6-08eb661a1fad import-from-url "https://danbooru.donmai.us/posts/8304527?q=megumin"
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Scripts\szuru-toolkit.exe\__main__.py", line 7, in <module>
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\szurubooru_toolkit\scripts\szuru_toolkit.py", line 487, in click_import_from_url
    module = setup_module('import_from_url', ctx)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\szurubooru_toolkit\scripts\szuru_toolkit.py", line 35, in setup_module
    config.override_config(click_context.obj)
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\szurubooru_toolkit\config.py", line 190, in override_config
    self.update_upload_media_config(section)
  File "C:\Users\Vega\AppData\Local\Programs\Python\Python311\Lib\site-packages\szurubooru_toolkit\config.py", line 363, in update_upload_media_config
    self.upload_media[option] = config_src_obj[option]
                                ~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'max_similarity'

@reluce
Copy link
Owner

reluce commented Oct 26, 2024

I just set the default src_path to the current directory, so the first error should be solved (the tmp_path is being created automatically if not set).

Regarding the KeyError: Did you build the package after checking out the branch? You can also try it with poetry run so you don't have to build and install the package:
poetry run szuru-toolkit --url...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants