Spaces:
Sleeping
Sleeping
File size: 2,249 Bytes
141f1e0 b87ce7c ebff827 b87ce7c 141f1e0 bc714de 30f0c04 bc714de 30f0c04 b87ce7c 141f1e0 bc714de 30f0c04 bc714de 141f1e0 b87ce7c ebff827 b87ce7c ebff827 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | from dataclasses import dataclass
def fields(raw_class):
from dataclasses import fields as dataclass_fields
from dataclasses import is_dataclass
if is_dataclass(raw_class):
df = dataclass_fields(raw_class)
if df:
return [getattr(raw_class, field.name) for field in df]
return [v for k, v in raw_class.__dict__.items() if k[:2] != "__" and k[-2:] != "__" and not callable(v)]
@dataclass
class ColumnContent:
name: str
type: str
displayed_by_default: bool
hidden: bool = False
never_hidden: bool = False
@dataclass(frozen=True)
class TeamColumn:
team_name = ColumnContent("Team Name", "str", True, never_hidden=True)
best_f1 = ColumnContent("Best F1 Score ⬆️", "number", True)
best_accuracy = ColumnContent("Best Accuracy ⬆️", "number", True)
best_precision = ColumnContent("Best Precision ⬆️", "number", True)
best_recall = ColumnContent("Best Recall ⬆️", "number", True)
best_tp = ColumnContent("Best TP ⬆️", "number", True)
best_fp = ColumnContent("Best FP ⬇️", "number", True)
best_fn = ColumnContent("Best FN ⬇️", "number", True)
best_tn = ColumnContent("Best TN ⬆️", "number", True)
best_submission_date = ColumnContent("Submission Date", "str", True)
@dataclass(frozen=True)
class SubmissionQueueColumn:
team_name = ColumnContent("Team Name", "str", True)
submission_date = ColumnContent("Submission Date", "str", True)
f1 = ColumnContent("F1 Score ⬆️", "number", True)
accuracy = ColumnContent("Accuracy ⬆️", "number", True)
precision = ColumnContent("Precision ⬆️", "number", True)
recall = ColumnContent("Recall ⬆️", "number", True)
tp = ColumnContent("TP ⬆️", "number", True)
fp = ColumnContent("FP ⬇️", "number", True)
fn = ColumnContent("FN ⬇️", "number", True)
tn = ColumnContent("TN ⬆️", "number", True)
status = ColumnContent("Status", "str", True)
COLS = [c.name for c in fields(TeamColumn) if hasattr(c, "hidden") and not c.hidden]
SUBMISSION_COLS = [c.name for c in fields(SubmissionQueueColumn) if hasattr(c, "name")]
SUBMISSION_TYPES = [c.type for c in fields(SubmissionQueueColumn) if hasattr(c, "type")]
|