Interpause/auto-sd-krita

not currently working?

Closed this issue · 4 comments

I set it up using git before, so I started off by opening a git console in the plugin dir, doing 'git pull' to update.
I also switched my auto1111 repo using 'git switch --detach krita/master' which worked once I stashed my webui-user.bat away.
However, on launching krita and trying either txt2img or img2img I get an error, an example of which I have pasted below:

JSONDecodeError
Python 3.8.1: C:\Program Files\Krita (x64)\bin\krita.exe
Sat Oct 29 14:37:21 2022

A problem occurred in a Python script.  Here is the sequence of
function calls leading up to the error, in the order they occurred.

 C:\Users\norgu\AppData\Roaming\krita\pykrita\krita_diff\pages\txt2img.py in <lambda>()
   41         self.highres.cfg_connect()
   42         self.highres.toggled.connect(toggle_highres)
   43         toggle_highres(self.highres.isChecked())
   44 
   45         self.btn.released.connect(lambda: script.action_txt2img())
self undefined
global script = <krita_diff.script.Script object>
script.action_txt2img = <bound method Script.action_txt2img of <krita_diff.script.Script object>>

 C:\Users\norgu\AppData\Roaming\krita\pykrita\krita_diff\script.py in action_txt2img(self=<krita_diff.script.Script object>)
  269             return
  270         self.adjust_selection()
  271         self.apply_txt2img()
  272 
  273     def action_img2img(self):
self = <krita_diff.script.Script object>
self.apply_txt2img = <bound method Script.apply_txt2img of <krita_diff.script.Script object>>

 C:\Users\norgu\AppData\Roaming\krita\pykrita\krita_diff\script.py in apply_txt2img(self=<krita_diff.script.Script object>)
  173             self.status_changed.emit(STATE_TXT2IMG)
  174 
  175         self.client.post_txt2img(
  176             cb, self.width, self.height, self.selection is not None
  177         )
self = <krita_diff.script.Script object>
self.client = <krita_diff.client.Client object>
self.client.post_txt2img = <bound method Client.post_txt2img of <krita_diff.client.Client object>>
cb = <function Script.apply_txt2img.<locals>.cb>
self.width = 512
self.height = 512
self.selection = None

 C:\Users\norgu\AppData\Roaming\krita\pykrita\krita_diff\client.py in post_txt2img(self=<krita_diff.client.Client object>, cb=<function Script.apply_txt2img.<locals>.cb>, width=512, height=512, has_selection=False)
  236             )
  237             ext_name = self.cfg("txt2img_script", str)
  238             ext_args = get_ext_args(self.ext_cfg, "scripts_txt2img", ext_name)
  239             params.update(self.get_common_params(has_selection))
  240             params.update(
ext_args undefined
global get_ext_args = <function get_ext_args>
self = <krita_diff.client.Client object>
self.ext_cfg = <krita_diff.config.Config object>
ext_name = 'None'

 C:\Users\norgu\AppData\Roaming\krita\pykrita\krita_diff\utils.py in get_ext_args(ext_cfg=<krita_diff.config.Config object>, ext_type='scripts_txt2img', ext_name='None')
   27 def get_ext_args(ext_cfg: Config, ext_type: str, ext_name: str):
   28     """Get args for script in positional list form."""
   29     meta = json.loads(ext_cfg(get_ext_key(ext_type, ext_name)))
   30     args = []
   31     for i, o in enumerate(meta):
meta undefined
global json = <module 'json' from 'C:\\Program Files\\Krita (x64)\\python\\python38.zip\\json\\__init__.pyc'>
json.loads = <function loads>
ext_cfg = <krita_diff.config.Config object>
global get_ext_key = <function get_ext_key>
ext_type = 'scripts_txt2img'
ext_name = 'None'

 C:\Program Files\Krita (x64)\json\__init__.py in loads(s='', cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw={})


 C:\Program Files\Krita (x64)\json\decoder.py in decode(self=<json.decoder.JSONDecoder object>, s='', _w=<built-in method match of re.Pattern object>)


 C:\Program Files\Krita (x64)\json\decoder.py in raw_decode(self=<json.decoder.JSONDecoder object>, s='', idx=0)

JSONDecodeError: Expecting value: line 1 column 1 (char 0)
    __cause__ = None
    __class__ = <class 'json.decoder.JSONDecodeError'>
    __context__ = StopIteration(0)
    __delattr__ = <method-wrapper '__delattr__' of JSONDecodeError object>
    __dict__ = {'colno': 1, 'doc': '', 'lineno': 1, 'msg': 'Expecting value', 'pos': 0}
    __dir__ = <built-in method __dir__ of JSONDecodeError object>
    __doc__ = None
    __eq__ = <method-wrapper '__eq__' of JSONDecodeError object>
    __format__ = <built-in method __format__ of JSONDecodeError object>
    __ge__ = <method-wrapper '__ge__' of JSONDecodeError object>
    __getattribute__ = <method-wrapper '__getattribute__' of JSONDecodeError object>
    __gt__ = <method-wrapper '__gt__' of JSONDecodeError object>
    __hash__ = <method-wrapper '__hash__' of JSONDecodeError object>
    __init__ = <bound method JSONDecodeError.__init__ of JSONDe...ror('Expecting value: line 1 column 1 (char 0)')>
    __init_subclass__ = <built-in method __init_subclass__ of type object>
    __le__ = <method-wrapper '__le__' of JSONDecodeError object>
    __lt__ = <method-wrapper '__lt__' of JSONDecodeError object>
    __module__ = 'json.decoder'
    __ne__ = <method-wrapper '__ne__' of JSONDecodeError object>
    __new__ = <built-in method __new__ of type object>
    __reduce__ = <bound method JSONDecodeError.__reduce__ of JSON...ror('Expecting value: line 1 column 1 (char 0)')>
    __reduce_ex__ = <built-in method __reduce_ex__ of JSONDecodeError object>
    __repr__ = <method-wrapper '__repr__' of JSONDecodeError object>
    __setattr__ = <method-wrapper '__setattr__' of JSONDecodeError object>
    __setstate__ = <built-in method __setstate__ of JSONDecodeError object>
    __sizeof__ = <built-in method __sizeof__ of JSONDecodeError object>
    __str__ = <method-wrapper '__str__' of JSONDecodeError object>
    __subclasshook__ = <built-in method __subclasshook__ of type object>
    __suppress_context__ = True
    __traceback__ = <traceback object>
    __weakref__ = None
    args = ('Expecting value: line 1 column 1 (char 0)',)
    colno = 1
    doc = ''
    lineno = 1
    msg = 'Expecting value'
    pos = 0
    with_traceback = <built-in method with_traceback of JSONDecodeError object>

The above is a description of an error in a Python program.  Here is
the original traceback:

Traceback (most recent call last):
  File "C:\Users\norgu\AppData\Roaming\krita\pykrita\krita_diff\pages\txt2img.py", line 45, in <lambda>
    self.btn.released.connect(lambda: script.action_txt2img())
  File "C:\Users\norgu\AppData\Roaming\krita\pykrita\krita_diff\script.py", line 271, in action_txt2img
    self.apply_txt2img()
  File "C:\Users\norgu\AppData\Roaming\krita\pykrita\krita_diff\script.py", line 175, in apply_txt2img
    self.client.post_txt2img(
  File "C:\Users\norgu\AppData\Roaming\krita\pykrita\krita_diff\client.py", line 238, in post_txt2img
    ext_args = get_ext_args(self.ext_cfg, "scripts_txt2img", ext_name)
  File "C:\Users\norgu\AppData\Roaming\krita\pykrita\krita_diff\utils.py", line 29, in get_ext_args
    meta = json.loads(ext_cfg(get_ext_key(ext_type, ext_name)))
  File "json\__init__.py", line 357, in loads
  File "json\decoder.py", line 337, in decode
  File "json\decoder.py", line 355, in raw_decode
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

This seems due to me exposing AUTO's script API. Error occurs in the logic for loading cached metadata for scripts. JSON error indicates the metadata is empty rather than corrupted. Probably means the script dropdown has a value outside of the options available.

Try clicking the "(Experimental) Scripts" and selecting an option (i.e. "None"). When I am finished with my work, I will just have it reset to the default of None if the metadata is invalid.

Actually, in the short term, I am looking at using the extensions API instead.

I right now have a feeling the API maturing would take quite a while longer, and probably will never support some of the features I want unless I start making pull requests I currently don't have time for...

For example, it probably is no one's priority right now to implement calling scripts or changing shared settings in the official API. I would do it myself, but there's no tracking issue to coordinate these changes, and I simply don't have time for the next week or so.

EDIT:
oh i stand corrected, the official API supports changing settings already. Just that it doesn't work for things that require reloading (i.e. models).
Still rewriting to use the official API is going to take quite a lot of time. At that point, it probably is better to wait for someone to create a better plugin using the official API.

AUTOMATIC1111#4005 might be very useful if it gets merged and works correctly.

I am going to update my tracking issue on this:
#24

Just a heads-up. My PR was closed but you can extend the API using AUTOMATIC1111#3982