Spaces:
Runtime error
Runtime error
Commit
·
81cc82d
1
Parent(s):
a6d3a7a
Add quickstart example
Browse files- Dockerfile +23 -0
- README.md +1 -0
- app.py +27 -0
- requirements.txt +1 -0
Dockerfile
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.11
|
| 2 |
+
|
| 3 |
+
# Set up a new user named "user" with user ID 1000 for permission
|
| 4 |
+
RUN useradd -m -u 1000 user
|
| 5 |
+
|
| 6 |
+
# Switch to the "user" user
|
| 7 |
+
USER user
|
| 8 |
+
|
| 9 |
+
# Set home to the user's home directory
|
| 10 |
+
ENV HOME=/home/user \
|
| 11 |
+
PATH=/home/user/.local/bin:$PATH
|
| 12 |
+
|
| 13 |
+
# Upgreade pip
|
| 14 |
+
RUN pip install --no-cache-dir --upgrade pip
|
| 15 |
+
|
| 16 |
+
COPY --chown=user requirements.txt .
|
| 17 |
+
|
| 18 |
+
# Install requirements
|
| 19 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 20 |
+
|
| 21 |
+
COPY --chown=user app.py app.py
|
| 22 |
+
|
| 23 |
+
ENTRYPOINT ["solara", "run", "app.py", "--host=0.0.0.0", "--port", "7860"]
|
README.md
CHANGED
|
@@ -6,6 +6,7 @@ colorTo: pink
|
|
| 6 |
sdk: docker
|
| 7 |
pinned: false
|
| 8 |
license: mit
|
|
|
|
| 9 |
---
|
| 10 |
|
| 11 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 6 |
sdk: docker
|
| 7 |
pinned: false
|
| 8 |
license: mit
|
| 9 |
+
app_port: 7860
|
| 10 |
---
|
| 11 |
|
| 12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import solara
|
| 2 |
+
|
| 3 |
+
# Declare reactive variables at the top level. Components using these variables
|
| 4 |
+
# will be re-executed when their values change.
|
| 5 |
+
sentence = solara.reactive("Solara makes our team more productive.")
|
| 6 |
+
word_limit = solara.reactive(10)
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
@solara.component
|
| 10 |
+
def Page():
|
| 11 |
+
# Calculate word_count within the component to ensure re-execution when reactive variables change.
|
| 12 |
+
word_count = len(sentence.value.split())
|
| 13 |
+
|
| 14 |
+
solara.SliderInt("Word limit", value=word_limit, min=2, max=20)
|
| 15 |
+
solara.InputText(label="Your sentence", value=sentence, continuous_update=True)
|
| 16 |
+
|
| 17 |
+
# Display messages based on the current word count and word limit.
|
| 18 |
+
if word_count >= int(word_limit.value):
|
| 19 |
+
solara.Error(f"With {word_count} words, you passed the word limit of {word_limit.value}.")
|
| 20 |
+
elif word_count >= int(0.8 * word_limit.value):
|
| 21 |
+
solara.Warning(f"With {word_count} words, you are close to the word limit of {word_limit.value}.")
|
| 22 |
+
else:
|
| 23 |
+
solara.Success("Great short writing!")
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
# The following line is required only when running the code in a Jupyter notebook:
|
| 27 |
+
Page()
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
solara
|