Spaces:
Sleeping
Sleeping
inoki-giskard
commited on
Commit
•
d57b1dd
1
Parent(s):
b6a7e2b
Allow to run cicd locally
Browse files- app.py +43 -2
- output/.gitkeep +0 -0
app.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
import datasets
|
3 |
import huggingface_hub
|
|
|
|
|
4 |
|
5 |
|
6 |
theme = gr.themes.Soft(
|
@@ -45,7 +47,7 @@ def check_dataset(dataset_id, dataset_config="default", dataset_split="test"):
|
|
45 |
return dataset_id, dataset_config, dataset_split
|
46 |
|
47 |
|
48 |
-
def try_submit(model_id, dataset_id, dataset_config, dataset_split):
|
49 |
# Validate model
|
50 |
m_id, ppl = check_model(model_id=model_id)
|
51 |
if m_id is None:
|
@@ -75,6 +77,43 @@ def try_submit(model_id, dataset_id, dataset_config, dataset_split):
|
|
75 |
|
76 |
# TODO: Validate column mapping by running once
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
return config, split
|
79 |
|
80 |
with gr.Blocks(theme=theme) as iface:
|
@@ -94,6 +133,7 @@ with gr.Blocks(theme=theme) as iface:
|
|
94 |
],
|
95 |
value=0,
|
96 |
)
|
|
|
97 |
|
98 |
with gr.Column():
|
99 |
dataset_id_input = gr.Textbox(
|
@@ -127,7 +167,8 @@ with gr.Blocks(theme=theme) as iface:
|
|
127 |
model_id_input,
|
128 |
dataset_id_input,
|
129 |
dataset_config_input,
|
130 |
-
dataset_split_input
|
|
|
131 |
],
|
132 |
outputs=[
|
133 |
dataset_config_input,
|
|
|
1 |
import gradio as gr
|
2 |
import datasets
|
3 |
import huggingface_hub
|
4 |
+
import sys
|
5 |
+
from pathlib import Path
|
6 |
|
7 |
|
8 |
theme = gr.themes.Soft(
|
|
|
47 |
return dataset_id, dataset_config, dataset_split
|
48 |
|
49 |
|
50 |
+
def try_submit(model_id, dataset_id, dataset_config, dataset_split, local):
|
51 |
# Validate model
|
52 |
m_id, ppl = check_model(model_id=model_id)
|
53 |
if m_id is None:
|
|
|
77 |
|
78 |
# TODO: Validate column mapping by running once
|
79 |
|
80 |
+
del ppl
|
81 |
+
|
82 |
+
if local:
|
83 |
+
if "cicd" not in sys.path:
|
84 |
+
sys.path.append("cicd")
|
85 |
+
from giskard_cicd.loaders import HuggingFaceLoader
|
86 |
+
from giskard_cicd.pipeline.runner import PipelineRunner
|
87 |
+
|
88 |
+
from cicd.automation import create_discussion
|
89 |
+
supported_loaders = {
|
90 |
+
"huggingface": HuggingFaceLoader(),
|
91 |
+
}
|
92 |
+
|
93 |
+
runner = PipelineRunner(loaders=supported_loaders)
|
94 |
+
|
95 |
+
runner_kwargs = {
|
96 |
+
"loader_id": "huggingface",
|
97 |
+
"model": m_id,
|
98 |
+
"dataset": d_id,
|
99 |
+
"scan_config": None,
|
100 |
+
"dataset_split": split,
|
101 |
+
"dataset_config": config,
|
102 |
+
}
|
103 |
+
|
104 |
+
report = runner.run(**runner_kwargs)
|
105 |
+
|
106 |
+
# TODO: Publish it
|
107 |
+
# rendered_report = report.to_markdown(template="github")
|
108 |
+
|
109 |
+
# Cache locally
|
110 |
+
rendered_report = report.to_html()
|
111 |
+
output_dir = Path(f"output/{m_id}/{d_id}/{config}/{split}/")
|
112 |
+
output_dir.mkdir(parents=True, exist_ok=True)
|
113 |
+
with open(output_dir / "report.html", "w") as f:
|
114 |
+
print(f'Writing to {output_dir / "report.html"}')
|
115 |
+
f.write(rendered_report)
|
116 |
+
|
117 |
return config, split
|
118 |
|
119 |
with gr.Blocks(theme=theme) as iface:
|
|
|
133 |
],
|
134 |
value=0,
|
135 |
)
|
136 |
+
run_local = gr.Checkbox(value=True, label="Run in this Space")
|
137 |
|
138 |
with gr.Column():
|
139 |
dataset_id_input = gr.Textbox(
|
|
|
167 |
model_id_input,
|
168 |
dataset_id_input,
|
169 |
dataset_config_input,
|
170 |
+
dataset_split_input,
|
171 |
+
run_local,
|
172 |
],
|
173 |
outputs=[
|
174 |
dataset_config_input,
|
output/.gitkeep
ADDED
File without changes
|