giskard-evaluator / app_debug.py
inoki-giskard's picture
fix-uid-bug-and-add-debug-section (#23)
8092547
raw
history blame
1.46 kB
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 = [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)