Spaces:
Sleeping
Sleeping
Deploy Myco from CI
Browse files- scripts/deploy_space.py +24 -9
- tests/test_myco_core.py +9 -7
- ui/renderers.py +19 -11
- ui/styles.py +70 -0
scripts/deploy_space.py
CHANGED
|
@@ -4,6 +4,7 @@ This script is intentionally minimal because CI may call it directly. If the
|
|
| 4 |
optional HF_BUILD_SMALL_HACKATHON_TOKEN secret is missing, it exits cleanly.
|
| 5 |
"""
|
| 6 |
|
|
|
|
| 7 |
import os
|
| 8 |
|
| 9 |
TOKEN_ENV_VAR = "HF_BUILD_SMALL_HACKATHON_TOKEN"
|
|
@@ -38,16 +39,10 @@ def get_space_id():
|
|
| 38 |
return os.environ.get("HF_SPACE_ID", DEFAULT_SPACE_ID).strip() or DEFAULT_SPACE_ID
|
| 39 |
|
| 40 |
|
| 41 |
-
def
|
| 42 |
-
"""
|
| 43 |
-
token = get_hf_token()
|
| 44 |
-
if not token:
|
| 45 |
-
print(f"{TOKEN_ENV_VAR} is not configured; skipping Hugging Face Space deployment.")
|
| 46 |
-
return
|
| 47 |
-
|
| 48 |
from huggingface_hub import HfApi
|
| 49 |
|
| 50 |
-
repo_id = get_space_id()
|
| 51 |
HfApi().upload_folder(
|
| 52 |
folder_path=".",
|
| 53 |
repo_id=repo_id,
|
|
@@ -56,7 +51,27 @@ def main():
|
|
| 56 |
ignore_patterns=get_ignore_patterns(),
|
| 57 |
commit_message="Deploy Myco from CI",
|
| 58 |
)
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
|
| 62 |
if __name__ == "__main__":
|
|
|
|
| 4 |
optional HF_BUILD_SMALL_HACKATHON_TOKEN secret is missing, it exits cleanly.
|
| 5 |
"""
|
| 6 |
|
| 7 |
+
import json
|
| 8 |
import os
|
| 9 |
|
| 10 |
TOKEN_ENV_VAR = "HF_BUILD_SMALL_HACKATHON_TOKEN"
|
|
|
|
| 39 |
return os.environ.get("HF_SPACE_ID", DEFAULT_SPACE_ID).strip() or DEFAULT_SPACE_ID
|
| 40 |
|
| 41 |
|
| 42 |
+
def upload_space(token, repo_id):
|
| 43 |
+
"""Upload the repository folder to the configured Hugging Face Space."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
from huggingface_hub import HfApi
|
| 45 |
|
|
|
|
| 46 |
HfApi().upload_folder(
|
| 47 |
folder_path=".",
|
| 48 |
repo_id=repo_id,
|
|
|
|
| 51 |
ignore_patterns=get_ignore_patterns(),
|
| 52 |
commit_message="Deploy Myco from CI",
|
| 53 |
)
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
def main():
|
| 57 |
+
"""Deploy when a token is configured; otherwise skip without failing."""
|
| 58 |
+
token = get_hf_token()
|
| 59 |
+
if not token:
|
| 60 |
+
print(f"{TOKEN_ENV_VAR} is not configured; skipping Hugging Face Space deployment.")
|
| 61 |
+
return
|
| 62 |
+
|
| 63 |
+
repo_id = get_space_id()
|
| 64 |
+
for attempt in range(2):
|
| 65 |
+
try:
|
| 66 |
+
upload_space(token, repo_id)
|
| 67 |
+
except json.JSONDecodeError as error:
|
| 68 |
+
if attempt == 0:
|
| 69 |
+
print("Hugging Face metadata validation returned non-JSON; retrying once.")
|
| 70 |
+
continue
|
| 71 |
+
print(f"Hugging Face metadata validation returned non-JSON again; skipping CI deploy: {error}")
|
| 72 |
+
return
|
| 73 |
+
print(f"Deployed Myco to https://huggingface.co/spaces/{repo_id}")
|
| 74 |
+
return
|
| 75 |
|
| 76 |
|
| 77 |
if __name__ == "__main__":
|
tests/test_myco_core.py
CHANGED
|
@@ -58,15 +58,17 @@ class MycoCoreTests(unittest.TestCase):
|
|
| 58 |
self.assertIn("clue", current)
|
| 59 |
self.assertIn("secret", current)
|
| 60 |
|
| 61 |
-
def
|
| 62 |
home = home_forest_markdown()
|
| 63 |
|
| 64 |
-
self.assertIn('class="
|
| 65 |
-
self.
|
| 66 |
-
self.
|
| 67 |
-
self.assertIn('class="
|
| 68 |
-
self.assertIn('class="
|
| 69 |
-
self.assertIn('class="
|
|
|
|
|
|
|
| 70 |
self.assertIn("β¨", home)
|
| 71 |
self.assertIn("β¦", home)
|
| 72 |
|
|
|
|
| 58 |
self.assertIn("clue", current)
|
| 59 |
self.assertIn("secret", current)
|
| 60 |
|
| 61 |
+
def test_home_keeps_original_tree_and_mushroom_postcard(self):
|
| 62 |
home = home_forest_markdown()
|
| 63 |
|
| 64 |
+
self.assertIn('class="home-forest-postcard"', home)
|
| 65 |
+
self.assertNotIn('class="forest-map"', home)
|
| 66 |
+
self.assertNotIn('class="scene-stage"', home)
|
| 67 |
+
self.assertIn('class="home-milky-way" title="Milky Way">π</span>', home)
|
| 68 |
+
self.assertIn('class="home-myco" title="Myco">π</span>', home)
|
| 69 |
+
self.assertIn('class="home-brown-mushroom" title="Brown mushroom">πβπ«</span>', home)
|
| 70 |
+
self.assertIn("π²", home)
|
| 71 |
+
self.assertIn("π³", home)
|
| 72 |
self.assertIn("β¨", home)
|
| 73 |
self.assertIn("β¦", home)
|
| 74 |
|
ui/renderers.py
CHANGED
|
@@ -29,17 +29,25 @@ def hero_markdown() -> str:
|
|
| 29 |
|
| 30 |
|
| 31 |
def home_forest_markdown() -> str:
|
| 32 |
-
"""Render the
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
|
| 45 |
def play_hook_markdown() -> str:
|
|
|
|
| 29 |
|
| 30 |
|
| 31 |
def home_forest_markdown() -> str:
|
| 32 |
+
"""Render the original non-game Home forest postcard."""
|
| 33 |
+
return """
|
| 34 |
+
<div class="home-forest-postcard" aria-label="Original Myco forest postcard">
|
| 35 |
+
<div class="home-sky">
|
| 36 |
+
<span class="home-milky-way" title="Milky Way">π</span>
|
| 37 |
+
<span class="home-star star-one">β¨</span>
|
| 38 |
+
<span class="home-star star-two">β¦</span>
|
| 39 |
+
</div>
|
| 40 |
+
<div class="home-forest-floor">
|
| 41 |
+
<span class="home-tree left">π²</span>
|
| 42 |
+
<span class="home-grass grass-left">πΏ</span>
|
| 43 |
+
<span class="home-myco" title="Myco">π</span>
|
| 44 |
+
<span class="home-brown-mushroom" title="Brown mushroom">πβπ«</span>
|
| 45 |
+
<span class="home-grass grass-right">π</span>
|
| 46 |
+
<span class="home-tree right">π³</span>
|
| 47 |
+
</div>
|
| 48 |
+
<p>Myco waits under the Milky Way beside a brown mushroom. Open Play when you are ready to explore.</p>
|
| 49 |
+
</div>
|
| 50 |
+
"""
|
| 51 |
|
| 52 |
|
| 53 |
def play_hook_markdown() -> str:
|
ui/styles.py
CHANGED
|
@@ -145,6 +145,76 @@ APP_CSS = """
|
|
| 145 |
color: #31533f;
|
| 146 |
}
|
| 147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
.play-hook {
|
| 149 |
margin-bottom: 1rem;
|
| 150 |
padding: 1.1rem 1.25rem;
|
|
|
|
| 145 |
color: #31533f;
|
| 146 |
}
|
| 147 |
|
| 148 |
+
.home-forest-postcard {
|
| 149 |
+
position: relative;
|
| 150 |
+
overflow: hidden;
|
| 151 |
+
margin: 1rem 0;
|
| 152 |
+
padding: 1.25rem;
|
| 153 |
+
border-radius: 28px;
|
| 154 |
+
background:
|
| 155 |
+
radial-gradient(circle at 50% 18%, rgba(190, 205, 255, 0.34), transparent 9rem),
|
| 156 |
+
radial-gradient(circle at 50% 76%, rgba(255, 235, 176, 0.28), transparent 10rem),
|
| 157 |
+
linear-gradient(180deg, #121f4f 0%, #163a46 38%, #245c3c 70%, #523b20 100%);
|
| 158 |
+
border: 1px solid rgba(255, 244, 190, 0.34);
|
| 159 |
+
box-shadow: 0 18px 48px rgba(8, 30, 20, 0.24);
|
| 160 |
+
color: #fff9d7 !important;
|
| 161 |
+
text-align: center;
|
| 162 |
+
}
|
| 163 |
+
.home-forest-postcard span,
|
| 164 |
+
.home-forest-postcard p {
|
| 165 |
+
color: #fff9d7 !important;
|
| 166 |
+
}
|
| 167 |
+
.home-sky {
|
| 168 |
+
position: relative;
|
| 169 |
+
min-height: 4.7rem;
|
| 170 |
+
}
|
| 171 |
+
.home-milky-way {
|
| 172 |
+
display: inline-block;
|
| 173 |
+
font-size: clamp(3rem, 9vw, 5.5rem);
|
| 174 |
+
filter: drop-shadow(0 0 18px rgba(201, 218, 255, 0.46));
|
| 175 |
+
}
|
| 176 |
+
.home-star {
|
| 177 |
+
position: absolute;
|
| 178 |
+
font-size: clamp(1.5rem, 4vw, 2.5rem);
|
| 179 |
+
filter: drop-shadow(0 0 12px rgba(255, 251, 198, 0.75));
|
| 180 |
+
}
|
| 181 |
+
.home-star.star-one {
|
| 182 |
+
left: 18%;
|
| 183 |
+
top: 0.8rem;
|
| 184 |
+
}
|
| 185 |
+
.home-star.star-two {
|
| 186 |
+
right: 19%;
|
| 187 |
+
top: 1.9rem;
|
| 188 |
+
}
|
| 189 |
+
.home-forest-floor {
|
| 190 |
+
display: flex;
|
| 191 |
+
align-items: flex-end;
|
| 192 |
+
justify-content: center;
|
| 193 |
+
gap: clamp(0.3rem, 2vw, 1rem);
|
| 194 |
+
min-height: 7rem;
|
| 195 |
+
}
|
| 196 |
+
.home-tree {
|
| 197 |
+
font-size: clamp(3rem, 8vw, 5.6rem);
|
| 198 |
+
filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.28));
|
| 199 |
+
}
|
| 200 |
+
.home-grass {
|
| 201 |
+
font-size: clamp(1.8rem, 4vw, 3rem);
|
| 202 |
+
margin-bottom: 0.25rem;
|
| 203 |
+
}
|
| 204 |
+
.home-myco,
|
| 205 |
+
.home-brown-mushroom {
|
| 206 |
+
font-size: clamp(3.4rem, 8vw, 6rem);
|
| 207 |
+
filter: drop-shadow(0 14px 22px rgba(255, 225, 140, 0.22));
|
| 208 |
+
}
|
| 209 |
+
.home-myco {
|
| 210 |
+
filter: drop-shadow(0 14px 24px rgba(255, 92, 92, 0.32));
|
| 211 |
+
}
|
| 212 |
+
.home-forest-postcard p {
|
| 213 |
+
max-width: 42rem;
|
| 214 |
+
margin: 0.9rem auto 0;
|
| 215 |
+
font-weight: 800;
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
.play-hook {
|
| 219 |
margin-bottom: 1rem;
|
| 220 |
padding: 1.1rem 1.25rem;
|