You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: demo/README.md
+32-2
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,14 @@
1
+
---
2
+
title: Mesop Demo Gallery
3
+
emoji: 👓
4
+
colorFrom: blue
5
+
colorTo: purple
6
+
sdk: docker
7
+
pinned: false
8
+
license: apache-2.0
9
+
app_port: 8080
10
+
---
11
+
1
12
# Mesop demo app
2
13
3
14
This app demonstrates Mesop's various components and features. Create your own Cloud Run app by following: https://google.github.io/mesop/guides/deployment/
@@ -35,7 +46,12 @@ If you add more demos and want to re-generate screenshots, do the following step
35
46
36
47
## Deployment
37
48
38
-
> Note: make sure you [generate screenshots](#generate-screenshots) before deploying!
49
+
**Pre-requisites:**
50
+
51
+
- Make sure you [generate screenshots](#generate-screenshots) before deploying!
52
+
- Ensure a recent version of Mesop has been published to pip, otherwise the demos may not work (because they rely on a new API).
53
+
54
+
### Deploy to Cloud Run
39
55
40
56
This app is deployed to Google Cloud Run.
41
57
@@ -44,3 +60,17 @@ gcloud run deploy mesop --source .
44
60
```
45
61
46
62
See our Mesop deployment [docs](https://google.github.io/mesop/guides/deployment/#deploy-to-google-cloud-run) for more background.
63
+
64
+
### Deploy to Hugging Face Spaces
65
+
66
+
> NOTE: You need to update demo/requirements.txt to point to the latest Mesop version because Hugging Face Spaces may use a cached version of Mesop which is too old.
67
+
68
+
Because Hugging Face Spaces has restrictions on not having binary files (e.g. image files), we cannot push the full Mesop Git repo to Hugging Face Spaces. Instead, we copy just the `demo` directory and turn it into a standalone Git repo which we deploy.
69
+
70
+
```sh
71
+
./demo/deploy_to_hf.sh ../hf_demo
72
+
```
73
+
74
+
You can change `../hf_demo` to any dir path outside of your Mesop repo.
75
+
76
+
> Note: if you get an error in Hugging Face Spaces "No app file", then you can create an "app.py" file in the Spaces UI to manually trigger a build. This seems like a bug with Hugging Face.
echo"Updating allowed iframe parents to include hugging face spaces site..."
35
+
# Find all .py files and update the allowed_iframe_parents list
36
+
find . -name "*.py" -type f |whileread -r file;do
37
+
# Use sed with -i.bak so it woroks on MacOs
38
+
sed -i.bak 's/allowed_iframe_parents=\["https:\/\/google\.github\.io"\]/allowed_iframe_parents=["https:\/\/google.github.io", "https:\/\/huggingface.co"]/'"$file"
39
+
# Remove the backup file created by sed
40
+
rm "${file}.bak"
41
+
done
42
+
echo"Update complete."
43
+
44
+
git init
45
+
46
+
git add .
47
+
48
+
git commit -m "Commit"
49
+
50
+
# The hf remote may already exist if the script has been run
0 commit comments