AnswerDotAI / fasthtml-example

Example fasthtml applications demonstrating a range of web programming techniques
Apache License 2.0
640 stars 98 forks source link

Deploy to HuggingFace Template #1

Closed freddyaboulton closed 4 months ago

freddyaboulton commented 4 months ago

Add some instructions and scripts to deploy the todos app to huggingface spaces.

Persistent storage is a paid feature on hugging face, this template will automatically backup the sqlite files a to a huggingface dataset.

freddyaboulton commented 4 months ago

@jph00 removed sqlite-utils from the requirements file. About the Dockerfile - we could deploy this app using the gradio space template and that would remove the need for the Dockerfile. I thought that'd be confusing though since fasthtml is not gradio. I think down the line it would be nice if there was a built-in fasthtml template for spaces and that would require using the Dockerfile.

I'll leave it up to you - happy to implement whichever one :)

jph00 commented 4 months ago

Can you explain the dockerfile thing a bit more Freddy? Does it currently work without the dockerfile? If so, what makes you think it might be confusing?

A builtin template sounds very interesting. What might that do/contain? Would it make your example simpler/easier?

Message ID: @.***>

freddyaboulton commented 4 months ago

The Dockerfile is only needed for deploying to spaces. Locally, you can run the main.py and it will work as normal.

All Hugging Face spaces are built from Dockerfiles. It's just that for Gradio/Streamlit spaces, the Dockerfile is abstracted away from the end user. We can remove the Dockerfile from this PR, but then we'd have to deploy FastHTML apps as Gradio applications (reference here). Nothing wrong with that but it felt a bit weird since FastHTML is its own framework.

By built-in template, I meant one of the pre-configured framework options available from the space creation screen. Like JupyterLab and Argilla:

image

The Dockerfile would still need to exist in this PR in that case. It would just make getting started with FastHTML on Spaces faster.

jph00 commented 4 months ago

Makes perfect sense - thanks! I agree choosing 'gradio' would be confusing.

Having an SDK option for FastHTML would be super. Anything we can do to make that happen? Should we aim for that for day-1 release? (I'm guessing that'll be ~2 weeks away.)