Spaces:
Running
Running
update
Browse files- main.py +14 -12
- tabs/fs_tab.py +3 -8
main.py
CHANGED
|
@@ -46,20 +46,22 @@ class KeepAliveProcess(object):
|
|
| 46 |
|
| 47 |
async def start(self):
|
| 48 |
while True:
|
| 49 |
-
|
| 50 |
-
logger.info(f"[{self.name}; {self.url}] access...")
|
| 51 |
-
client = Client("https://qgyd2021-douyin-and-youtube.hf.space/")
|
| 52 |
-
text = client.predict(
|
| 53 |
-
cmd="cat README.md | grep ^title | cut -c 8-",
|
| 54 |
-
api_name="/shell"
|
| 55 |
-
)
|
| 56 |
-
text = str(text).strip()
|
| 57 |
-
logger.info(f"[{self.name}; {self.url}] access success, text: `{text}`")
|
| 58 |
-
except Exception as error:
|
| 59 |
-
logger.error(f"[{self.name}; {self.url}] access failed, error type: {type(error)}, text: {str(error)}")
|
| 60 |
-
|
| 61 |
await asyncio.sleep(self.interval)
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
class KeepAliveManager(object):
|
| 65 |
def __init__(self,
|
|
|
|
| 46 |
|
| 47 |
async def start(self):
|
| 48 |
while True:
|
| 49 |
+
await self.process()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
await asyncio.sleep(self.interval)
|
| 51 |
|
| 52 |
+
async def process(self):
|
| 53 |
+
try:
|
| 54 |
+
logger.info(f"[{self.name}; {self.url}] access...")
|
| 55 |
+
client = Client("https://qgyd2021-douyin-and-youtube.hf.space/")
|
| 56 |
+
text = client.predict(
|
| 57 |
+
cmd="cat README.md | grep ^title | cut -c 8-",
|
| 58 |
+
api_name="/shell"
|
| 59 |
+
)
|
| 60 |
+
text = str(text).strip()
|
| 61 |
+
logger.info(f"[{self.name}; {self.url}] access success, text: `{text}`")
|
| 62 |
+
except Exception as error:
|
| 63 |
+
logger.error(f"[{self.name}; {self.url}] access failed, error type: {type(error)}, text: {str(error)}")
|
| 64 |
+
|
| 65 |
|
| 66 |
class KeepAliveManager(object):
|
| 67 |
def __init__(self,
|
tabs/fs_tab.py
CHANGED
|
@@ -8,15 +8,12 @@ from project_settings import project_path
|
|
| 8 |
def get_fs_tab():
|
| 9 |
with gr.TabItem("fs"):
|
| 10 |
with gr.Row():
|
| 11 |
-
with gr.Column(scale=
|
| 12 |
fs_filename = gr.Textbox(label="filename", max_lines=10)
|
| 13 |
fs_file = gr.File(label="file")
|
| 14 |
-
|
| 15 |
-
fs_file_dir = gr.Dropdown(choices=["data/dataset", "data/eval_data"],
|
| 16 |
-
value="data/dataset",
|
| 17 |
-
label="file_dir")
|
| 18 |
fs_query = gr.Button("query", variant="primary")
|
| 19 |
-
with gr.Column(scale=
|
| 20 |
fs_filelist_dataset_state = gr.State(value=[])
|
| 21 |
fs_filelist_dataset = gr.Dataset(
|
| 22 |
components=[fs_filename, fs_file],
|
|
@@ -33,8 +30,6 @@ def get_fs_tab():
|
|
| 33 |
continue
|
| 34 |
if filename.name.endswith(".py"):
|
| 35 |
continue
|
| 36 |
-
if filename.name.endswith(".raw"):
|
| 37 |
-
continue
|
| 38 |
dataset_state.append((
|
| 39 |
filename.relative_to(file_dir).as_posix(),
|
| 40 |
filename.as_posix(),
|
|
|
|
| 8 |
def get_fs_tab():
|
| 9 |
with gr.TabItem("fs"):
|
| 10 |
with gr.Row():
|
| 11 |
+
with gr.Column(scale=5):
|
| 12 |
fs_filename = gr.Textbox(label="filename", max_lines=10)
|
| 13 |
fs_file = gr.File(label="file")
|
| 14 |
+
fs_file_dir = gr.Textbox(value="data", label="file_dir")
|
|
|
|
|
|
|
|
|
|
| 15 |
fs_query = gr.Button("query", variant="primary")
|
| 16 |
+
with gr.Column(scale=5):
|
| 17 |
fs_filelist_dataset_state = gr.State(value=[])
|
| 18 |
fs_filelist_dataset = gr.Dataset(
|
| 19 |
components=[fs_filename, fs_file],
|
|
|
|
| 30 |
continue
|
| 31 |
if filename.name.endswith(".py"):
|
| 32 |
continue
|
|
|
|
|
|
|
| 33 |
dataset_state.append((
|
| 34 |
filename.relative_to(file_dir).as_posix(),
|
| 35 |
filename.as_posix(),
|