Simon Strandgaard
commited on
Commit
·
0e11928
1
Parent(s):
a250316
IS_HUGGINGFACE_SPACES env for determining if the app runs on huggingface or not
Browse files- app.py +4 -0
- src/plan/app_text2plan.py +9 -0
app.py
CHANGED
@@ -1,3 +1,7 @@
|
|
|
|
|
|
|
|
|
|
1 |
if __name__ == "__main__":
|
2 |
from src.plan.app_text2plan import demo_text2plan
|
3 |
demo_text2plan.launch()
|
|
|
1 |
+
"""
|
2 |
+
During development, to mimic the same behavior as on Hugging Face Spaces.
|
3 |
+
PROMPT> IS_HUGGINGFACE_SPACES=true python app.py
|
4 |
+
"""
|
5 |
if __name__ == "__main__":
|
6 |
from src.plan.app_text2plan import demo_text2plan
|
7 |
demo_text2plan.launch()
|
src/plan/app_text2plan.py
CHANGED
@@ -1,5 +1,9 @@
|
|
1 |
"""
|
|
|
2 |
PROMPT> python -m src.plan.app_text2plan
|
|
|
|
|
|
|
3 |
"""
|
4 |
import gradio as gr
|
5 |
import os
|
@@ -18,6 +22,11 @@ from src.prompt.prompt_catalog import PromptCatalog
|
|
18 |
from src.utils.get_env_as_string import get_env_as_string
|
19 |
from src.utils.time_since_last_modification import time_since_last_modification
|
20 |
|
|
|
|
|
|
|
|
|
|
|
21 |
MODULE_PATH_PIPELINE = "src.plan.run_plan_pipeline"
|
22 |
DEFAULT_PROMPT_UUID = "4dc34d55-0d0d-4e9d-92f4-23765f49dd29"
|
23 |
|
|
|
1 |
"""
|
2 |
+
Start the UI in single user mode.
|
3 |
PROMPT> python -m src.plan.app_text2plan
|
4 |
+
|
5 |
+
Start the UI in multi user mode, as on: Hugging Face Spaces.
|
6 |
+
PROMPT> IS_HUGGINGFACE_SPACES=true python -m src.plan.app_text2plan
|
7 |
"""
|
8 |
import gradio as gr
|
9 |
import os
|
|
|
22 |
from src.utils.get_env_as_string import get_env_as_string
|
23 |
from src.utils.time_since_last_modification import time_since_last_modification
|
24 |
|
25 |
+
# Slightly different behavior when running inside Hugging Face Spaces, where it's not possible to open a file explorer.
|
26 |
+
# And it's multi-user, so we need to keep track of the state for each user.
|
27 |
+
IS_HUGGINGFACE_SPACES = os.getenv("IS_HUGGINGFACE_SPACES", "false").lower() == "true"
|
28 |
+
print(f"IS_HUGGINGFACE_SPACES: {IS_HUGGINGFACE_SPACES}")
|
29 |
+
|
30 |
MODULE_PATH_PIPELINE = "src.plan.run_plan_pipeline"
|
31 |
DEFAULT_PROMPT_UUID = "4dc34d55-0d0d-4e9d-92f4-23765f49dd29"
|
32 |
|