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

To get this working...

Open michaelcuneo opened this issue 1 year ago • 7 comments
trafficstars

Change 1: In the file node_modules/sveltekit-modal/esm/src/vite/sveltekit_modal/src/app.py Remove @stub.asgi_app() Replace with @modal.asgi_app() // and of course import modal

Change 2: In the file node_modules/sveltekit-modal/esm/src/vite/sveltekit_modal/src/serve.py Remove run_serve_loop('sveltekit_modal.app', stdout=Logger(sys.stdout), show_progress=True) Replace with serve_stub(stub_ref='sveltekit_modal.app', stub='sveltekit_modal.app', stdout=Logger(sys.stdout), show_progress=True) And import from modal.serving import serve_stub

Change 3: In the file node_modules/sveltekit-modal/esm/src/vite/sveltekit_modal/src/deploy.py Remove stub.deploy(stdout=Logger(sys.stdout), show_progress=True) Replace with runner.deploy_stub(stub, stdout=Logger(sys.stdout), show_progress=True) // and of course import runner from modal

Change 4: Remove 'secret': modal.Secret.from_name("my-openai-secret") from your svelte_modal_config.py and add it to the .run_function(secrets=[]) array. (All secrets are pushed in together into the one secrets array now)

Change 5: Remove all HUGGINGFACE_TOKEN stuff... The pipeline won't use it.

You will now get a successful deployment - However you won't get a successful formed URL it doesn't put the right URL into .env.production, you have to do all that manually, and even then I don't get any URL while running npm run dev

Internal server error: vite-plugin-sveltekit-modal-serve failed to produce a modal_url Plugin: vite-plugin-sveltekit-modal-py-server-endpoint

However, if I npm run build, I do get a URL... but it doesn't actually ever trigger anything, always 404 not found or 200's... but error decoding response?

I'll update when I solve.

michaelcuneo avatar Feb 21 '24 11:02 michaelcuneo

Hey! Thanks for this work. Modal changing their internals so frequently makes it hard to keep up to date.

Happy to accept a PR if you make one!

ConProgramming avatar Feb 21 '24 23:02 ConProgramming

@ConProgramming I'm still trying to solve the bad URL, I think that's a problem with Vite 5.0 though, not the Modal side of this plugin, still reading up on the Vite 5.0 plugin changes. That'll be this evenings job. :)

michaelcuneo avatar Feb 21 '24 23:02 michaelcuneo

I have been having the most unusual issues working on this.

I forked and cloned the entire repo. After modifying the bin.mjs and sveltekit_modal source code in src... I run deno task dnt which makes the npm folder, then in example-app, I rm -r node_modules and pnpm i to install everything again, based on the package.json it pulls the sveltekit-modal from the local ../npm folder.

Most changes that I was making to sveltekit_modal didn't appear to be actually doing much, so I did a quick test and commented out the entire deploy command so that all it would do is a single deploy_log.stdout .. but instead it actually deployed.

So I tested further by writing a new switch case called "testing": and ran it again, this time it broke past all of it and I got the Invalid command ${cmd}. Did you mean "deploy"? ... so I tested further by making sure that every single instance of bin.mjs had identical commented out deployment code, and a testing case... STILL deployed.

At this point I am absolutely baffled, I have absolutely no idea where my computer is pulling the code from. I double checked and made sure that I didn't accidentally install sveltekit-modal globally, it's not global.

DeployedWIthNoCode

michaelcuneo avatar Feb 22 '24 23:02 michaelcuneo

Well that was the most unusual problem I have ever experienced in my life, I troubleshooted that to the ends of the world and back... all of a sudden it worked fine. For about 12 hours, my computer was somehow getting the binary from who knows where. I'm almost there...

michaelcuneo avatar Feb 23 '24 12:02 michaelcuneo

@ConProgramming hey, in this setup, where does the configuration tell modal what endpoint to hit when you make a request? Everything is working except if I hit the /api/summarize endpoint inside svelte it goes to the modal URL without /api/summarize on the end and returns 404... everything else is working fine.

michaelcuneo avatar Feb 26 '24 03:02 michaelcuneo

Hi @ConProgramming @michaelcuneo - is the readme up to date or is there a new method needed to get this up and running?

chanmathew avatar Oct 03 '24 11:10 chanmathew

Hi @ConProgramming @michaelcuneo - is the readme up to date or is there a new method needed to get this up and running?

I tried everything but I couldn't solve it completely, I ended up just running a monorepo and with my modal setup as one package and the SvelteKit app as another package.

michaelcuneo avatar Oct 03 '24 23:10 michaelcuneo