Spaces:
Runtime error
Runtime error
freemt commited on
Commit ·
d0123e3
1
Parent(s): 8ccf616
Update (dev) time.tzset()
Browse files
app.py
CHANGED
|
@@ -9,6 +9,7 @@ import pandas as pd
|
|
| 9 |
from about_time import about_time
|
| 10 |
from aset2pairs import aset2pairs
|
| 11 |
from cmat2aset import cmat2aset
|
|
|
|
| 12 |
from logzero import logger
|
| 13 |
from seg_text import seg_text
|
| 14 |
|
|
@@ -16,6 +17,14 @@ from radio_mlbee import __version__
|
|
| 16 |
from radio_mlbee.gen_cmat import gen_cmat
|
| 17 |
from radio_mlbee.utils import text1, text2
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
os.environ["TZ"] = "Asia/Shanghai"
|
| 20 |
try:
|
| 21 |
time.tzset() # type: ignore
|
|
@@ -90,16 +99,15 @@ def ml_fn(
|
|
| 90 |
html = df.to_html()
|
| 91 |
|
| 92 |
dl_csv = None
|
| 93 |
-
|
| 94 |
-
|
| 95 |
dl_csv = Path("aligned-blocks.csv")
|
| 96 |
_ = df.to_csv(index=False)
|
| 97 |
dl_csv.write_text(_, encoding="utf8")
|
| 98 |
-
|
| 99 |
-
|
|
|
|
| 100 |
|
| 101 |
-
# return pd.DataFrame([["", "", ""]])
|
| 102 |
-
# return df.to_html()
|
| 103 |
return df, html, dl_csv
|
| 104 |
|
| 105 |
|
|
@@ -112,9 +120,11 @@ mlbee = gr.Interface(
|
|
| 112 |
gr.Checkbox(label="Preview?"),
|
| 113 |
gr.Checkbox(label="Download csv?"),
|
| 114 |
],
|
| 115 |
-
outputs=[
|
| 116 |
-
|
| 117 |
-
|
|
|
|
|
|
|
| 118 |
# outputs="html",
|
| 119 |
title=f"radio-mlbee {__version__}",
|
| 120 |
description="mlbee rest api on dev ",
|
|
|
|
| 9 |
from about_time import about_time
|
| 10 |
from aset2pairs import aset2pairs
|
| 11 |
from cmat2aset import cmat2aset
|
| 12 |
+
from icecream import install as ic_install, ic
|
| 13 |
from logzero import logger
|
| 14 |
from seg_text import seg_text
|
| 15 |
|
|
|
|
| 17 |
from radio_mlbee.gen_cmat import gen_cmat
|
| 18 |
from radio_mlbee.utils import text1, text2
|
| 19 |
|
| 20 |
+
ic_install()
|
| 21 |
+
ic.configureOutput(
|
| 22 |
+
includeContext=True,
|
| 23 |
+
outputFunction=logger.info,
|
| 24 |
+
)
|
| 25 |
+
ic.enable()
|
| 26 |
+
# ic.disenable() # to turn off
|
| 27 |
+
|
| 28 |
os.environ["TZ"] = "Asia/Shanghai"
|
| 29 |
try:
|
| 30 |
time.tzset() # type: ignore
|
|
|
|
| 99 |
html = df.to_html()
|
| 100 |
|
| 101 |
dl_csv = None
|
| 102 |
+
if download_csv:
|
| 103 |
+
try:
|
| 104 |
dl_csv = Path("aligned-blocks.csv")
|
| 105 |
_ = df.to_csv(index=False)
|
| 106 |
dl_csv.write_text(_, encoding="utf8")
|
| 107 |
+
ic("Saving df.to_csv to dl_csv...")
|
| 108 |
+
except Exception as exc:
|
| 109 |
+
logger.exception(exc)
|
| 110 |
|
|
|
|
|
|
|
| 111 |
return df, html, dl_csv
|
| 112 |
|
| 113 |
|
|
|
|
| 120 |
gr.Checkbox(label="Preview?"),
|
| 121 |
gr.Checkbox(label="Download csv?"),
|
| 122 |
],
|
| 123 |
+
outputs=[
|
| 124 |
+
"dataframe",
|
| 125 |
+
"html",
|
| 126 |
+
gr.outputs.File(label="Click to download csv"),
|
| 127 |
+
],
|
| 128 |
# outputs="html",
|
| 129 |
title=f"radio-mlbee {__version__}",
|
| 130 |
description="mlbee rest api on dev ",
|