fermyon / feedback

Centralized repository for Fermyon Cloud feedback and bug reports
3 stars 1 forks source link

Python http example is working locally but giving "Internal Server Error" on cloud deploy #51

Closed farooqhasny closed 4 months ago

farooqhasny commented 4 months ago

Describe the bug A clear and concise description of what the bug is.

Frequency of the bug Please check one:

Set-up information spin 2.4.2 (340378e 2024-04-03) tried on windows and WSL2 Ubuntu To Reproduce Steps to reproduce the behavior:

  1. use https://github.com/fermyon/spin-python-sdk/tree/main/templates/http-py template to create project .
  2. build and deploy on cloud once uploaded open url in browser (chrome)

Expected behavior expect to see "Hello from Python!" but getting Internal Server Error

mikkelhegn commented 4 months ago

Thanks for reporting this @farooqhasny.

Could you try using this template instead? https://github.com/fermyon/spin-python-sdk/tree/v2.0/templates/http-py

spin template upgrade --repo https://github.com/fermyon/spin-python-sdk --branch v2.0 would be the command to use.

We believe there's an incompatibility with version 3.0.0 and 3.1.0 of the Python SDK and cloud, which we need to handle.

farooqhasny commented 4 months ago

Thanks for your response @mikkelhegn I have tried upgrading template without any success .I am attaching the project for your reference .

http-py.zip

mikkelhegn commented 4 months ago

The spin template upgrade command only applies to the template you use for creationg a new application, so it will not make any changes to the ones you've already created.

The main thing is the SDK and componentize-py version you're using. I'm not sure if changing the version in the requirmens.txt file to the below will work, but you can try.

spin-sdk == 2.0.0
componentize-py == 0.11.2
farooqhasny commented 4 months ago

hi @mikkelhegn when i try using spin-sdk == 2.0.0 componentize-py == 0.11.2 Python 3.10.12 and template from https://github.com/fermyon/spin-python-sdk --branch v2.0 build fails

ASF1KMF:~/hello-world$ spin build
Building component hello-world with `componentize-py -w spin-http componentize app -o app.wasm`
Traceback (most recent call last):
  File "/usr/local/bin/componentize-py", line 8, in <module>
    sys.exit(script())
AssertionError: Traceback (most recent call last):
  File "/0/app.py", line 1, in <module>
    from spin_sdk.http import IncomingHandler, Request, Response
  File "/1/spin_sdk/http/__init__.py", line 5, in <module>
    from spin_sdk.http import poll_loop
  File "/1/spin_sdk/http/poll_loop.py", line 17, in <module>
    from spin_sdk.wit.imports.streams import StreamError_Closed, InputStream
ImportError: cannot import name 'StreamError_Closed' from 'spin_sdk.wit.imports.streams' (/1/spin_sdk/wit/imports/streams.py). Did you mean: 'StreamErrorClosed'?

Caused by:
    ImportError: cannot import name 'StreamError_Closed' from 'spin_sdk.wit.imports.streams' (/1/spin_sdk/wit/imports/streams.py)
Error: Build command for component hello-world failed with status Exited(1)
mikkelhegn commented 4 months ago

Do you have a repo or gist you can share?

This is my repro: https://gist.github.com/mikkelhegn/346bbff92ae9bdb2b09fd6c2948b40c5

I'm using Python 3.12.2

farooqhasny commented 4 months ago

i have tried compiling your gist and got this error ESKTOP-ASF1KMF:~/pygist$ spin build Building component python withcomponentize-py -w spin-http componentize app -o app.wasm` Traceback (most recent call last): File "/home/farooq/.local/bin/componentize-py", line 8, in sys.exit(script()) AssertionError: Traceback (most recent call last): File "/0/app.py", line 1, in from spin_sdk.http import IncomingHandler, Request, Response File "/1/spin_sdk/http/init.py", line 5, in from spin_sdk.http import poll_loop File "/1/spin_sdk/http/poll_loop.py", line 17, in from spin_sdk.wit.imports.streams import StreamError_Closed, InputStream ImportError: cannot import name 'StreamError_Closed' from 'spin_sdk.wit.imports.streams' (/1/spin_sdk/wit/imports/streams.py). Did you mean: 'StreamErrorClosed'?

Caused by: ImportError: cannot import name 'StreamError_Closed' from 'spin_sdk.wit.imports.streams' (/1/spin_sdk/wit/imports/streams.py) Error: Build command for component python failed with status Exited(1) `

mikkelhegn commented 4 months ago

Ok - I think we have to call @dicej to help with some debugging here... Joel?

dicej commented 4 months ago

@farooqhasny Based on the error message you posted, it looks like you're still using spin-sdk 3.0.0 rather than spin-sdk 2.0.0 as specified in Mikkel's gist. Did you run pip install -r requirements.txt?

FWIW, I just tried the code in Mikkel's gist, and it worked for me.

farooqhasny commented 4 months ago

Thanks @dicej my apps which were create and deployed 4 days ago, which weren't working before , have start working now. seems like some recent update of spin cloud runtime has fix the issue . Thanks for all your support .