Spaces:
Build error
Build error
freemt
commited on
Commit
·
a65b4e5
1
Parent(s):
f4cdef5
Fix server_name=0.0.0.0 debug=False when running in hf spaces ('amz2' in platform.node().releases)
Browse files- radiobee/__main__.py +17 -25
radiobee/__main__.py
CHANGED
@@ -16,6 +16,7 @@ from socket import socket, AF_INET, SOCK_STREAM
|
|
16 |
from sklearn.cluster import DBSCAN # noqa
|
17 |
import joblib
|
18 |
from varname import nameof
|
|
|
19 |
from logzero import logger
|
20 |
|
21 |
# import numpy as np
|
@@ -27,8 +28,10 @@ import matplotlib.pyplot as plt # noqa
|
|
27 |
# from tabulate import tabulate
|
28 |
from fastlid import fastlid
|
29 |
|
|
|
30 |
if "." not in sys.path:
|
31 |
sys.path.insert(0, ".")
|
|
|
32 |
import gradio as gr
|
33 |
from radiobee.process_upload import process_upload
|
34 |
from radiobee.files2df import files2df
|
@@ -108,19 +111,22 @@ def error_msg(
|
|
108 |
|
109 |
|
110 |
if __name__ == "__main__":
|
111 |
-
_ = """
|
112 |
-
fn = process_2upoads
|
113 |
-
inputs = ["file", "file"]
|
114 |
-
examples = [
|
115 |
-
["data/test_zh.txt", "data/test_en.txt"],
|
116 |
-
["data/test_en.txt", "data/test_zh.txt"],
|
117 |
-
]
|
118 |
-
outputs = ["dataframe"]
|
119 |
-
# """
|
120 |
-
import logzero
|
121 |
-
|
122 |
debug = True
|
123 |
# debug = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
if debug:
|
125 |
logzero.loglevel(10)
|
126 |
logger.debug(" debug ")
|
@@ -607,20 +613,6 @@ if __name__ == "__main__":
|
|
607 |
css=f"{css_image} {css_input_file} {css_output_file}",
|
608 |
)
|
609 |
|
610 |
-
uname = platform.uname()
|
611 |
-
# node = uname.node
|
612 |
-
|
613 |
-
# match = re.search(r'[a-z\d]{10,}', gethostname())
|
614 |
-
# hf spaces release: '4.14.248-189.473.amzn2.x86_64'
|
615 |
-
# match = re.search(r'[a-z\d]{10,}', node)
|
616 |
-
# if match and node.system.lower() in ["linux"]:
|
617 |
-
if "amzn2" in uname.release:
|
618 |
-
# likely hf spaces
|
619 |
-
server_name = "0.0.0.0"
|
620 |
-
debug = False
|
621 |
-
else:
|
622 |
-
server_name = "127.0.0.1"
|
623 |
-
|
624 |
iface.launch(
|
625 |
share=False,
|
626 |
# share=True,
|
|
|
16 |
from sklearn.cluster import DBSCAN # noqa
|
17 |
import joblib
|
18 |
from varname import nameof
|
19 |
+
import logzero
|
20 |
from logzero import logger
|
21 |
|
22 |
# import numpy as np
|
|
|
28 |
# from tabulate import tabulate
|
29 |
from fastlid import fastlid
|
30 |
|
31 |
+
# for embeddable python
|
32 |
if "." not in sys.path:
|
33 |
sys.path.insert(0, ".")
|
34 |
+
|
35 |
import gradio as gr
|
36 |
from radiobee.process_upload import process_upload
|
37 |
from radiobee.files2df import files2df
|
|
|
111 |
|
112 |
|
113 |
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
debug = True
|
115 |
# debug = False
|
116 |
+
|
117 |
+
uname = platform.uname()
|
118 |
+
|
119 |
+
# match = re.search(r'[a-z\d]{10,}', gethostname())
|
120 |
+
# hf spaces release: '4.14.248-189.473.amzn2.x86_64'
|
121 |
+
# match = re.search(r'[a-z\d]{10,}', node)
|
122 |
+
# if match and node.system.lower() in ["linux"]:
|
123 |
+
if "amzn2" in uname.release:
|
124 |
+
# likely hf spaces
|
125 |
+
server_name = "0.0.0.0"
|
126 |
+
debug = False
|
127 |
+
else:
|
128 |
+
server_name = "127.0.0.1"
|
129 |
+
|
130 |
if debug:
|
131 |
logzero.loglevel(10)
|
132 |
logger.debug(" debug ")
|
|
|
613 |
css=f"{css_image} {css_input_file} {css_output_file}",
|
614 |
)
|
615 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
616 |
iface.launch(
|
617 |
share=False,
|
618 |
# share=True,
|