Spaces:
Running
Running
inoki-giskard
commited on
Commit
·
71788ef
1
Parent(s):
1bf401f
Allow to post report with detailed info
Browse files- app.py +12 -3
- cicd/automation/__init__.py +2 -2
- cicd/automation/post_discussion.py +13 -0
app.py
CHANGED
@@ -2,9 +2,15 @@ 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(
|
9 |
primary_hue="green",
|
10 |
)
|
@@ -85,7 +91,7 @@ def try_submit(model_id, dataset_id, dataset_config, dataset_split, local):
|
|
85 |
from giskard_cicd.loaders import HuggingFaceLoader
|
86 |
from giskard_cicd.pipeline.runner import PipelineRunner
|
87 |
|
88 |
-
from
|
89 |
supported_loaders = {
|
90 |
"huggingface": HuggingFaceLoader(),
|
91 |
}
|
@@ -103,8 +109,11 @@ def try_submit(model_id, dataset_id, dataset_config, dataset_split, local):
|
|
103 |
|
104 |
report = runner.run(**runner_kwargs)
|
105 |
|
106 |
-
# TODO: Publish it
|
107 |
-
|
|
|
|
|
|
|
108 |
|
109 |
# Cache locally
|
110 |
rendered_report = report.to_html()
|
|
|
2 |
import datasets
|
3 |
import huggingface_hub
|
4 |
import sys
|
5 |
+
import os
|
6 |
from pathlib import Path
|
7 |
|
8 |
|
9 |
+
HF_REPO_ID = 'HF_REPO_ID'
|
10 |
+
HF_SPACE_ID = 'SPACE_ID'
|
11 |
+
HF_WRITE_TOKEN = 'HF_WRITE_TOKEN'
|
12 |
+
|
13 |
+
|
14 |
theme = gr.themes.Soft(
|
15 |
primary_hue="green",
|
16 |
)
|
|
|
91 |
from giskard_cicd.loaders import HuggingFaceLoader
|
92 |
from giskard_cicd.pipeline.runner import PipelineRunner
|
93 |
|
94 |
+
from automation import create_discussion_detailed
|
95 |
supported_loaders = {
|
96 |
"huggingface": HuggingFaceLoader(),
|
97 |
}
|
|
|
109 |
|
110 |
report = runner.run(**runner_kwargs)
|
111 |
|
112 |
+
# TODO: Publish it with given repo id/model id
|
113 |
+
if os.environ.get(HF_REPO_ID) or os.environ.get(HF_SPACE_ID) and os.environ.get(HF_WRITE_TOKEN):
|
114 |
+
rendered_report = report.to_markdown(template="github")
|
115 |
+
repo = os.environ.get(HF_REPO_ID) or os.environ.get(HF_SPACE_ID)
|
116 |
+
create_discussion_detailed(repo, m_id, d_id, config, split, os.environ.get(HF_WRITE_TOKEN), rendered_report)
|
117 |
|
118 |
# Cache locally
|
119 |
rendered_report = report.to_html()
|
cicd/automation/__init__.py
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
from .post_discussion import create_discussion
|
2 |
|
3 |
-
__all__ = ["create_discussion"]
|
|
|
1 |
+
from .post_discussion import create_discussion, create_discussion_detailed
|
2 |
|
3 |
+
__all__ = ["create_discussion", "create_discussion_detailed"]
|
cicd/automation/post_discussion.py
CHANGED
@@ -1,5 +1,18 @@
|
|
1 |
import huggingface_hub as hf_hub
|
|
|
2 |
def create_discussion(repo_id, model_name, hf_token, report):
|
3 |
# Create a discussion
|
4 |
discussion = hf_hub.create_discussion(repo_id, title=f"Report for {model_name}", token=hf_token, description=report, repo_type="space")
|
5 |
return discussion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import huggingface_hub as hf_hub
|
2 |
+
|
3 |
def create_discussion(repo_id, model_name, hf_token, report):
|
4 |
# Create a discussion
|
5 |
discussion = hf_hub.create_discussion(repo_id, title=f"Report for {model_name}", token=hf_token, description=report, repo_type="space")
|
6 |
return discussion
|
7 |
+
|
8 |
+
|
9 |
+
def create_discussion_detailed(repo_id, model_name, dataset_id, dataset_config, dataset_split, hf_token, report):
|
10 |
+
# Create a discussion
|
11 |
+
discussion = hf_hub.create_discussion(
|
12 |
+
repo_id,
|
13 |
+
title=f"Report for {model_name} on {dataset_id} ({dataset_config}, {dataset_split} set)",
|
14 |
+
token=hf_token,
|
15 |
+
description=report,
|
16 |
+
repo_type="space"
|
17 |
+
)
|
18 |
+
return discussion
|