LysandreJik commited on
Commit
7deed59
1 Parent(s): ffeea82

Max number of arch adjustments

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -19,8 +19,14 @@ def merge_columns(dataset: Dataset, max_number_of_columns: int):
19
  to_merge = list(sorted_downloads.keys())[max_number_of_columns:]
20
  to_keep = list(sorted_downloads.keys())[:max_number_of_columns]
21
 
 
 
 
 
 
 
22
  dictionary = dataset.to_dict()
23
- dictionary['combined'] = dictionary.pop('no_arch')
24
 
25
  while len(to_merge):
26
  current = dictionary['combined']
@@ -42,12 +48,12 @@ def merge_columns(dataset: Dataset, max_number_of_columns: int):
42
  return dataset
43
 
44
 
45
- def plot(library: str, stacked: bool, number_of_pipelines_to_show: int):
46
  dataset = load_dataset(f"open-source-metrics/{library}-checkpoint-downloads")['train']
47
  n_archs = len(dataset.column_names) - 1 # Remove dates
48
 
49
- if n_archs > number_of_pipelines_to_show:
50
- dataset = merge_columns(dataset, number_of_pipelines_to_show)
51
 
52
  dates = dataset['dates']
53
  axis = dataset.column_names
@@ -58,8 +64,6 @@ def plot(library: str, stacked: bool, number_of_pipelines_to_show: int):
58
  fig.add_trace(
59
  go.Scatter(x=dates, y=dataset[i], mode='lines+markers', name=i, stackgroup='one' if stacked else None)
60
  )
61
-
62
- fig.show()
63
  return fig
64
 
65
 
@@ -67,7 +71,7 @@ with gr.Blocks() as demo:
67
  inputs = [
68
  gr.Dropdown(pipelines),
69
  gr.Checkbox(label='Stacked'),
70
- gr.Slider(minimum=1, maximum=len(pipelines), value=3, step=1, label="Max number of pipelines to show")
71
  ]
72
  submit = gr.Button('Submit')
73
  with gr.Row():
 
19
  to_merge = list(sorted_downloads.keys())[max_number_of_columns:]
20
  to_keep = list(sorted_downloads.keys())[:max_number_of_columns]
21
 
22
+ if 'no_arch' in to_merge:
23
+ to_merge.remove('no_arch')
24
+
25
+ if 'no_arch' in to_keep:
26
+ to_keep.remove('no_arch')
27
+
28
  dictionary = dataset.to_dict()
29
+ dictionary['combined'] = dictionary['no_arch']
30
 
31
  while len(to_merge):
32
  current = dictionary['combined']
 
48
  return dataset
49
 
50
 
51
+ def plot(library: str, stacked: bool, number_of_architectures_to_show: int):
52
  dataset = load_dataset(f"open-source-metrics/{library}-checkpoint-downloads")['train']
53
  n_archs = len(dataset.column_names) - 1 # Remove dates
54
 
55
+ if n_archs > number_of_architectures_to_show:
56
+ dataset = merge_columns(dataset, number_of_architectures_to_show)
57
 
58
  dates = dataset['dates']
59
  axis = dataset.column_names
 
64
  fig.add_trace(
65
  go.Scatter(x=dates, y=dataset[i], mode='lines+markers', name=i, stackgroup='one' if stacked else None)
66
  )
 
 
67
  return fig
68
 
69
 
 
71
  inputs = [
72
  gr.Dropdown(pipelines),
73
  gr.Checkbox(label='Stacked'),
74
+ gr.Slider(minimum=1, maximum=len(pipelines), value=3, step=1, label="Max number of architectures to show")
75
  ]
76
  submit = gr.Button('Submit')
77
  with gr.Row():