Spaces:
Runtime error
Runtime error
Benjamin Bossan
commited on
Commit
·
b052ddd
1
Parent(s):
76ffd6d
Try to fix type annotation issue
Browse files
app.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
| 1 |
# HF space creator starting from an sklearn model
|
| 2 |
|
|
|
|
|
|
|
| 3 |
import base64
|
| 4 |
import glob
|
| 5 |
import io
|
|
@@ -161,7 +163,7 @@ def _create_model_card():
|
|
| 161 |
continue
|
| 162 |
|
| 163 |
if key.startswith(PLOT_PREFIX):
|
| 164 |
-
key = key[len(PLOT_PREFIX):]
|
| 165 |
model_card.add_plot(**{key: val})
|
| 166 |
else:
|
| 167 |
model_card.add(**{key: val})
|
|
@@ -185,7 +187,7 @@ def _process_card_for_rendering(rendered: str) -> tuple[str, str]:
|
|
| 185 |
# 
|
| 186 |
images = re.findall(
|
| 187 |
r'(!\[(?P<image_title>[^\]]+)\]\((?P<image_path>[^\)"\s]+)\s*([^\)]*)\))',
|
| 188 |
-
markdown
|
| 189 |
)
|
| 190 |
return images
|
| 191 |
|
|
@@ -211,7 +213,9 @@ def _process_card_for_rendering(rendered: str) -> tuple[str, str]:
|
|
| 211 |
image_markdown = image[0]
|
| 212 |
image_alt = image[1]
|
| 213 |
image_path = image[2]
|
| 214 |
-
markdown = markdown.replace(
|
|
|
|
|
|
|
| 215 |
return markdown
|
| 216 |
|
| 217 |
rendered_with_img = markdown_insert_images(rendered)
|
|
@@ -354,13 +358,9 @@ with left_col:
|
|
| 354 |
" plot')",
|
| 355 |
key="key_plot_name",
|
| 356 |
)
|
| 357 |
-
plot_file = st.file_uploader(
|
| 358 |
-
"Upload a figure*", key="key_plot_file"
|
| 359 |
-
)
|
| 360 |
|
| 361 |
-
submit_new_plot = st.form_submit_button(
|
| 362 |
-
"Add plot", on_click=add_custom_plot
|
| 363 |
-
)
|
| 364 |
|
| 365 |
_load_custom_section_cache()
|
| 366 |
for key in custom_sections:
|
|
@@ -369,7 +369,9 @@ with left_col:
|
|
| 369 |
|
| 370 |
if key.startswith(PLOT_PREFIX):
|
| 371 |
st.button(
|
| 372 |
-
f"Remove plot '{key[len(PLOT_PREFIX):]}'",
|
|
|
|
|
|
|
| 373 |
)
|
| 374 |
else:
|
| 375 |
st.button(
|
|
|
|
| 1 |
# HF space creator starting from an sklearn model
|
| 2 |
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
import base64
|
| 6 |
import glob
|
| 7 |
import io
|
|
|
|
| 163 |
continue
|
| 164 |
|
| 165 |
if key.startswith(PLOT_PREFIX):
|
| 166 |
+
key = key[len(PLOT_PREFIX) :] # noqa
|
| 167 |
model_card.add_plot(**{key: val})
|
| 168 |
else:
|
| 169 |
model_card.add(**{key: val})
|
|
|
|
| 187 |
# 
|
| 188 |
images = re.findall(
|
| 189 |
r'(!\[(?P<image_title>[^\]]+)\]\((?P<image_path>[^\)"\s]+)\s*([^\)]*)\))',
|
| 190 |
+
markdown,
|
| 191 |
)
|
| 192 |
return images
|
| 193 |
|
|
|
|
| 213 |
image_markdown = image[0]
|
| 214 |
image_alt = image[1]
|
| 215 |
image_path = image[2]
|
| 216 |
+
markdown = markdown.replace(
|
| 217 |
+
image_markdown, img_to_html(image_path, image_alt)
|
| 218 |
+
)
|
| 219 |
return markdown
|
| 220 |
|
| 221 |
rendered_with_img = markdown_insert_images(rendered)
|
|
|
|
| 358 |
" plot')",
|
| 359 |
key="key_plot_name",
|
| 360 |
)
|
| 361 |
+
plot_file = st.file_uploader("Upload a figure*", key="key_plot_file")
|
|
|
|
|
|
|
| 362 |
|
| 363 |
+
submit_new_plot = st.form_submit_button("Add plot", on_click=add_custom_plot)
|
|
|
|
|
|
|
| 364 |
|
| 365 |
_load_custom_section_cache()
|
| 366 |
for key in custom_sections:
|
|
|
|
| 369 |
|
| 370 |
if key.startswith(PLOT_PREFIX):
|
| 371 |
st.button(
|
| 372 |
+
f"Remove plot '{key[len(PLOT_PREFIX):]}'",
|
| 373 |
+
on_click=_remove_custom_section,
|
| 374 |
+
args=(key,),
|
| 375 |
)
|
| 376 |
else:
|
| 377 |
st.button(
|