sveltekit-modal icon indicating copy to clipboard operation
sveltekit-modal copied to clipboard

Error in latest `modal-client` version

Open pheuter opened this issue 2 years ago • 3 comments

Keep getting various different python errors when trying different combinations of modal-client versions with sveltekit-modal, ranging from Cannot find requirements.txt to No module named 'modal._live_reload'. Seems like this lib hasn't been updated since about a month ago, and enough has changed in SvelteKit/Modal that makes it difficult to actually get started using this lib.

Guidance/feedback from anyone currently using this lib would be greatly appreciated 🙏. Also would be good to know if this lib isn't being actively maintained.

pheuter avatar May 22 '23 16:05 pheuter

Hey! I'm still using it. I'm on modal client version 0.48.1862 right now.

They do keep changing the internals, their docs are a bit messy in places too currently. Hopefully their core code should have less churn soon, but in the meantime I suggest using that version till I upgrade this again :)

ConProgramming avatar May 22 '23 18:05 ConProgramming

Regarding the Modal internals: the "programmatic serve" functionality is now provided by modal.serving.serve_stub instead of the removed internal modal._live_reload.run_serve_loop in case someone wants to fix the "bug"

freider avatar Jun 16 '23 06:06 freider

Here is what I had to change in /sveltekit-mod │ │ [email protected][email protected]/node_modules/sveltekit-modal/esm/src/vite/sveltekit_modal/serve.py

import sys

from synchronicity import Interface
from modal.cli.import_refs import import_stub
# from modal._live_reload import run_serve_loop
from modal.serving import serve_stub

from .sveltekit_modal_config import config

from watchfiles import DefaultFilter

DefaultFilter.ignore_dirs = (
    '__pycache__',
    '.git',
    '.hg',
    '.svn',
    '.tox',
    '.venv',
    'site-packages',
    '.idea',
    # 'node_modules',
    '.mypy_cache',
    '.pytest_cache',
    '.hypothesis',
)


class Logger(object):
    def __init__(self, stream):
        self.stream = stream

    def __getattr__(self, attr_name):
        return getattr(self.stream, attr_name)

    def write(self, data):
        if config.get('log'):
            sys.stderr.write(str(data))
            sys.stderr.flush()

        self.stream.write(str(data))
        self.stream.flush()

    def flush(self):
        self.stream.flush()


if __name__ == '__main__':
    # run_serve_loop('sveltekit_modal.app', stdout=Logger(sys.stdout), show_progress=True)
    serve_stub('sveltekit_modal.app', stdout=Logger(sys.stdout), show_progress=True)

deshartman avatar Jul 06 '23 03:07 deshartman