Michelle Lam commited on
Commit
70ab0be
1 Parent(s): da6aa93

Adds automatically generated usernames. Removes username selection and shared user store. Removes Results and Study Links views. Removes AppOld component.

Browse files
audit_utils.py CHANGED
@@ -1175,7 +1175,7 @@ def plot_overall_vis(preds_df, error_type, cur_user, cur_model, n_topics=None, b
1175
  ignorePeers=True,
1176
  ).encode(
1177
  x=alt.X('vis_pred_bin:Q', title="Our prediction of your rating", scale=alt.Scale(domain=(domain_min, domain_max))),
1178
- y=alt.Y('id:O', title="Comments (ordered by System toxicity rating)", axis=alt.Axis(values=list(range(0, max_items, 5))), sort='descending'),
1179
  color = alt.Color("key:O", scale=alt.Scale(
1180
  domain=["System agrees: Non-toxic", "System agrees: Toxic", "System differs: Error > 1.5", "System differs: Error > 1.0", "System differs: Error > 0.5", "System differs: Error <=0.5"],
1181
  range=["white", "#cbcbcb", "red", "#ff7a5c", "#ffa894", "#ffd1c7"]),
 
1175
  ignorePeers=True,
1176
  ).encode(
1177
  x=alt.X('vis_pred_bin:Q', title="Our prediction of your rating", scale=alt.Scale(domain=(domain_min, domain_max))),
1178
+ y=alt.Y('id:O', title="Topics (ordered by System toxicity rating)", axis=alt.Axis(values=list(range(0, max_items, 5))), sort='descending'),
1179
  color = alt.Color("key:O", scale=alt.Scale(
1180
  domain=["System agrees: Non-toxic", "System agrees: Toxic", "System differs: Error > 1.5", "System differs: Error > 1.0", "System differs: Error > 0.5", "System differs: Error <=0.5"],
1181
  range=["white", "#cbcbcb", "red", "#ff7a5c", "#ffa894", "#ffd1c7"]),
indie_label_svelte/src/App.svelte CHANGED
@@ -4,18 +4,10 @@
4
 
5
  import HypothesisPanel from "./HypothesisPanel.svelte";
6
  import MainPanel from "./MainPanel.svelte";
7
- import SelectUserDialog from "./SelectUserDialog.svelte";
8
  import Explore from "./Explore.svelte";
9
- import Results from "./Results.svelte";
10
- import StudyLinks from "./StudyLinks.svelte";
11
- import { user } from './stores/cur_user_store.js';
12
- import { users } from "./stores/all_users_store.js";
13
 
14
  let personalized_model;
15
  let personalized_models = [];
16
-
17
- // let topic = "";
18
-
19
  let error_type_options = ['Both', 'System is under-sensitive', 'System is over-sensitive', 'Show errors and non-errors'];
20
  let error_type = error_type_options[0];
21
 
@@ -24,27 +16,6 @@
24
  let mode = searchParams.get("mode");
25
  let cur_user = searchParams.get("user");
26
 
27
- // Set cur_user if it's provided in URL params
28
- if (cur_user !== null) {
29
- user.update((value) => cur_user);
30
- }
31
-
32
- // Handle user dialog
33
- let user_dialog_open = false;
34
- user.subscribe(value => {
35
- cur_user = value;
36
- });
37
-
38
- // Handle all users
39
- let all_users = [];
40
- async function getUsers() {
41
- const response = await fetch("./get_users");
42
- const text = await response.text();
43
- const data = JSON.parse(text);
44
- all_users = data["users"];
45
- users.update((value) => all_users);
46
- }
47
-
48
  function getAuditSettings() {
49
  let req_params = {
50
  user: cur_user,
@@ -55,27 +26,12 @@
55
  .then(function (r_orig) {
56
  let r = JSON.parse(r_orig);
57
  personalized_models = r["personalized_models"];
58
- personalized_model = personalized_models[0]; // TEMP
59
- console.log("personalized_model", personalized_model);
60
- // personalized_model = "model_1632886687_iterA";
61
- // let clusters = r["clusters"];
62
- // topic = clusters[0]; // TEMP
63
  });
64
-
65
- // fetch("./audit_settings")
66
- // .then((r) => r.text())
67
- // .then(function (r_orig) {
68
- // let r = JSON.parse(r_orig);
69
- // personalized_models = r["personalized_models"];
70
- // personalized_model = personalized_models[0]; // TEMP
71
- // // personalized_model = "model_1632886687_iterA";
72
- // let clusters = r["clusters"];
73
- // topic = clusters[0]; // TEMP
74
- // });
75
  }
76
  onMount(async () => {
77
  getAuditSettings();
78
- getUsers();
79
  });
80
  </script>
81
 
@@ -88,22 +44,13 @@
88
  <div>
89
  <Explore />
90
  </div>
91
- {:else if mode == "results"}
92
- <div>
93
- <Results />
94
- </div>
95
- {:else if mode == "study_links"}
96
- <div>
97
- <StudyLinks />
98
- </div>
99
  {:else }
100
- <SelectUserDialog bind:open={user_dialog_open} cur_user={cur_user} />
101
  <div>
102
  {#key personalized_model }
103
- <HypothesisPanel model={personalized_model} bind:user_dialog_open={user_dialog_open}/>
104
  {/key}
105
 
106
- <MainPanel bind:model={personalized_model} bind:error_type={error_type} on:change />
107
  </div>
108
  {/if}
109
  </main>
 
4
 
5
  import HypothesisPanel from "./HypothesisPanel.svelte";
6
  import MainPanel from "./MainPanel.svelte";
 
7
  import Explore from "./Explore.svelte";
 
 
 
 
8
 
9
  let personalized_model;
10
  let personalized_models = [];
 
 
 
11
  let error_type_options = ['Both', 'System is under-sensitive', 'System is over-sensitive', 'Show errors and non-errors'];
12
  let error_type = error_type_options[0];
13
 
 
16
  let mode = searchParams.get("mode");
17
  let cur_user = searchParams.get("user");
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  function getAuditSettings() {
20
  let req_params = {
21
  user: cur_user,
 
26
  .then(function (r_orig) {
27
  let r = JSON.parse(r_orig);
28
  personalized_models = r["personalized_models"];
29
+ personalized_model = personalized_models[0];
30
+ cur_user = r["user"];
 
 
 
31
  });
 
 
 
 
 
 
 
 
 
 
 
32
  }
33
  onMount(async () => {
34
  getAuditSettings();
 
35
  });
36
  </script>
37
 
 
44
  <div>
45
  <Explore />
46
  </div>
 
 
 
 
 
 
 
 
47
  {:else }
 
48
  <div>
49
  {#key personalized_model }
50
+ <HypothesisPanel model={personalized_model} cur_user={cur_user}/>
51
  {/key}
52
 
53
+ <MainPanel bind:model={personalized_model} bind:error_type={error_type} cur_user={cur_user} on:change />
54
  </div>
55
  {/if}
56
  </main>
indie_label_svelte/src/AppOld.svelte DELETED
@@ -1,127 +0,0 @@
1
- <svelte:head>
2
- <title>IndieLabel</title>
3
- </svelte:head>
4
-
5
- <script lang="ts">
6
- import { onMount } from "svelte";
7
- import Section from "./Section.svelte";
8
- import IterativeClustering from "./IterativeClustering.svelte";
9
- import OverallResults from "./OverallResults.svelte";
10
- import Labeling from "./Labeling.svelte";
11
- import HypothesisPanel from "./HypothesisPanel.svelte"
12
-
13
- let personalized_model;
14
- let personalized_models = [];
15
- let breakdown_category;
16
- let breakdown_categories = [];
17
- let systems = ["Perspective comment toxicity classifier"]; // Only one system for now
18
- let clusters = [];
19
- let promise = Promise.resolve(null);
20
-
21
- function getAuditSettings() {
22
- fetch("./audit_settings")
23
- .then((r) => r.text())
24
- .then(function (r_orig) {
25
- let r = JSON.parse(r_orig);
26
- breakdown_categories = r["breakdown_categories"];
27
- breakdown_category = breakdown_categories[0];
28
- personalized_models = r["personalized_models"];
29
- personalized_model = personalized_models[0];
30
- clusters = r["clusters"];
31
- });
32
- }
33
- onMount(async () => {
34
- getAuditSettings();
35
- });
36
-
37
- function handleAuditButton() {
38
- promise = getAudit();
39
- }
40
-
41
- async function getAudit() {
42
- let req_params = {
43
- pers_model: personalized_model,
44
- breakdown_axis: breakdown_category,
45
- perf_metric: "avg_diff",
46
- breakdown_sort: "difference",
47
- n_topics: 10,
48
- };
49
- let params = new URLSearchParams(req_params).toString();
50
- const response = await fetch("./get_audit?" + params);
51
- const text = await response.text();
52
- const data = JSON.parse(text);
53
- return data;
54
- }
55
-
56
- </script>
57
-
58
- <main>
59
- <HypothesisPanel model={personalized_model} />
60
-
61
- <Labeling />
62
-
63
- <IterativeClustering clusters={clusters} ind={1} personalized_model={personalized_model} />
64
-
65
- <div id="audit-settings" class="section">
66
- <h5>Audit settings</h5>
67
- <Section
68
- section_id="systems"
69
- section_title="What status-quo system would you like to audit?"
70
- section_opts={systems}
71
- bind:value={systems[0]}
72
- />
73
- <Section
74
- section_id="personalized_model"
75
- section_title="What model would you like to use to represent your views?"
76
- section_opts={personalized_models}
77
- bind:value={personalized_model}
78
- />
79
- <Section
80
- section_id="breakdown_category"
81
- section_title="How would you like to explore the performance of the system?"
82
- section_opts={breakdown_categories}
83
- bind:value={breakdown_category}
84
- />
85
- <button on:click={handleAuditButton}> Generate results </button>
86
- <div>
87
- Personalized model: {personalized_model}, Breakdown category: {breakdown_category}
88
- </div>
89
- </div>
90
-
91
- {#await promise}
92
- <p>...waiting</p>
93
- {:then audit_results}
94
- {#if audit_results}
95
- <OverallResults data={audit_results} clusters={clusters} personalized_model={personalized_model} />
96
- {/if}
97
- {:catch error}
98
- <p style="color: red">{error.message}</p>
99
- {/await}
100
- </main>
101
-
102
- <style>
103
- main {
104
- text-align: left;
105
- padding: 1em;
106
- max-width: 240px;
107
- margin: 0 0;
108
- }
109
- h3 {
110
- color: rgb(80, 80, 80);
111
- font-size: 30px;
112
- }
113
- h5 {
114
- color: rgb(80, 80, 80);
115
- font-size: 25px;
116
- }
117
- h6 {
118
- margin-top: 50px;
119
- text-transform: uppercase;
120
- font-size: 14px;
121
- }
122
- @media (min-width: 640px) {
123
- main {
124
- max-width: none;
125
- }
126
- }
127
- </style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
indie_label_svelte/src/Auditing.svelte CHANGED
@@ -7,7 +7,6 @@
7
  import HelpTooltip from "./HelpTooltip.svelte";
8
  import TopicTraining from "./TopicTraining.svelte";
9
 
10
- import { user } from './stores/cur_user_store.js';
11
  import { error_type } from './stores/error_type_store.js';
12
  import { topic_chosen } from './stores/cur_topic_store.js';
13
  import { model_chosen } from './stores/cur_model_store.js';
@@ -17,15 +16,13 @@
17
  import LayoutGrid, { Cell } from "@smui/layout-grid";
18
  import Radio from '@smui/radio';
19
  import FormField from '@smui/form-field';
20
- import Card, { Content } from '@smui/card';
21
  import{ Wrapper } from '@smui/tooltip';
22
  import IconButton from '@smui/icon-button';
23
- import Select, { Option } from "@smui/select";
24
  import Svelecte from '../node_modules/svelecte/src/Svelecte.svelte';
25
 
26
  export let personalized_model;
27
- // export let topic;
28
  export let cur_error_type = "Both";
 
29
 
30
  let evidence = [];
31
  let show_audit_settings = false;
@@ -99,19 +96,8 @@
99
  use_group_model = true;
100
  }
101
 
102
- // TEMP
103
  let promise_cluster = Promise.resolve(null);
104
 
105
- // Get current user from store
106
- let cur_user;
107
- user.subscribe(value => {
108
- if (value != cur_user) {
109
- cur_user = value;
110
- personalized_model = "";
111
- getAuditSettings();
112
- }
113
- });
114
-
115
  // Get current topic from store
116
  let topic;
117
  topic_chosen.subscribe(value => {
@@ -142,7 +128,6 @@
142
 
143
  async function updateTopicChosen() {
144
  if (topic != null) {
145
- console.log("updateTopicChosen", topic)
146
  topic_chosen.update((value) => topic);
147
  }
148
  }
@@ -170,7 +155,6 @@
170
  model_chosen.update((value) => personalized_model);
171
  clusters = r["clusters"];
172
  clusters_for_tuning = r["clusters_for_tuning"];
173
- console.log("clusters", clusters); // TEMP
174
  topic = clusters[0]["options"][0]["text"];
175
  topic_chosen.update((value) => topic);
176
  handleAuditButton(); // TEMP
@@ -230,7 +214,6 @@
230
  const response = await fetch("./get_cluster_results?" + params);
231
  const text = await response.text();
232
  const data = JSON.parse(text);
233
- console.log(topic);
234
  return data;
235
  }
236
  </script>
@@ -364,7 +347,7 @@
364
  </li>
365
  </ul>
366
  {#key topic}
367
- <TopicTraining topic={topic} />
368
  {/key}
369
  </div>
370
 
 
7
  import HelpTooltip from "./HelpTooltip.svelte";
8
  import TopicTraining from "./TopicTraining.svelte";
9
 
 
10
  import { error_type } from './stores/error_type_store.js';
11
  import { topic_chosen } from './stores/cur_topic_store.js';
12
  import { model_chosen } from './stores/cur_model_store.js';
 
16
  import LayoutGrid, { Cell } from "@smui/layout-grid";
17
  import Radio from '@smui/radio';
18
  import FormField from '@smui/form-field';
 
19
  import{ Wrapper } from '@smui/tooltip';
20
  import IconButton from '@smui/icon-button';
 
21
  import Svelecte from '../node_modules/svelecte/src/Svelecte.svelte';
22
 
23
  export let personalized_model;
 
24
  export let cur_error_type = "Both";
25
+ export let cur_user;
26
 
27
  let evidence = [];
28
  let show_audit_settings = false;
 
96
  use_group_model = true;
97
  }
98
 
 
99
  let promise_cluster = Promise.resolve(null);
100
 
 
 
 
 
 
 
 
 
 
 
101
  // Get current topic from store
102
  let topic;
103
  topic_chosen.subscribe(value => {
 
128
 
129
  async function updateTopicChosen() {
130
  if (topic != null) {
 
131
  topic_chosen.update((value) => topic);
132
  }
133
  }
 
155
  model_chosen.update((value) => personalized_model);
156
  clusters = r["clusters"];
157
  clusters_for_tuning = r["clusters_for_tuning"];
 
158
  topic = clusters[0]["options"][0]["text"];
159
  topic_chosen.update((value) => topic);
160
  handleAuditButton(); // TEMP
 
214
  const response = await fetch("./get_cluster_results?" + params);
215
  const text = await response.text();
216
  const data = JSON.parse(text);
 
217
  return data;
218
  }
219
  </script>
 
347
  </li>
348
  </ul>
349
  {#key topic}
350
+ <TopicTraining topic={topic} cur_user={cur_user}/>
351
  {/key}
352
  </div>
353
 
indie_label_svelte/src/CommentTable.svelte CHANGED
@@ -4,23 +4,16 @@
4
  import Button, { Label } from "@smui/button";
5
  import DataTable, { Head, Body, Row, Cell } from "@smui/data-table";
6
  import LinearProgress from '@smui/linear-progress';
7
- import IconButton from '@smui/icon-button';
8
- import { user } from './stores/cur_user_store.js';
9
 
10
  export let mode;
11
  export let model_name;
 
12
 
13
  let to_label = {};
14
  let promise = Promise.resolve(null);
15
  let n_complete_ratings;
16
  let n_unsure_ratings;
17
 
18
- // Get current user
19
- let cur_user;
20
- user.subscribe(value => {
21
- cur_user = value;
22
- });
23
-
24
  function getCommentsToLabel(cur_mode, n) {
25
  if (cur_mode == "train") {
26
  let req_params = {
 
4
  import Button, { Label } from "@smui/button";
5
  import DataTable, { Head, Body, Row, Cell } from "@smui/data-table";
6
  import LinearProgress from '@smui/linear-progress';
 
 
7
 
8
  export let mode;
9
  export let model_name;
10
+ export let cur_user;
11
 
12
  let to_label = {};
13
  let promise = Promise.resolve(null);
14
  let n_complete_ratings;
15
  let n_unsure_ratings;
16
 
 
 
 
 
 
 
17
  function getCommentsToLabel(cur_mode, n) {
18
  if (cur_mode == "train") {
19
  let req_params = {
indie_label_svelte/src/HypothesisPanel.svelte CHANGED
@@ -1,12 +1,9 @@
1
  <script lang="ts">
2
  import { onMount } from "svelte";
3
  import ClusterResults from "./ClusterResults.svelte";
4
- import HelpTooltip from "./HelpTooltip.svelte";
5
 
6
  import Button, { Label } from "@smui/button";
7
  import Textfield from '@smui/textfield';
8
- import { user } from './stores/cur_user_store.js';
9
- import { error_type } from './stores/error_type_store.js';
10
  import { new_evidence } from './stores/new_evidence_store.js';
11
  import { open_evidence } from './stores/open_evidence_store.js';
12
  import { topic_chosen } from './stores/cur_topic_store.js';
@@ -24,21 +21,12 @@
24
  import Checkbox from '@smui/checkbox';
25
  import FormField from '@smui/form-field';
26
  import IconButton from "@smui/icon-button";
27
- import{ Wrapper } from '@smui/tooltip';
28
  import Radio from '@smui/radio';
29
- import Switch from '@smui/switch';
30
 
31
  export let model;
32
- // export let topic;
33
- export let user_dialog_open;
34
 
35
  let all_reports = [];
36
-
37
- let cur_user;
38
- user.subscribe(value => {
39
- cur_user = value;
40
- });
41
-
42
  let cur_topic;
43
  topic_chosen.subscribe(value => {
44
  cur_topic = value;
@@ -69,8 +57,6 @@
69
  cur_open_evidence = selected["evidence"];
70
  open_evidence.update((value) => cur_open_evidence);
71
  let isolated_topic = selected["title"].replace(/^(Topic: )/,'');
72
- console.log("selected title", selected["title"]);
73
- console.log(selected);
74
 
75
  // Close panel
76
  open = false;
@@ -229,9 +215,8 @@
229
  <div class="panel_header">
230
  <div class="panel_header_content">
231
  <div class="page_header">
232
- <!-- <span class="page_title">IndieLabel</span> -->
233
  <img src="/logo.png" style="height: 50px; padding: 0px 20px;" alt="IndieLabel" />
234
- <Button on:click={() => (user_dialog_open = true)} class="user_button" color="secondary" style="margin: 12px 10px;" >
235
  <Label>User: {cur_user}</Label>
236
  </Button>
237
  </div>
@@ -578,6 +563,13 @@
578
  :global(.mdc-button.user_button) {
579
  float: right;
580
  margin-right: 20px;
 
 
 
 
 
 
 
581
  }
582
 
583
  .page_header {
 
1
  <script lang="ts">
2
  import { onMount } from "svelte";
3
  import ClusterResults from "./ClusterResults.svelte";
 
4
 
5
  import Button, { Label } from "@smui/button";
6
  import Textfield from '@smui/textfield';
 
 
7
  import { new_evidence } from './stores/new_evidence_store.js';
8
  import { open_evidence } from './stores/open_evidence_store.js';
9
  import { topic_chosen } from './stores/cur_topic_store.js';
 
21
  import Checkbox from '@smui/checkbox';
22
  import FormField from '@smui/form-field';
23
  import IconButton from "@smui/icon-button";
 
24
  import Radio from '@smui/radio';
 
25
 
26
  export let model;
27
+ export let cur_user;
 
28
 
29
  let all_reports = [];
 
 
 
 
 
 
30
  let cur_topic;
31
  topic_chosen.subscribe(value => {
32
  cur_topic = value;
 
57
  cur_open_evidence = selected["evidence"];
58
  open_evidence.update((value) => cur_open_evidence);
59
  let isolated_topic = selected["title"].replace(/^(Topic: )/,'');
 
 
60
 
61
  // Close panel
62
  open = false;
 
215
  <div class="panel_header">
216
  <div class="panel_header_content">
217
  <div class="page_header">
 
218
  <img src="/logo.png" style="height: 50px; padding: 0px 20px;" alt="IndieLabel" />
219
+ <Button class="user_button" color="secondary" style="margin: 12px 10px;" >
220
  <Label>User: {cur_user}</Label>
221
  </Button>
222
  </div>
 
563
  :global(.mdc-button.user_button) {
564
  float: right;
565
  margin-right: 20px;
566
+ max-width: 200px;
567
+ }
568
+
569
+ :global(.mdc-button.user_button span) {
570
+ text-overflow: ellipsis;
571
+ white-space: nowrap;
572
+ overflow: hidden;
573
  }
574
 
575
  .page_header {
indie_label_svelte/src/Labeling.svelte CHANGED
@@ -8,7 +8,8 @@
8
  import Button, { Label } from "@smui/button";
9
  import LinearProgress from '@smui/linear-progress';
10
  import Svelecte from '../node_modules/svelecte/src/Svelecte.svelte';
11
- import { user } from './stores/cur_user_store.js';
 
12
 
13
  let model_name = "";
14
  let personalized_models = [];
@@ -17,23 +18,12 @@
17
  "Create a new model",
18
  "Edit an existing model",
19
  "Tune your model for a topic area",
20
- "Set up a group-based model",
21
  ];
22
 
23
  let clusters_for_tuning = [];
24
  let topic;
25
 
26
- // Get current user
27
- let cur_user;
28
- user.subscribe(value => {
29
- if (value != cur_user) {
30
- cur_user = value;
31
- personalized_models = [];
32
- getLabeling();
33
- }
34
- cur_user = value;
35
- });
36
-
37
  // Handle routing
38
  let label_mode = label_modes[0];
39
  let searchParams = new URLSearchParams(window.location.search);
@@ -45,6 +35,7 @@
45
  } else if (req_label_mode == 2) {
46
  label_mode = label_modes[2];
47
  } else if (req_label_mode == 3) {
 
48
  label_mode = label_modes[3];
49
  }
50
 
@@ -172,7 +163,7 @@
172
  </li>
173
  </ul>
174
 
175
- <CommentTable mode={"train"} model_name={model_name}/>
176
  </div>
177
  {:else if label_mode == label_modes[1]}
178
  <!-- EXISTING MODEL -->
@@ -202,7 +193,7 @@
202
  </li>
203
  </ul>
204
  {#key existing_model_name}
205
- <CommentTable mode={"view"} model_name={existing_model_name}/>
206
  {/key}
207
  </div>
208
  {:else if label_mode == label_modes[2]}
@@ -239,7 +230,7 @@
239
  </li>
240
  </ul>
241
  {#key topic}
242
- <TopicTraining topic={topic} model_name={model_name} />
243
  {/key}
244
  </div>
245
 
 
8
  import Button, { Label } from "@smui/button";
9
  import LinearProgress from '@smui/linear-progress';
10
  import Svelecte from '../node_modules/svelecte/src/Svelecte.svelte';
11
+
12
+ export let cur_user;
13
 
14
  let model_name = "";
15
  let personalized_models = [];
 
18
  "Create a new model",
19
  "Edit an existing model",
20
  "Tune your model for a topic area",
21
+ // "Set up a group-based model",
22
  ];
23
 
24
  let clusters_for_tuning = [];
25
  let topic;
26
 
 
 
 
 
 
 
 
 
 
 
 
27
  // Handle routing
28
  let label_mode = label_modes[0];
29
  let searchParams = new URLSearchParams(window.location.search);
 
35
  } else if (req_label_mode == 2) {
36
  label_mode = label_modes[2];
37
  } else if (req_label_mode == 3) {
38
+ // Unused; previous group-based mode
39
  label_mode = label_modes[3];
40
  }
41
 
 
163
  </li>
164
  </ul>
165
 
166
+ <CommentTable mode={"train"} model_name={model_name} cur_user={cur_user}/>
167
  </div>
168
  {:else if label_mode == label_modes[1]}
169
  <!-- EXISTING MODEL -->
 
193
  </li>
194
  </ul>
195
  {#key existing_model_name}
196
+ <CommentTable mode={"view"} model_name={existing_model_name} cur_user={cur_user}/>
197
  {/key}
198
  </div>
199
  {:else if label_mode == label_modes[2]}
 
230
  </li>
231
  </ul>
232
  {#key topic}
233
+ <TopicTraining topic={topic} model_name={model_name} cur_user={cur_user}/>
234
  {/key}
235
  </div>
236
 
indie_label_svelte/src/MainPanel.svelte CHANGED
@@ -1,24 +1,20 @@
1
  <script lang="ts">
2
  import Labeling from "./Labeling.svelte";
3
  import Auditing from "./Auditing.svelte";
4
- import AppOld from "./AppOld.svelte";
5
 
6
  import Tab, { Label } from "@smui/tab";
7
  import TabBar from "@smui/tab-bar";
8
 
9
  export let model;
10
- // export let topic;
11
  export let error_type;
12
-
13
- let app_versions = ["old", "new"];
14
- let app_version = "new";
15
 
16
  // Handle routing
17
- let active = "auditing";
18
  let searchParams = new URLSearchParams(window.location.search);
19
  let tab = searchParams.get("tab");
20
- if (tab == "labeling") {
21
- active = "labeling";
22
  }
23
 
24
  </script>
@@ -37,37 +33,16 @@
37
  </div>
38
 
39
  <div class="panel_contents">
40
- <!-- VERSION SELECTION -->
41
- <!-- <div>
42
- <Section
43
- section_id="app_version"
44
- section_title="What app version do you want to use?"
45
- section_opts={app_versions}
46
- width_pct={40}
47
- bind:value={app_version}
48
- />
49
- </div> -->
50
-
51
- {#if app_version == app_versions[0]}
52
- <!-- OLD VERSION -->
53
- <AppOld />
54
- {:else if app_version == app_versions[1]}
55
- <!-- NEW VERSION -->
56
- <div>
57
- <div id="labeling" hidden={active == "auditing"} >
58
- <Labeling/>
59
- </div>
60
 
61
- <div id="auditing" hidden={active == "labeling"} >
62
- <Auditing bind:personalized_model={model} bind:cur_error_type={error_type} on:change/>
63
- </div>
64
  </div>
65
- {/if}
66
 
67
- <!-- TEMP -->
68
- <!-- {#key model}
69
- <div>Model: {model}</div>
70
- {/key} -->
71
  </div>
72
  </div>
73
 
 
1
  <script lang="ts">
2
  import Labeling from "./Labeling.svelte";
3
  import Auditing from "./Auditing.svelte";
 
4
 
5
  import Tab, { Label } from "@smui/tab";
6
  import TabBar from "@smui/tab-bar";
7
 
8
  export let model;
 
9
  export let error_type;
10
+ export let cur_user;
 
 
11
 
12
  // Handle routing
13
+ let active = "labeling";
14
  let searchParams = new URLSearchParams(window.location.search);
15
  let tab = searchParams.get("tab");
16
+ if (tab == "auditing") {
17
+ active = "auditing";
18
  }
19
 
20
  </script>
 
33
  </div>
34
 
35
  <div class="panel_contents">
36
+ <div>
37
+ <div id="labeling" hidden={active == "auditing"} >
38
+ <Labeling cur_user={cur_user}/>
39
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
+ <div id="auditing" hidden={active == "labeling"} >
42
+ <Auditing bind:personalized_model={model} bind:cur_error_type={error_type} cur_user={cur_user} on:change/>
 
43
  </div>
44
+ </div>
45
 
 
 
 
 
46
  </div>
47
  </div>
48
 
indie_label_svelte/src/OverallResults.svelte CHANGED
@@ -19,18 +19,6 @@
19
  let topic_overview_spec = topic_overview_json;
20
  let topic_overview_view: View;
21
 
22
- // // Overall Histogram
23
- // let overall_hist_json = data["overall_perf"]["overall_hist_json"];
24
- // let overall_hist_data = overall_hist_json["datasets"][overall_hist_json["data"]["name"]];
25
- // let overall_hist_spec = overall_hist_json;
26
- // let overall_hist_view: View;
27
-
28
- // // Class-conditional Histogram
29
- // let class_cond_plot_json = data["overall_perf"]["class_cond_plot_json"];
30
- // let class_cond_plot_data = class_cond_plot_json["datasets"][class_cond_plot_json["data"]["name"]];
31
- // let class_cond_plot_spec = class_cond_plot_json;
32
- // let class_cond_plot_view: View;
33
-
34
  </script>
35
 
36
  <div>
@@ -84,73 +72,6 @@
84
  </div>
85
  </div>
86
 
87
- <!-- Old visualizations -->
88
- <!-- <div style="margin-top: 500px">
89
- <h6>Overall Performance</h6>
90
- <div class="row">
91
- <div class="col s12">
92
- <div id="overall_perf">
93
- <table>
94
- <tbody>
95
- <tr class="custom-blue">
96
- <td class="bold"
97
- >System {data[
98
- "overall_perf"
99
- ]["metric"]} with YOUR labels</td
100
- >
101
- <td>
102
- <span class="bold-large"
103
- >{data[
104
- "overall_perf"
105
- ]["user_metric"]}</span
106
- >
107
- (Percentile: {data[
108
- "overall_perf"
109
- ]["user_percentile"]})
110
- </td>
111
- </tr>
112
- <tr>
113
- <td class="bold"
114
- >System {data[
115
- "overall_perf"
116
- ]["metric"]} with OTHER USERS' labels</td
117
- >
118
- <td>
119
- <span class="bold-large"
120
- >{data[
121
- "overall_perf"
122
- ]["other_metric"]}</span
123
- >
124
- (95% CI: [{data[
125
- "overall_perf"
126
- ]["other_ci_low"]}, {data[
127
- "overall_perf"
128
- ]["other_ci_high"]}])
129
- </td>
130
- </tr>
131
- </tbody>
132
- </table>
133
- </div>
134
- </div>
135
- </div>
136
- <div class="row">
137
- <div class="col s8">
138
- <VegaLite {overall_hist_data} spec={overall_hist_spec} bind:view={overall_hist_view}/>
139
- </div>
140
- </div>
141
-
142
- <h6>Performance Breakdown</h6>
143
- <div class="row">
144
- <div class="col s12">
145
- <div class="row">
146
- <div class="col s12">
147
- <VegaLite {class_cond_plot_data} spec={class_cond_plot_spec} bind:view={class_cond_plot_view} />
148
- </div>
149
- </div>
150
- </div>
151
- </div>
152
- </div> -->
153
-
154
  </div>
155
  <style>
156
  </style>
 
19
  let topic_overview_spec = topic_overview_json;
20
  let topic_overview_view: View;
21
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  </script>
23
 
24
  <div>
 
72
  </div>
73
  </div>
74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  </div>
76
  <style>
77
  </style>
indie_label_svelte/src/Results.svelte DELETED
@@ -1,206 +0,0 @@
1
- <script lang="ts">
2
- import { onMount } from "svelte";
3
- import ClusterResults from "./ClusterResults.svelte";
4
-
5
- import Button, { Label } from "@smui/button";
6
- import LinearProgress from "@smui/linear-progress";
7
- import Checkbox from '@smui/checkbox';
8
- import DataTable, {
9
- Head,
10
- Body,
11
- Row,
12
- Cell,
13
- Label,
14
- SortValue,
15
- } from "@smui/data-table";
16
- import FormField from "@smui/form-field";
17
-
18
- let cur_examples = [];
19
- let promise = Promise.resolve(null);
20
-
21
- let scaffold_methods = ["personal", "personal_group", "prompts"];
22
-
23
- let all_users = [];
24
- async function getUsers() {
25
- const response = await fetch("./get_users");
26
- const text = await response.text();
27
- const data = JSON.parse(text);
28
- all_users = data["users"];
29
- promise = getResults();
30
- }
31
-
32
- onMount(async () => {
33
- getUsers()
34
- });
35
-
36
- async function getResults() {
37
- let req_params = {
38
- users: all_users
39
- };
40
- let params = new URLSearchParams(req_params).toString();
41
- const response = await fetch("./get_results?" + params);
42
- const text = await response.text();
43
- const data = JSON.parse(text);
44
-
45
- let results = data["results"];
46
- return results;
47
- }
48
-
49
- function get_complete_ratio(reports) {
50
- let total = reports.length;
51
- let complete = reports.filter(item => item.complete_status).length;
52
- return "" + complete + "/" + total + " complete";
53
- }
54
-
55
- function get_complete_count(reports) {
56
- return reports.filter(item => item.complete_status).length;
57
- }
58
-
59
- function get_summary(reports) {
60
- let summary = "";
61
- let total_audits = 0
62
- for (const scaffold_method of scaffold_methods) {
63
- if (reports[scaffold_method]) {
64
- let cur_reports = reports[scaffold_method];
65
- let cur_ratio = get_complete_ratio(cur_reports);
66
- let cur_result = "<li><b>" + scaffold_method + "</b>: " + cur_ratio + "</li>";
67
- summary += cur_result;
68
- let cur_complete = get_complete_count(cur_reports);
69
- total_audits += cur_complete;
70
- }
71
- }
72
-
73
- let top_summary = "<li><b>Total audits</b>: " + total_audits + "</li>";
74
- summary = "<ul>" + top_summary + summary + "</ul>";
75
- return summary;
76
- }
77
-
78
- function get_url(user, scaffold_method) {
79
- return "http://localhost:5001/?user=" + user + "&scaffold=" + scaffold_method;
80
- }
81
- </script>
82
-
83
- <svelte:head>
84
- <title>Results</title>
85
- </svelte:head>
86
-
87
- <div class="panel">
88
- <div class="panel_contents">
89
- <div>
90
- <h3>Results</h3>
91
- </div>
92
-
93
- <div style="padding-top:50px">
94
- {#await promise}
95
- <div class="app_loading">
96
- <LinearProgress indeterminate />
97
- </div>
98
- {:then results}
99
- {#if results}
100
- {#each results as user_report}
101
- <div class="head_3">{user_report["user"]}</div>
102
- <div class="section_indent">
103
- <div class="head_5">Summary</div>
104
- <div>{@html get_summary(user_report)}</div>
105
- <ul>
106
- <li>Labeling pages
107
- <ul>
108
- <li>
109
- <a href="http://localhost:5001/?user={user_report["user"]}&tab=labeling&label_mode=3" target="_blank">Group-based model</a>
110
- </li>
111
- <li>
112
- <a href="http://localhost:5001/?user={user_report["user"]}&tab=labeling&label_mode=0" target="_blank">Personalized model</a>
113
- </li>
114
- </ul>
115
- </li>
116
- <li>Auditing pages
117
- <ul>
118
- <li>
119
- <a href="http://localhost:5001/?user={user_report["user"]}&scaffold=personal_group" target="_blank">Group-based audit - personal scaffold</a>
120
- </li>
121
- <li>
122
- <a href="http://localhost:5001/?user={user_report["user"]}&scaffold=personal" target="_blank">Individual audit - personal scaffold</a>
123
- </li>
124
- <li>
125
- <a href="http://localhost:5001/?user={user_report["user"]}&scaffold=prompts" target="_blank">Individual audit - prompt scaffold</a>
126
- </li>
127
- </ul>
128
- </li>
129
- </ul>
130
- </div>
131
- {#each scaffold_methods as scaffold_method}
132
- {#if user_report[scaffold_method]}
133
- <div class="spacing_vert_60 section_indent">
134
- <div class="head_5">
135
- {scaffold_method} ({get_complete_ratio(user_report[scaffold_method])})
136
- [<a href={get_url(user_report["user"], scaffold_method)} target="_blank">link</a>]
137
- </div>
138
- {#each user_report[scaffold_method] as report}
139
- <div class="spacing_vert_40 section_indent">
140
- <div class="head_6_non_cap">
141
- {report["title"]}
142
- </div>
143
-
144
- <div class="spacing_vert_20">
145
- <div class="">
146
- <b>Error type</b>
147
- </div>
148
- {report["error_type"]}
149
- </div>
150
-
151
- <div class="spacing_vert_20">
152
- <div class="">
153
- <b>Evidence</b>
154
- </div>
155
- {#if report["evidence"].length > 0}
156
- <ClusterResults
157
- cluster={null}
158
- model={null}
159
- data={{"cluster_comments": report["evidence"]}}
160
- show_vis={false}
161
- show_checkboxes={false}
162
- table_width_pct={100}
163
- rowsPerPage={10}
164
- table_id={"panel"}
165
- />
166
- {:else}
167
- <p class="grey_text">
168
- No examples added
169
- </p>
170
- {/if}
171
- </div>
172
-
173
- <div class="spacing_vert_20">
174
- <div class="">
175
- <b>Summary/Suggestions</b>
176
- </div>
177
- {report["text_entry"]}
178
- </div>
179
-
180
- <div class="spacing_vert_20">
181
- <b>Completed</b>
182
- <FormField>
183
- <Checkbox checked={report["complete_status"]} disabled/>
184
- </FormField>
185
- </div>
186
-
187
- </div>
188
- {/each}
189
- </div>
190
- {/if}
191
- {/each}
192
- {/each}
193
- {/if}
194
- {:catch error}
195
- <p style="color: red">{error.message}</p>
196
- {/await}
197
- </div>
198
- </div>
199
- </div>
200
-
201
- <style>
202
- .panel {
203
- width: 80%;
204
- padding: 50px;
205
- }
206
- </style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
indie_label_svelte/src/SelectUserDialog.svelte DELETED
@@ -1,66 +0,0 @@
1
- <script lang="ts">
2
- import Dialog, { Title, Content, Actions } from "@smui/dialog";
3
- import Button, { Label } from "@smui/button";
4
- import Textfield from "@smui/textfield";
5
- import Select, { Option } from "@smui/select";
6
- import { user } from "./stores/cur_user_store.js";
7
- import { users } from "./stores/all_users_store.js";
8
-
9
- export let open;
10
- export let cur_user;
11
- let cur_user_tf = cur_user;
12
- let cur_user_sel = cur_user;
13
-
14
- let all_users;
15
- users.subscribe((value) => {
16
- all_users = value;
17
- });
18
-
19
- function updateUserTextField() {
20
- user.update((value) => cur_user_tf);
21
- if (!all_users.includes(user)) {
22
- all_users = all_users.concat(cur_user_tf);
23
- users.update(all_users);
24
- }
25
- open = false;
26
- }
27
-
28
- function updateUserSel() {
29
- user.update((value) => cur_user_sel);
30
- open = false;
31
- }
32
- </script>
33
-
34
- <div>
35
- <Dialog
36
- bind:open
37
- aria-labelledby="simple-title"
38
- aria-describedby="simple-content"
39
- >
40
- <!-- Title cannot contain leading whitespace due to mdc-typography-baseline-top() -->
41
- <Title id="simple-title">Select Current User</Title>
42
- <Content id="simple-content">
43
- <Textfield bind:value={cur_user_tf} label="Enter user's name" />
44
-
45
- <Select bind:value={cur_user_sel} label="Select Menu">
46
- {#each all_users as u}
47
- <Option value={u}>{u}</Option>
48
- {/each}
49
- </Select>
50
- </Content>
51
- <Actions>
52
- <Button on:click={updateUserTextField}>
53
- <Label>Update from TextField</Label>
54
- </Button>
55
- <Button on:click={updateUserSel}>
56
- <Label>Update from Select</Label>
57
- </Button>
58
- </Actions>
59
- </Dialog>
60
- </div>
61
-
62
- <style>
63
- :global(.mdc-dialog__surface) {
64
- height: 300px;
65
- }
66
- </style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
indie_label_svelte/src/StudyLinks.svelte DELETED
@@ -1,59 +0,0 @@
1
- <script lang="ts">
2
- import { user } from "./stores/cur_user_store.js";
3
-
4
- let cur_user;
5
- user.subscribe((value) => {
6
- cur_user = value;
7
- });
8
-
9
- </script>
10
-
11
- <svelte:head>
12
- <title>Study Links</title>
13
- </svelte:head>
14
-
15
- <div class="panel">
16
- <div class="panel_contents">
17
- <div>
18
- <h3>Study Links</h3>
19
- </div>
20
-
21
- <div>
22
- <!-- <div class="head_5">{cur_user}</div> -->
23
- <div class="section_indent">
24
- <ul>
25
- <li>Labeling pages
26
- <ul>
27
- <li>
28
- <a href="http://localhost:5001/?user={cur_user}&tab=labeling&label_mode=3" target="_blank">Group-based model</a>
29
- </li>
30
- <li>
31
- <a href="http://localhost:5001/?user={cur_user}&tab=labeling&label_mode=0" target="_blank">Personalized model</a>
32
- </li>
33
- </ul>
34
- </li>
35
- <li>Auditing pages
36
- <ul>
37
- <li>
38
- <a href="http://localhost:5001/?user={cur_user}&scaffold=personal_group" target="_blank">Group-based audit - personal scaffold</a>
39
- </li>
40
- <li>
41
- <a href="http://localhost:5001/?user={cur_user}&scaffold=personal" target="_blank">Individual audit - personal scaffold</a>
42
- </li>
43
- <li>
44
- <a href="http://localhost:5001/?user={cur_user}&scaffold=prompts" target="_blank">Individual audit - prompt scaffold</a>
45
- </li>
46
- </ul>
47
- </li>
48
- </ul>
49
- </div>
50
- </div>
51
- </div>
52
- </div>
53
-
54
- <style>
55
- .panel {
56
- width: 80%;
57
- padding: 50px;
58
- }
59
- </style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
indie_label_svelte/src/TopicTraining.svelte CHANGED
@@ -4,21 +4,15 @@
4
  import Button, { Label } from "@smui/button";
5
  import DataTable, { Head, Body, Row, Cell } from "@smui/data-table";
6
  import LinearProgress from '@smui/linear-progress';
7
- import { user } from './stores/cur_user_store.js';
8
  import { model_chosen } from './stores/cur_model_store.js';
9
 
10
  export let topic;
11
  export let model_name = null;
 
12
 
13
  let to_label = {};
14
  let promise = Promise.resolve(null);
15
 
16
- // Get current user
17
- let cur_user;
18
- user.subscribe(value => {
19
- cur_user = value;
20
- });
21
-
22
  // Get current model
23
  if (model_name == null) {
24
  model_chosen.subscribe(value => {
 
4
  import Button, { Label } from "@smui/button";
5
  import DataTable, { Head, Body, Row, Cell } from "@smui/data-table";
6
  import LinearProgress from '@smui/linear-progress';
 
7
  import { model_chosen } from './stores/cur_model_store.js';
8
 
9
  export let topic;
10
  export let model_name = null;
11
+ export let cur_user;
12
 
13
  let to_label = {};
14
  let promise = Promise.resolve(null);
15
 
 
 
 
 
 
 
16
  // Get current model
17
  if (model_name == null) {
18
  model_chosen.subscribe(value => {
indie_label_svelte/src/stores/all_users_store.js DELETED
@@ -1,6 +0,0 @@
1
- import { writable } from 'svelte/store';
2
-
3
- // Fallback if request doesn't work
4
- let all_users = ["DemoUser"];
5
-
6
- export const users = writable(all_users);
 
 
 
 
 
 
 
indie_label_svelte/src/stores/cur_user_store.js DELETED
@@ -1,3 +0,0 @@
1
- import { writable } from 'svelte/store';
2
-
3
- export const user = writable("DemoUser");
 
 
 
 
server.py CHANGED
@@ -17,10 +17,12 @@ import math
17
  import altair as alt
18
  import matplotlib.pyplot as plt
19
  import time
 
20
 
21
  import audit_utils as utils
22
 
23
  app = Flask(__name__)
 
24
 
25
  # Path for our main Svelte page
26
  @app.route("/")
@@ -38,11 +40,19 @@ def home(path):
38
  comments_grouped_full_topic_cat = pd.read_pickle("data/comments_grouped_full_topic_cat2_persp.pkl")
39
 
40
  @app.route("/audit_settings")
41
- def audit_settings():
42
  # Fetch page content
43
  user = request.args.get("user")
44
  scaffold_method = request.args.get("scaffold_method")
45
 
 
 
 
 
 
 
 
 
46
  user_models = utils.get_all_model_names(user)
47
  grp_models = [m for m in user_models if m.startswith(f"model_{user}_group_")]
48
 
@@ -89,21 +99,10 @@ def audit_settings():
89
  "breakdown_categories": ['Topic', 'Toxicity Category', 'Toxicity Severity'],
90
  "clusters": clusters_options,
91
  "clusters_for_tuning": clusters_for_tuning_options,
 
92
  }
93
  return json.dumps(context)
94
 
95
- ########################################
96
- # ROUTE: /GET_USERS
97
- @app.route("/get_users")
98
- def get_users():
99
- # Fetch page content
100
- with open(f"./data/users_to_models.pkl", "rb") as f:
101
- users_to_models = pickle.load(f)
102
- users = list(users_to_models.keys())
103
- context = {
104
- "users": users,
105
- }
106
- return json.dumps(context)
107
 
108
  ########################################
109
  # ROUTE: /GET_AUDIT
@@ -320,8 +319,7 @@ def get_labeling():
320
  clusters_for_tuning = utils.get_large_clusters(min_n=150)
321
  clusters_for_tuning_options = [{"value": i, "text": cluster} for i, cluster in enumerate(clusters_for_tuning)] # Format for Svelecte UI element
322
 
323
- # model_name_suggestion = f"model_{int(time.time())}"
324
- model_name_suggestion = f"model_{user}"
325
 
326
  context = {
327
  "personalized_models": utils.get_all_model_names(user),
@@ -764,40 +762,5 @@ def get_explore_examples():
764
  }
765
  return json.dumps(results)
766
 
767
- ########################################
768
- # ROUTE: /GET_RESULTS
769
- @app.route("/get_results")
770
- def get_results():
771
- users = request.args.get("users")
772
- if users != "":
773
- users = users.split(",")
774
- # print("users", users)
775
-
776
- IGNORE_LIST = ["DemoUser"]
777
- report_dir = f"./data/user_reports"
778
-
779
-
780
- # For each user, get personal and prompt results
781
- # Get links to label pages and audit pages
782
- results = []
783
- for user in users:
784
- if user not in IGNORE_LIST:
785
- user_results = {}
786
- user_results["user"] = user
787
- for scaffold_method in ["personal", "personal_group", "prompts"]:
788
- # Get results
789
- user_file = os.path.join(report_dir, f"{user}_{scaffold_method}.pkl")
790
- if os.path.isfile(user_file):
791
- with open(user_file, "rb") as f:
792
- user_results[scaffold_method] = pickle.load(f)
793
- results.append(user_results)
794
-
795
- # print("results", results)
796
-
797
- results = {
798
- "results": results,
799
- }
800
- return json.dumps(results)
801
-
802
  if __name__ == "__main__":
803
  app.run(debug=True, port=5001)
 
17
  import altair as alt
18
  import matplotlib.pyplot as plt
19
  import time
20
+ import friendlywords as fw
21
 
22
  import audit_utils as utils
23
 
24
  app = Flask(__name__)
25
+ DEBUG = False # Debug flag for development; set to False for production
26
 
27
  # Path for our main Svelte page
28
  @app.route("/")
 
40
  comments_grouped_full_topic_cat = pd.read_pickle("data/comments_grouped_full_topic_cat2_persp.pkl")
41
 
42
  @app.route("/audit_settings")
43
+ def audit_settings(debug=DEBUG):
44
  # Fetch page content
45
  user = request.args.get("user")
46
  scaffold_method = request.args.get("scaffold_method")
47
 
48
+ # Assign user ID if none is provided (default case)
49
+ if user == "null":
50
+ if debug:
51
+ user = "DemoUser"
52
+ else:
53
+ # Generate random two-word user ID
54
+ user = fw.generate(2, separator="_")
55
+
56
  user_models = utils.get_all_model_names(user)
57
  grp_models = [m for m in user_models if m.startswith(f"model_{user}_group_")]
58
 
 
99
  "breakdown_categories": ['Topic', 'Toxicity Category', 'Toxicity Severity'],
100
  "clusters": clusters_options,
101
  "clusters_for_tuning": clusters_for_tuning_options,
102
+ "user": user,
103
  }
104
  return json.dumps(context)
105
 
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
  ########################################
108
  # ROUTE: /GET_AUDIT
 
319
  clusters_for_tuning = utils.get_large_clusters(min_n=150)
320
  clusters_for_tuning_options = [{"value": i, "text": cluster} for i, cluster in enumerate(clusters_for_tuning)] # Format for Svelecte UI element
321
 
322
+ model_name_suggestion = f"my_model"
 
323
 
324
  context = {
325
  "personalized_models": utils.get_all_model_names(user),
 
762
  }
763
  return json.dumps(results)
764
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
765
  if __name__ == "__main__":
766
  app.run(debug=True, port=5001)