Skip to content

Commit 5326b7f

Browse files
Roni-Friedmanelronbandel
authored andcommitted
ruff + fold global scores
1 parent fa511ad commit 5326b7f

File tree

3 files changed

+45
-31
lines changed

3 files changed

+45
-31
lines changed

src/unitxt/ui/load_catalog_data.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def is_valid_data(data):
5050
return True
5151

5252
cards_data = {}
53-
json_data = dict()
53+
json_data = {}
5454
catalog_dirs = get_catalog_dirs()
5555
for dir in catalog_dirs:
5656
cards, card_jsons = get_catalog_items_from_dir("cards", dir)
@@ -96,7 +96,7 @@ def get_file_from_item_name(item_name, dir):
9696

9797
def get_catalog_items_from_dir(items_type, dir):
9898
items = []
99-
jsons = dict()
99+
jsons = {}
100100
items_dir = os.path.join(dir, items_type)
101101
files = get_all_files_in_dir(items_dir, recursive=True)
102102
for file in files:
@@ -113,7 +113,7 @@ def get_catalog_items_from_dir(items_type, dir):
113113

114114
def get_catalog_items(items_type):
115115
items = []
116-
jsons = dict()
116+
jsons = {}
117117
for dir in get_catalog_dirs():
118118
dir_items, dir_jsons = get_catalog_items_from_dir(items_type, dir)
119119
items.extend(dir_items)

src/unitxt/ui/run.py

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,20 @@
33
import gradio as gr
44

55
from unitxt.ui import constants as cons
6-
from unitxt.ui.ui_tiny_utils import *
6+
from unitxt.ui.ui_tiny_utils import (
7+
activate_button,
8+
deactivate_button,
9+
go_to_intro_tab,
10+
go_to_json_tab,
11+
go_to_main_tab,
12+
make_group_invisible,
13+
make_group_visible,
14+
make_json_visible,
15+
make_mrk_down_invisible,
16+
make_mrk_down_visible,
17+
make_txt_visible,
18+
select_checkbox,
19+
)
720
from unitxt.ui.ui_utils import (
821
build_command,
922
create_dataframe,
@@ -137,8 +150,7 @@ def display_json_button(element):
137150
make_json_visible(json_el),
138151
)
139152

140-
else:
141-
return tabs, f"Error: {element}'s json not found", None, None
153+
return tabs, f"Error: {element}'s json not found", None, None
142154

143155

144156
######################
@@ -230,38 +242,40 @@ def display_json_button(element):
230242
"Previous Sample", interactive=False
231243
)
232244
next_sample = gr.Button("Next Sample", interactive=False)
233-
with gr.Accordion():
234-
with gr.Group() as prompt_group:
235-
prompts_title = gr.Markdown("## Prompt:")
236-
selected_prompt = gr.Textbox(
237-
lines=5,
238-
show_copy_button=True,
239-
label="Prompt",
240-
autoscroll=False,
241-
)
245+
with gr.Group() as prompt_group:
246+
prompts_title = gr.Markdown(" ## Prompt:")
247+
selected_prompt = gr.Textbox(
248+
lines=5,
249+
show_copy_button=True,
250+
label="Prompt",
251+
autoscroll=False,
252+
)
242253

243-
target = gr.Textbox(lines=1, label="Target", scale=3)
254+
target = gr.Textbox(lines=1, label="Target", scale=3)
244255

245256
with gr.Group(visible=False) as infer_group:
246-
infer_title = gr.Markdown("## Inference:")
257+
infer_title = gr.Markdown(" ## Inference:")
258+
247259
prediction = gr.Textbox(
248-
lines=1,
260+
lines=5,
249261
label="Model prediction",
250262
value=" ",
251263
autoscroll=False,
252264
)
253-
with gr.Row():
254-
instance_scores = gr.DataFrame(
255-
label="Instance scores",
256-
value=cons.EMPTY_SCORES_FRAME,
257-
headers=cons.SCORE_FRAME_HEADERS,
258-
height=200,
259-
)
265+
266+
instance_scores = gr.DataFrame(
267+
label="Instance scores",
268+
value=cons.EMPTY_SCORES_FRAME,
269+
headers=cons.SCORE_FRAME_HEADERS,
270+
)
271+
with gr.Accordion(
272+
label=f"Aggregated scores for {cons.PROMPT_SAMPLE_SIZE} predictions",
273+
open=False,
274+
):
260275
global_scores = gr.DataFrame(
261-
label=f"Aggregated scores for {cons.PROMPT_SAMPLE_SIZE} predictions",
262276
value=cons.EMPTY_SCORES_FRAME,
263277
headers=cons.SCORE_FRAME_HEADERS,
264-
height=200,
278+
visible=True,
265279
)
266280
with gr.TabItem("Code", id="code"):
267281
code_intro = gr.Markdown(value=cons.CODE_INTRO_TXT)

src/unitxt/ui/ui_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ def build_command(prompt_data, with_prediction):
144144

145145

146146
def update_choices_per_task(task_choice):
147-
datasets_choices = gr.update(choices=[], value=None)
148-
template_choices = gr.update(choices=[], value=None)
149-
augmentors_choices = gr.update(choices=[], value=None)
147+
datasets_choices = None
148+
template_choices = None
149+
augmentors_choices = None
150150
if isinstance(task_choice, str):
151151
if task_choice in data:
152152
datasets_choices = gr.update(choices=get_datasets(task_choice))
@@ -168,7 +168,7 @@ def get_augmentors(task_choice):
168168

169169
def get_templates(task_choice, dataset_choice):
170170
if not isinstance(dataset_choice, str):
171-
return gr.update(choices=[], value=None)
171+
return None
172172
return gr.update(choices=sorted(data[task_choice][dataset_choice]))
173173

174174

0 commit comments

Comments
 (0)