• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

gcivil-nyu-org / team4-wed-fall25 / 63

10 Nov 2025 07:18PM UTC coverage: 75.054% (+11.0%) from 64.094%
63

push

travis-pro

web-flow
Merge pull request #77 from gcivil-nyu-org/feature/run_test_models_locally

fixed some UI changes and test cases

403 of 431 new or added lines in 11 files covered. (93.5%)

269 existing lines in 4 files now uncovered.

1047 of 1395 relevant lines covered (75.05%)

0.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.28
/note2webapp/forms.py
1
# note2webapp/forms.py
2
from django import forms
1✔
3
from .models import ModelUpload, ModelVersion
1✔
4

5

6
# -------------------------
7
# Upload Form (for new upload)
8
# -------------------------
9
class UploadForm(forms.ModelForm):
1✔
10
    class Meta:
1✔
11
        model = ModelUpload
1✔
12
        fields = ["name"]
1✔
13

14

15
# -------------------------
16
# Version Form (for new version)
17
# -------------------------
18
class VersionForm(forms.ModelForm):
1✔
19
    information = forms.CharField(
1✔
20
        widget=forms.Textarea(
21
            attrs={
22
                "rows": 4,
23
                "placeholder": "Enter information about this model version...",
24
            }
25
        ),
26
        required=True,
27
        label="Model Information",
28
        help_text="Required: Add relevant information about this version",
29
    )
30

31
    class Meta:
1✔
32
        model = ModelVersion
1✔
33
        fields = [
1✔
34
            "model_file",
35
            "predict_file",
36
            "schema_file",
37
            "tag",
38
            "category",
39
            "information",
40
        ]
41
        widgets = {
1✔
42
            "model_file": forms.FileInput(attrs={"required": False}),
43
            "predict_file": forms.FileInput(attrs={"required": False}),
44
            "schema_file": forms.FileInput(attrs={"required": False}),
45
        }
46

47
    def __init__(self, *args, **kwargs):
1✔
48
        super().__init__(*args, **kwargs)
1✔
49

50
        # enforce the 3 categories you decided
51
        self.fields["category"].choices = [
1✔
52
            ("sentiment", "Sentiment"),
53
            ("recommendation", "Recommendation"),
54
            ("text-classification", "Text Classification"),
55
        ]
56
        if not self.initial.get("category"):
1✔
57
            self.fields["category"].initial = "sentiment"
1✔
58

59
        # we’ll do backend checks, so keep these False here
60
        self.fields["model_file"].required = False
1✔
61
        self.fields["predict_file"].required = False
1✔
62
        self.fields["schema_file"].required = False
1✔
63

64
        self.fields["model_file"].help_text = "Required: Upload your .pt model file"
1✔
65
        self.fields["predict_file"].help_text = (
1✔
66
            "Required: Upload your .py prediction script"
67
        )
68
        self.fields["schema_file"].help_text = "Required: Upload your .json schema file"
1✔
69

70
    def clean(self):
1✔
71
        cleaned_data = super().clean()
1✔
72
        model_file = cleaned_data.get("model_file")
1✔
73
        predict_file = cleaned_data.get("predict_file")
1✔
74
        schema_file = cleaned_data.get("schema_file")
1✔
75
        information = cleaned_data.get("information")
1✔
76

77
        if not model_file:
1✔
78
            raise forms.ValidationError("Model file (.pt) is required")
1✔
79
        if not predict_file:
1✔
80
            raise forms.ValidationError("Predict file (.py) is required")
1✔
81
        if not schema_file:
1✔
82
            raise forms.ValidationError("Schema file (.json) is required")
1✔
83
        if not information or not information.strip():
1✔
84
            raise forms.ValidationError("Model Information is required")
1✔
85

86
        return cleaned_data
1✔
87

88
    def clean_model_file(self):
1✔
89
        file = self.cleaned_data.get("model_file")
1✔
90
        if file and not file.name.endswith(".pt"):
1✔
91
            raise forms.ValidationError("Only .pt files are allowed for Model File")
1✔
92
        return file
1✔
93

94
    def clean_predict_file(self):
1✔
95
        file = self.cleaned_data.get("predict_file")
1✔
96
        if file and not file.name.endswith(".py"):
1✔
97
            raise forms.ValidationError("Only .py files are allowed for Predict File")
1✔
98
        return file
1✔
99

100
    def clean_schema_file(self):
1✔
101
        file = self.cleaned_data.get("schema_file")
1✔
102
        if file and not file.name.endswith(".json"):
1✔
103
            raise forms.ValidationError("Only .json files allowed for schema")
1✔
104
        return file
1✔
105

106
    def clean_tag(self):
1✔
107
        tag = self.cleaned_data.get("tag")
1✔
108
        if not tag:
1✔
UNCOV
109
            raise forms.ValidationError("Tag is required")
×
110
        return tag
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc