gunicorn issue in rendering panel app as webapp on HF spaces

#1
by njain - opened
Mouritech org

not able to resolve gunicorn issue

Hi,

Am trying to pickle a notebook code and unpickle it into a ".py" file before displaying it as web app on the HF spaces. Getting error in the gunicorn as indentation error from the unpickled python file. Not able to resolve it. Any help or doc would be useful.
thanks.

Ntbk:

import panel as pn
import pickle

numbers = [1, 2, 3, 4, 5]

def square_numbers():
squared = [num ** 2 for num in numbers]
return squared

pn.extension()

Create a Panel object for your app

app = pn.Column(
pn.widgets.IntSlider(name="Numbers"),
pn.pane.Markdown(f"The squared numbers are: {square_numbers()}"),
)

Serve the Panel object on Hugging Face

pn.serve(app)

with open("webpanel_ntbk.pkl", "wb") as f:
pickle.dump(app, f)


Unpicked python file docker CAT command output is below:

--> RUN cat webpanel_ntbk.py
Column
[0] IntSlider(name='Numbers')
[1] Markdown(str)
DONE 0.0s

Error is:

[2023-05-23 00:02:02 +0000] [7] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
worker.init_process()
File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 134, in init_process
self.load_wsgi()
File "/usr/local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
return self.load_wsgiapp()
File "/usr/local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python3.9/site-packages/gunicorn/util.py", line 359, in import_app
mod = importlib.import_module(module)
File "/usr/local/lib/python3.9/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1030, in _gcd_import
File "", line 1007, in _find_and_load
File "", line 986, in _find_and_load_unlocked
File "", line 680, in _load_unlocked
File "", line 846, in exec_module
File "", line 983, in get_code
File "", line 913, in source_to_code
File "", line 228, in _call_with_frames_removed
File "/code/webpanel_ntbk.py", line 2
[0] IntSlider(name='Numbers')
IndentationError: unexpected indent

Sign up or log in to comment