Spaces:
Running
Running
File size: 1,473 Bytes
6e92592 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
import gradio as gr
import pipe
from os import listdir
from os.path import isfile, join
LOG_PATH = "./tmp"
CONFIG_PATH = "./cicd/configs"
def get_accordions_of_files(path, files):
components = []
for file in files:
with gr.Row():
with gr.Accordion(label=file, open=False):
with gr.Row():
with open(join(path, file), "r") as f:
gr.Markdown(f.read())
return components
def get_accordions_of_log_files():
log_files = [f for f in listdir(LOG_PATH) if isfile(join(LOG_PATH, f)) and f.endswith("_log")]
return get_accordions_of_files(LOG_PATH, log_files)
def get_accordions_of_config_files():
config_files = config_files = [f for f in listdir(CONFIG_PATH) if isfile(join(CONFIG_PATH, f)) and f.endswith(".yaml")]
return get_accordions_of_files(CONFIG_PATH, config_files)
def get_demo(demo):
with gr.Row():
# check if jobs is an attribute of pipe
if hasattr(pipe, "jobs"):
gr.Markdown(f"current jobs in queue: {len(pipe.jobs)}")
with gr.Accordion(label="Config Files", open=False):
config_accordion = get_accordions_of_config_files()
demo.load(get_accordions_of_config_files, outputs=config_accordion, every=1)
with gr.Accordion(label="Log Files", open=False):
log_accordions = get_accordions_of_log_files()
demo.load(get_accordions_of_log_files, outputs=log_accordions, every=1)
|