Simon Strandgaard
commited on
Commit
·
a145e10
1
Parent(s):
459ddcb
Extracted is_huggingface_spaces() function
Browse files
src/plan/app_text2plan.py
CHANGED
|
@@ -20,12 +20,12 @@ from src.plan.plan_file import PlanFile
|
|
| 20 |
from src.plan.speedvsdetail import SpeedVsDetailEnum
|
| 21 |
from src.prompt.prompt_catalog import PromptCatalog
|
| 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 =
|
| 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"
|
|
|
|
| 20 |
from src.plan.speedvsdetail import SpeedVsDetailEnum
|
| 21 |
from src.prompt.prompt_catalog import PromptCatalog
|
| 22 |
from src.utils.get_env_as_string import get_env_as_string
|
| 23 |
+
from src.utils.is_huggingface_spaces import is_huggingface_spaces
|
| 24 |
from src.utils.time_since_last_modification import time_since_last_modification
|
| 25 |
|
| 26 |
# Slightly different behavior when running inside Hugging Face Spaces, where it's not possible to open a file explorer.
|
| 27 |
# And it's multi-user, so we need to keep track of the state for each user.
|
| 28 |
+
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"
|
src/utils/is_huggingface_spaces.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
PROMPT> IS_HUGGINGFACE_SPACES=true python -m src.utils.is_huggingface_spaces
|
| 3 |
+
True
|
| 4 |
+
|
| 5 |
+
PROMPT> python -m src.utils.is_huggingface_spaces
|
| 6 |
+
False
|
| 7 |
+
"""
|
| 8 |
+
import os
|
| 9 |
+
|
| 10 |
+
def is_huggingface_spaces() -> bool:
|
| 11 |
+
return os.getenv("IS_HUGGINGFACE_SPACES", "false").lower() == "true"
|
| 12 |
+
|
| 13 |
+
if __name__ == "__main__":
|
| 14 |
+
print(is_huggingface_spaces())
|