Spaces:
Running
Running
Add verifying filter
Browse files- src/submissions.py +32 -9
src/submissions.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
from collections import defaultdict
|
2 |
from enum import Enum
|
|
|
3 |
|
4 |
import gradio as gr
|
5 |
import pandas as pd
|
@@ -11,10 +12,17 @@ from src.chain_data import get_neurons
|
|
11 |
from wandb_data import get_current_runs, Run, get_blacklisted_keys
|
12 |
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
class SubmissionStatus(Enum):
|
15 |
BLACKLISTED = ("Blacklisted", "gray")
|
16 |
DUPLICATE = ("Duplicate", "gray")
|
17 |
PENDING = ("Pending", "orange")
|
|
|
18 |
DONE = ("Done", "springgreen")
|
19 |
INVALID = ("Invalid", "red")
|
20 |
|
@@ -23,8 +31,11 @@ class SubmissionStatus(Enum):
|
|
23 |
if is_blacklisted(hotkey, coldkey):
|
24 |
return SubmissionStatus.BLACKLISTED
|
25 |
|
26 |
-
|
|
|
27 |
return SubmissionStatus.DUPLICATE
|
|
|
|
|
28 |
|
29 |
if hotkey in run.submissions and block > run.submissions[hotkey].info.block and hotkey not in run.invalid_submissions:
|
30 |
return SubmissionStatus.PENDING
|
@@ -42,11 +53,22 @@ def is_blacklisted(hotkey: Key, coldkey: Key) -> bool:
|
|
42 |
return hotkey in get_blacklisted_keys().hotkeys or coldkey in get_blacklisted_keys().coldkeys
|
43 |
|
44 |
|
45 |
-
def is_duplicate_submission(hotkey: Key, revision: str) ->
|
46 |
-
|
|
|
|
|
47 |
submission.hotkey == hotkey and submission.revision == revision
|
48 |
-
for submission in
|
49 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
|
52 |
DROPDOWN_OPTIONS = [status.value[0] for status in SubmissionStatus]
|
@@ -67,9 +89,10 @@ def create_duplicate_submissions_plot() -> gr.Plot:
|
|
67 |
if is_blacklisted(hotkey, coldkey):
|
68 |
continue
|
69 |
|
70 |
-
|
|
|
71 |
submissions_by_coldkey[coldkey][0].append(commitment)
|
72 |
-
|
73 |
submissions_by_coldkey[coldkey][1].append(commitment)
|
74 |
|
75 |
submissions_by_coldkey = dict(sorted(
|
@@ -86,7 +109,7 @@ def create_duplicate_submissions_plot() -> gr.Plot:
|
|
86 |
x=[f"{coldkey[:6]}..."],
|
87 |
y=[len(safe_commitments)],
|
88 |
name="Safe",
|
89 |
-
marker_color="green",
|
90 |
hovertemplate="<br>".join([
|
91 |
"Submissions (%{y}):<br>" + "<br>".join(urls_safe)
|
92 |
]) + "<extra></extra>"
|
@@ -97,7 +120,7 @@ def create_duplicate_submissions_plot() -> gr.Plot:
|
|
97 |
x=[f"{coldkey[:6]}..."],
|
98 |
y=[len(duplicate_commitments)],
|
99 |
name="Duplicate",
|
100 |
-
marker_color="red",
|
101 |
hovertemplate="<br>".join([
|
102 |
"Submissions (%{y}):<br>" + "<br>".join(urls_duplicate)
|
103 |
]) + "<extra></extra>"
|
|
|
1 |
from collections import defaultdict
|
2 |
from enum import Enum
|
3 |
+
from enum import IntEnum
|
4 |
|
5 |
import gradio as gr
|
6 |
import pandas as pd
|
|
|
12 |
from wandb_data import get_current_runs, Run, get_blacklisted_keys
|
13 |
|
14 |
|
15 |
+
class DuplicateStatus(IntEnum):
|
16 |
+
SAFE = 0
|
17 |
+
DUPLICATE = 1
|
18 |
+
PENDING_VERIFICATION = 2
|
19 |
+
|
20 |
+
|
21 |
class SubmissionStatus(Enum):
|
22 |
BLACKLISTED = ("Blacklisted", "gray")
|
23 |
DUPLICATE = ("Duplicate", "gray")
|
24 |
PENDING = ("Pending", "orange")
|
25 |
+
VERIFYING = ("Verifying", "aqua")
|
26 |
DONE = ("Done", "springgreen")
|
27 |
INVALID = ("Invalid", "red")
|
28 |
|
|
|
31 |
if is_blacklisted(hotkey, coldkey):
|
32 |
return SubmissionStatus.BLACKLISTED
|
33 |
|
34 |
+
duplicate_status = is_duplicate_submission(hotkey, revision)
|
35 |
+
if duplicate_status == DuplicateStatus.DUPLICATE:
|
36 |
return SubmissionStatus.DUPLICATE
|
37 |
+
elif duplicate_status == DuplicateStatus.PENDING_VERIFICATION:
|
38 |
+
return SubmissionStatus.VERIFYING
|
39 |
|
40 |
if hotkey in run.submissions and block > run.submissions[hotkey].info.block and hotkey not in run.invalid_submissions:
|
41 |
return SubmissionStatus.PENDING
|
|
|
53 |
return hotkey in get_blacklisted_keys().hotkeys or coldkey in get_blacklisted_keys().coldkeys
|
54 |
|
55 |
|
56 |
+
def is_duplicate_submission(hotkey: Key, revision: str) -> DuplicateStatus:
|
57 |
+
duplicate_selection = get_blacklisted_keys().duplicate_selection
|
58 |
+
|
59 |
+
if any(
|
60 |
submission.hotkey == hotkey and submission.revision == revision
|
61 |
+
for submission in duplicate_selection.duplicate_submissions
|
62 |
+
):
|
63 |
+
return DuplicateStatus.DUPLICATE
|
64 |
+
|
65 |
+
elif any(
|
66 |
+
submission.hotkey == hotkey and submission.revision == revision
|
67 |
+
for submission in duplicate_selection.safe_submissions
|
68 |
+
):
|
69 |
+
return DuplicateStatus.SAFE
|
70 |
+
|
71 |
+
return DuplicateStatus.PENDING_VERIFICATION
|
72 |
|
73 |
|
74 |
DROPDOWN_OPTIONS = [status.value[0] for status in SubmissionStatus]
|
|
|
89 |
if is_blacklisted(hotkey, coldkey):
|
90 |
continue
|
91 |
|
92 |
+
duplicate_status = is_duplicate_submission(hotkey, commitment.revision)
|
93 |
+
if duplicate_status == DuplicateStatus.DUPLICATE:
|
94 |
submissions_by_coldkey[coldkey][0].append(commitment)
|
95 |
+
elif duplicate_status == DuplicateStatus.SAFE:
|
96 |
submissions_by_coldkey[coldkey][1].append(commitment)
|
97 |
|
98 |
submissions_by_coldkey = dict(sorted(
|
|
|
109 |
x=[f"{coldkey[:6]}..."],
|
110 |
y=[len(safe_commitments)],
|
111 |
name="Safe",
|
112 |
+
marker_color="green", # type: ignore
|
113 |
hovertemplate="<br>".join([
|
114 |
"Submissions (%{y}):<br>" + "<br>".join(urls_safe)
|
115 |
]) + "<extra></extra>"
|
|
|
120 |
x=[f"{coldkey[:6]}..."],
|
121 |
y=[len(duplicate_commitments)],
|
122 |
name="Duplicate",
|
123 |
+
marker_color="red", # type: ignore
|
124 |
hovertemplate="<br>".join([
|
125 |
"Submissions (%{y}):<br>" + "<br>".join(urls_duplicate)
|
126 |
]) + "<extra></extra>"
|