Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model Page UI Improvements #228

Merged
merged 180 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
180 commits
Select commit Hold shift + click to select a range
7a22e0a
fix visualizer in annotate page and add the relevant front end test
Apr 16, 2023
af8105f
add predit button test
May 8, 2023
6492924
add front-end test which catch the bug of calling api twice
May 8, 2023
ee5dd5c
cannot find the reason why predict api was called twice so i fix the …
May 14, 2023
c231c5d
modify wait time(500)
May 15, 2023
e59ac7c
Merge branch 'dev' into visualizer
May 28, 2023
8c9d9b0
fix the load issue in annotate page
May 29, 2023
762021b
merge dev
May 29, 2023
e11434f
delete one comment
Jun 3, 2023
8227e9d
Merge remote-tracking branch 'refs/remotes/origin/dev' into dev
Jun 26, 2023
6748379
add initialized model page
Jul 21, 2023
a2f0eda
feat: model upload dialog
shuguang-lv Jul 24, 2023
2e19b74
adjust page layout
Jul 24, 2023
bd436f3
Add db setup doc; remove useless db files
PaulCCCCCCH Jul 25, 2023
c2e50be
add database schema change note
PaulCCCCCCH Jul 27, 2023
9b5e2ea
add db schema design diagram and code
PaulCCCCCCH Jul 27, 2023
63c2bb1
Create 'model.py' for initial model APIs sketch
Leon-Leyang Jul 30, 2023
c380573
Add docstrings for the UploadModel API
Leon-Leyang Jul 30, 2023
1b4edfe
Add 'model_utils.py' for utilities & outline 'UploadModel' API
Leon-Leyang Jul 30, 2023
f16a80a
change button positions
Jul 31, 2023
b45dc49
feat: improve styles of model uploader; add data binding
shuguang-lv Aug 7, 2023
00018f2
Get all metadata of the model according to the db design
Leon-Leyang Aug 7, 2023
e7d012e
Complete `init_model` function implementation
Leon-Leyang Aug 7, 2023
87212fc
Extend `UploadModel` to handle uploading models after training
Leon-Leyang Aug 8, 2023
3a6f693
refactor: implemented orm models
PaulCCCCCCH Aug 14, 2023
055a55c
fixed db model definition bugs
PaulCCCCCCH Aug 14, 2023
7e1f42d
delete misupload content
Aug 14, 2023
2d782d3
delete misapplied content
monmonli Aug 14, 2023
3a9f04b
change db types in function signatures
PaulCCCCCCH Aug 20, 2023
abd9c76
feat: add code file input; read content from code file
shuguang-lv Aug 21, 2023
41967ca
Enhance UploadModel API with ID assignment and architecture metadata
Leon-Leyang Aug 27, 2023
e065540
Complete `val_model` function implementation
Leon-Leyang Aug 28, 2023
6a54e9b
fix: new database operations with SQLAlchemy partially working
PaulCCCCCCH Aug 28, 2023
bb88202
most functionalities working; not passing test cases
PaulCCCCCCH Aug 31, 2023
01571c5
test cases passing
PaulCCCCCCH Aug 31, 2023
fb906b3
chore: update docker image version; include SQLAlchemy dependency
PaulCCCCCCH Aug 31, 2023
56bc6a8
feat: implemented model operations
PaulCCCCCCH Aug 31, 2023
a530304
Update save path for model definition and checkpoint files to /genera…
Leon-Leyang Sep 3, 2023
8a60f0c
Refactor 'UploadModel' API for enhanced model handling
Leon-Leyang Sep 3, 2023
a423336
Migrate from importlib_resources to importlib.resources
Leon-Leyang Sep 3, 2023
8e9fe4b
Refresh requirements.txt with updated packge versions
Leon-Leyang Sep 3, 2023
4d35d95
build: update lerna to 7; use npm workspaces; reorg deps
shuguang-lv Sep 4, 2023
a389363
fix: build script
shuguang-lv Sep 4, 2023
0000070
Merge branch 'dev' of https://github.com/HaohanWang/Robustar_implemen…
Leon-Leyang Sep 9, 2023
a0fb0b7
Merge branch 'chonghan/model-db' into 'merge/model-db-upload-val'
Leon-Leyang Sep 9, 2023
5ccd396
Merge branch 'leyang/model-upload-val' into merge/model-db-upload-val
Leon-Leyang Sep 9, 2023
450a07e
Correct some mistakes to let 'UploadModel' API work for basic custom …
Leon-Leyang Sep 10, 2023
f4c8c27
Fix type errors of var `pretrained` and `num_classes`
Leon-Leyang Sep 10, 2023
cfd78fa
Save the weight of pretrained predefined model to a local file
Leon-Leyang Sep 10, 2023
f8ea4c3
Raise an exception if pretrained weight is required for "ResNet18-32x32"
Leon-Leyang Sep 10, 2023
30a4d8d
Save `num_classes` of predefined models into local files for later re…
Leon-Leyang Sep 10, 2023
4088512
Save current model weights to a local file if the weight file is not …
Leon-Leyang Sep 11, 2023
687fe9f
Comment db clean up temporarily.
Leon-Leyang Sep 17, 2023
a77123c
feat: add model switch with dummy model id and test
PaulCCCCCCH Sep 20, 2023
fceb5d3
Merge branch 'merge/model-db-upload-val' into chonghan/model-switch
PaulCCCCCCH Sep 20, 2023
3fef9b5
feat: model apis implemented; need testing
PaulCCCCCCH Sep 21, 2023
8964492
Permit optional transmission of description and tags in metadata from…
Leon-Leyang Sep 22, 2023
a240a6c
Update model metadata design: Introduce `nickname` and Rename `name` …
Leon-Leyang Sep 22, 2023
7684bde
Extract 'tags' column from 'Models' table into a new table, and maint…
Leon-Leyang Sep 22, 2023
68d16cd
Enhance `UploadModel` docstring documentation
Leon-Leyang Sep 22, 2023
47fba98
Merge remote-tracking branch 'origin/dev' into dev
Sep 24, 2023
4ab0eae
Merge remote-tracking branch 'origin' into model
shuguang-lv Sep 24, 2023
16d2409
feat: improve styles of model page; add data binding
shuguang-lv Sep 25, 2023
2157f49
merge switch model
Sep 25, 2023
a07634b
merge switch model
Sep 25, 2023
f3f04a8
Close DB connection explicitly for .db file removal; Set fixture scop…
Leon-Leyang Oct 1, 2023
e8429f2
Change the base directory in pytest for debugging
Leon-Leyang Oct 1, 2023
e3a08a1
Debugging
Leon-Leyang Oct 1, 2023
eab8f7a
Debugging
Leon-Leyang Oct 1, 2023
bbbd56c
Debugging
Leon-Leyang Oct 1, 2023
552b620
Debugging
Leon-Leyang Oct 1, 2023
3cd7281
Debugging
Leon-Leyang Oct 1, 2023
12de854
Debugging
Leon-Leyang Oct 1, 2023
9189ca3
Restore for a full test
Leon-Leyang Oct 1, 2023
a870b7a
Restore for full test
Leon-Leyang Oct 1, 2023
0bd0339
Capture the 'stdout' and 'stderr' in pytest for debugging
Leon-Leyang Oct 1, 2023
8d31540
Debugging
Leon-Leyang Oct 1, 2023
d2c9f2e
Debugging
Leon-Leyang Oct 1, 2023
7fff551
Debugging
Leon-Leyang Oct 1, 2023
d21da8f
Solve the problem by specifying the db file address as absolute path
Leon-Leyang Oct 1, 2023
47a9d4b
Restore the config of CircleCI test
Leon-Leyang Oct 1, 2023
6b9b029
fix: provide app context to all thread creations
PaulCCCCCCH Oct 2, 2023
1af97cf
Merge branch 'merge/model-db-upload-val' of github.com:HaohanWang/Rob…
PaulCCCCCCH Oct 2, 2023
74a85ca
feat: add api functions
Oct 8, 2023
3f41697
Merge branch 'dev' into merge/model-db-upload-val
PaulCCCCCCH Oct 10, 2023
92e0ffa
fix: correctly getting context for child threads
PaulCCCCCCH Oct 10, 2023
9061a12
Resolve code review feedback:
Leon-Leyang Oct 15, 2023
367efbb
Merge remote-tracking branch 'origin/merge/model-db-upload-val' into …
Leon-Leyang Oct 15, 2023
579389e
Merge remote-tracking branch 'origin' into model
shuguang-lv Oct 15, 2023
aaab7b6
Merge changes on dev and resolve conflicts.
PaulCCCCCCH Oct 17, 2023
0e421cc
model switch and CRUD api implemented
PaulCCCCCCH Oct 18, 2023
4d2935a
chore: resolve conflict in requirements.txt
PaulCCCCCCH Oct 18, 2023
3907ce8
fixed things to pass test_predict
PaulCCCCCCH Oct 22, 2023
8e6aabd
Merge branch 'dev' into model
Oct 22, 2023
78d26cb
Merge remote-tracking branch 'refs/remotes/origin/model' into model
Oct 22, 2023
5a0a938
Merge branch 'chonghan/model-switch' into model
shuguang-lv Oct 22, 2023
18eee9f
feat: integrate model upload API
shuguang-lv Oct 23, 2023
fbc8b90
model name attribute name fix
PaulCCCCCCH Oct 23, 2023
a340c4b
Merge branch 'chonghan/model-switch' into model
shuguang-lv Oct 23, 2023
42b19c3
feat: add code and weight file when uploading model
shuguang-lv Oct 23, 2023
dadf02e
merge model/switch
Oct 23, 2023
17cff09
merge model/switch
Oct 23, 2023
169bbf9
api fixes
PaulCCCCCCH Oct 24, 2023
2e645a9
fix: add a serializer for db models
PaulCCCCCCH Oct 24, 2023
57dc2c0
Merge branch 'chonghan/model-switch' into model
shuguang-lv Oct 25, 2023
c476186
feat: integrate get model list api
shuguang-lv Oct 25, 2023
7c1e2ab
add model api error handling and use serializer everywhere
PaulCCCCCCH Oct 26, 2023
50965ed
Merge branch 'chonghan/model-switch' into model
shuguang-lv Oct 26, 2023
2b9986b
Add `predefined` to the model's metadata
Leon-Leyang Oct 29, 2023
286de99
update test case
PaulCCCCCCH Oct 31, 2023
721a8b5
commenting out test case for now
PaulCCCCCCH Oct 31, 2023
907bbdd
chore: fix nit
PaulCCCCCCH Oct 31, 2023
4dff6d2
Resolve conflict
Leon-Leyang Oct 31, 2023
e5174dc
Cherry-pick model refactors from refactor/model-db-upload-val
Leon-Leyang Nov 1, 2023
9d28e6c
Add one TODO
Leon-Leyang Nov 3, 2023
d958b86
Remove one TODO
Leon-Leyang Nov 3, 2023
a0c0b6f
fix problem in set_current_model
PaulCCCCCCH Nov 5, 2023
4dcd1aa
Merge branch 'merge/v0.3' into 'merge/model-db-upload-val'
Leon-Leyang Nov 5, 2023
e126560
Merge branch 'chonghan/model-switch' into model
Nov 6, 2023
1f86bd2
Merge branch 'merge/v0.3' into model
Nov 6, 2023
7dc199e
Add `pretrained` as a new field in 'models' table & Stop saving weigh…
Leon-Leyang Nov 6, 2023
11da958
integrate front end apis and merge the most recent back end branches
Nov 6, 2023
1c20d25
Merge branch 'merge/v0.3' into model
shuguang-lv Nov 10, 2023
c4bdce9
feat(model): integrate existing APIs
shuguang-lv Nov 11, 2023
7730845
feat(model ): add tag field
shuguang-lv Nov 11, 2023
b2ea51b
Merge branch 'merge/v0.3' into model
shuguang-lv Nov 12, 2023
da70765
feat: more APIs implemented and manually tested
PaulCCCCCCH Nov 13, 2023
51deaed
Merge branch 'merge/v0.3' and resolve conflicts
Leon-Leyang Nov 18, 2023
1db997d
add the model list panel
Nov 19, 2023
a1716d3
Merge remote-tracking branch 'refs/remotes/origin/model' into model
Nov 19, 2023
8132395
add utility functions and some test cases
PaulCCCCCCH Nov 19, 2023
4237dcc
modify the model list panel
Nov 20, 2023
06e6154
modify the model list panel
Nov 20, 2023
9620efc
fix(model ): uploader and model list issues
shuguang-lv Nov 20, 2023
5c91772
Merge branch 'chonghan/v0.3-apis' into model
shuguang-lv Nov 20, 2023
fa4e4b5
Merge branch 'merge/v0.3' into model
shuguang-lv Nov 20, 2023
4d2bc7f
feat(model): integrate update, duplicate and get predefined API
shuguang-lv Nov 21, 2023
d0df4d9
Merge branch 'merge/v0.3' into chonghan/v0.3-apis
PaulCCCCCCH Nov 24, 2023
a0ab6f4
test: implemented basic model switch CRUD tests
PaulCCCCCCH Nov 25, 2023
b29635a
temp commit
PaulCCCCCCH Nov 27, 2023
e088ae9
modify the style of modellist component
Dec 4, 2023
4315294
uncomment a test case for edit
PaulCCCCCCH Dec 4, 2023
06c1272
update edit test case
PaulCCCCCCH Dec 4, 2023
8032383
add another edit test case
PaulCCCCCCH Dec 4, 2023
519e1b5
refactored db init logic
PaulCCCCCCH Dec 16, 2023
2b5be3a
fix backend unit tests
PaulCCCCCCH Dec 16, 2023
ac5156f
use same db across test cases
PaulCCCCCCH Dec 17, 2023
1c8be76
change scope to function
PaulCCCCCCH Dec 17, 2023
8701382
fix failed tests
PaulCCCCCCH Dec 17, 2023
0d8e80d
Merge branch 'chonghan/v0.3-apis' into model
shuguang-lv Dec 17, 2023
3122517
feat(model): improve styles and fix bugs of list data table
shuguang-lv Dec 18, 2023
4d1b67d
Merge branch 'merge/v0.3' into model
PaulCCCCCCH Dec 22, 2023
d564d9d
re-organize files
PaulCCCCCCH Dec 22, 2023
c93f917
chore: re-organize files and made some other small changes
PaulCCCCCCH Dec 22, 2023
c220d74
fix merge conflicts
PaulCCCCCCH Dec 22, 2023
5e10ee8
Fix training without current model set to pass tests for now
PaulCCCCCCH Dec 22, 2023
2bfbb2a
restoring package-lock since no library was updated
PaulCCCCCCH Dec 24, 2023
69cc288
fix(model): Set Current Model Button; Current Model Visibility
shuguang-lv Jan 13, 2024
f2fc1dd
add test of current model
monmonli Jan 13, 2024
393e5f6
Merge branch 'model' of https://github.com/PaulCCCCCCH/Robustar_imple…
monmonli Jan 13, 2024
b7f7e62
Merge branch 'merge/v0.3' into model
shuguang-lv Jan 15, 2024
58cc25a
Merge branch 'merge/v0.3' into model
PaulCCCCCCH Jan 22, 2024
a2d4cbc
feat(model): add error messages
shuguang-lv Jan 22, 2024
825a14f
add front end model test
monmonli Jan 28, 2024
ebc7ae3
add front end model test
monmonli Jan 28, 2024
6ab1861
add front end model test
monmonli Jan 28, 2024
6ed5dc4
Refactor backend and tests to identify models by `id` instead of `nic…
Leon-Leyang Jan 29, 2024
44eed61
Use `id` as the model handle in training
Leon-Leyang Jan 29, 2024
e49bf98
Fix typo
Leon-Leyang Jan 29, 2024
6dbae9b
Fix typo
Leon-Leyang Jan 29, 2024
207ec63
add new test files
monmonli Feb 4, 2024
926ebfd
Merge branch 'leyang/primary-id' into model
monmonli Feb 4, 2024
c7d66e8
update test
monmonli Feb 11, 2024
09ca3ec
Merge branch 'merge/v0.3' into model
monmonli Feb 11, 2024
44060f8
resolve conflict
monmonli Feb 11, 2024
0cd82c9
use id as primary key; all test passed
monmonli Feb 11, 2024
3835c90
fix tag issue
monmonli Mar 18, 2024
0316819
enable tag selction
monmonli Mar 18, 2024
1127494
add predefined prefix to tag
monmonli Mar 18, 2024
e8f3f07
Merge branch 'merge/v0.3' into model
PaulCCCCCCH May 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion back-end/database/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ class Models(db.Model):
)

def as_dict(self):
return {c.name: getattr(self, c.name) for c in self.__table__.columns}
data = {c.name: getattr(self, c.name) for c in self.__table__.columns}
data["tags"] = [tag.name for tag in self.tags]
return data



class Tags(db.Model):
Expand Down
15 changes: 11 additions & 4 deletions back-end/objects/RModelWrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,17 @@ def update_model(self, model_id, metadata) -> Models:
)
model_to_update.nickname = metadata.get("nickname") or model_to_update.nickname

prev_tags = metadata.get("tags")
model_to_update.tags = (
[Tags(name=tag_name) for tag_name in prev_tags] if prev_tags else []
)
if "tags" in metadata:
existing_tags = {tag.name: tag for tag in Tags.query.all()}
updated_tags = []
for tag_name in metadata["tags"]:
if tag_name in existing_tags:
updated_tags.append(existing_tags[tag_name])
else:
new_tag = Tags(name=tag_name)
db.session.add(new_tag)
updated_tags.append(new_tag)
model_to_update.tags = updated_tags

db.session.commit()

Expand Down
2 changes: 1 addition & 1 deletion back-end/utils/model_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def construct_metadata_4_save(metadata, code_path, weight_path, model):
"predefined": bool(int(metadata.get("predefined"))),
"pretrained": bool(int(metadata.get("pretrained"))),
"description": metadata.get("description"),
"tags": metadata.get("tags"),
"tags": metadata.get("tags", []),
"create_time": datetime.now(),
"code_path": code_path,
"weight_path": weight_path,
Expand Down
Binary file added front-end/cypress/downloads/SimpleCNN.pth
Binary file not shown.
49 changes: 49 additions & 0 deletions front-end/cypress/downloads/SimpleCNN.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import torch
import torch.nn as nn


class SimpleCNN(nn.Module):
def __init__(self):
super(SimpleCNN, self).__init__()

# Convolutional layers
self.conv1 = nn.Conv2d(in_channels=3, out_channels=16, kernel_size=3, stride=1, padding=1)
self.conv2 = nn.Conv2d(in_channels=16, out_channels=32, kernel_size=3, stride=1, padding=1)

# Activation and pooling
self.relu = nn.ReLU()
self.pool = nn.MaxPool2d(kernel_size=2, stride=2, padding=0)

# Fully connected layers
self.fc1 = nn.Linear(32 * 8 * 8, 128) # after two pooling operations, 32x32 becomes 8x8
self.fc2 = nn.Linear(128, 9) # for 9 output classes

def forward(self, x):
# First convolutional layer followed by activation and pooling
x = self.conv1(x)
x = self.relu(x)
x = self.pool(x)

# Second convolutional layer followed by activation and pooling
x = self.conv2(x)
x = self.relu(x)
x = self.pool(x)

# Flatten the tensor
x = x.view(-1, 32 * 8 * 8)

# First fully connected layer followed by activation
x = self.fc1(x)
x = self.relu(x)

# Second fully connected layer to produce the final output
x = self.fc2(x)

return x


if __name__ == "__main__":
model = SimpleCNN()

# Save the model checkpoint
torch.save(model.state_dict(), "./SimpleCNN.pth")
96 changes: 96 additions & 0 deletions front-end/cypress/tests/components/train_model.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
describe('The Model Training Page', () => {
beforeEach(() => {
cy.visit('model');
});

it('can have current model after selecting', () => {
cy.get('tr:nth-child(1)').find('td').eq(10).within(() => {
cy.get('[data-test=train-model-edit-model]').click({ force: true });
})
cy.getBySel('train-model-set-current-model').click();
cy.wait(1000);
cy.getBySel('train-model-current-model-create-time').should('not.be.empty');
cy.getBySel('train-model-current-model-achitecture').should('not.be.empty');

});

it('can go to the train page after having current model', () => {
cy.get('tr:nth-child(1)').find('td').eq(10).within(() => {
cy.get('[data-test=train-model-edit-model]').click({ force: true });
});
cy.get('[data-test=train-model-set-current-model]').click();
cy.wait(1000);
cy.get('[data-test=train-model-edit-model-cancel]').click();
cy.get('[data-test=train-model-train-model-button]').click();
cy.url().should('contains', 'train');
});

it('can edit model', () => {
cy.get('tr:nth-child(1)').find('td').eq(10).within(() => {
cy.get('[data-test=train-model-edit-model]').click({ force: true });
});

cy.get('[data-test=train-model-edit-model-description]').clear().type("test123");
cy.get('[data-test=train-model-edit-model-cancel]').click();

cy.get('tr:nth-child(1)').find('td').eq(10).within(() => {
cy.get('[data-test=train-model-edit-model]').click({ force: true });
});
cy.get('[data-test=train-model-edit-model-description]').invoke('val').should('not.contain', 'test123');
cy.get('tr:nth-child(1)').find('td').eq(10).within(() => {
cy.get('[data-test=train-model-edit-model]').click({ force: true });
});

cy.get('[data-test=train-model-edit-model-description]').clear().type("test");
cy.get('[data-test=train-model-edit-model-confirm]').click();
cy.get('tr:nth-child(1)').find('td').eq(10).within(() => {
cy.get('[data-test=train-model-edit-model]').click({ force: true });
});
cy.get('[data-test=train-model-edit-model-description]').invoke('val').should('contain', 'test');
});

it('can duplicate model', () => {
cy.get('tr:nth-child(1)').find('td').eq(10).within(() => {
cy.get('[data-test=train-model-duplicate-model]').click();
cy.wait(1000);
});
cy.get('tr').should('have.length', 3);
});


it('can delete model', () => {
cy.get('tr:nth-child(1)').find('td').eq(10).within(() => {
cy.get('[data-test=train-model-delete-model]').click();
});

cy.get('[data-test=train-model-delete-model-confirm]').click();
cy.wait(1000);
cy.get('tr').should('have.length', 2);

});



it('can upload model', () => {
cy.contains('.v-btn', 'Upload New Model').click();
cy.get('[data-test=model-upload-nickname]').type("SimpleCNN");
cy.get('[data-test=model-upload-classname]').type("SimpleCNN");
cy.get('[data-test=model-upload-codefile]').selectFile('cypress/downloads/SimpleCNN.py', { force: true });
cy.get('[data-test=model-upload-submit-button]').click();
cy.get('tr').should('have.length', 3);


});


it('can edit model name', () => {
cy.get('tr:nth-child(1)').find('td').eq(10).within(() => {
cy.get('[data-test=train-model-edit-model]').click({ force: true });
});

cy.get('[data-test=train-model-edit-model-name]').clear().type("test");
cy.get('[data-test=train-model-edit-model-confirm]').click();

cy.get('[data-test=train-model-edit-model-name]').invoke('val').should('contain', 'test');
});
});
145 changes: 32 additions & 113 deletions front-end/packages/robustar/src/components/ModelUploader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,136 +14,50 @@

<v-form ref="form" lazy-validation class="pa-4">
<div class="d-flex justify-space-between">
<v-text-field
v-model="nickname"
:rules="[rules.required]"
:loading="isSubmitting"
label="Nickname"
hint=""
outlined
clearable
dense
class="mr-4"
></v-text-field>
<v-select
v-if="predefined"
v-model="className"
:rules="[rules.required]"
:loading="isSubmitting"
:items="modelClasses"
label="Class Name"
hint=""
outlined
dense
></v-select>
<v-text-field
v-else
v-model="className"
:rules="[rules.required]"
:loading="isSubmitting"
label="Class Name"
hint=""
outlined
clearable
dense
></v-text-field>
<v-text-field v-model="nickname" :rules="[rules.required]" :loading="isSubmitting" label="Nickname" hint=""
outlined clearable dense class="mr-4" data-test="model-upload-nickname"></v-text-field>
<v-select v-if="predefined" v-model="className" :rules="[rules.required]" :loading="isSubmitting"
:items="modelClasses" label="Class Name" hint="" outlined @change="addModelClassAsTag"></v-select>
<v-text-field v-else v-model="className" :rules="[rules.required]" :loading="isSubmitting" label="Class Name"
hint="" outlined clearable dense data-test="model-upload-classname"></v-text-field>
</div>
<v-combobox
v-model="tags"
:loading="isSubmitting"
label="Tags"
multiple
chips
clearable
dense
small-chips
outlined
></v-combobox>
<v-textarea
v-model="description"
:loading="isSubmitting"
rows="1"
label="Description"
hint=""
auto-grow
outlined
clearable
dense
></v-textarea>
<v-checkbox
v-model="predefined"
label="use predefined"
dense
class="d-inline-block mr-8"
></v-checkbox>
<v-checkbox
v-if="predefined"
v-model="pretrained"
label="is model pretrained"
dense
class="d-inline-block"
></v-checkbox>
<v-combobox v-model="tags" :loading="isSubmitting" label="Tags" multiple chips clearable dense small-chips
outlined></v-combobox>
<v-textarea v-model="description" :loading="isSubmitting" rows="1" label="Description" hint="" auto-grow outlined
clearable dense></v-textarea>
<v-checkbox v-model="predefined" label="use predefined" dense class="d-inline-block mr-8"></v-checkbox>
<v-checkbox v-if="predefined" v-model="pretrained" label="is model pretrained" dense
class="d-inline-block"></v-checkbox>
<div v-if="!predefined">
<v-file-input
v-model="weightFile"
:loading="isSubmitting"
prepend-icon="mdi-file-outline"
chips
clearable
dense
filled
show-size
label="Weight File (optional)"
hint="choose file"
></v-file-input>
<v-file-input
v-model="codeFile"
:rules="[rules.required]"
:loading="isSubmitting"
@change="handleCodeFileUpload"
prepend-icon="mdi-file-outline"
chips
clearable
dense
filled
show-size
label="Code File"
hint="choose file"
></v-file-input>
<v-textarea
v-model="code"
:rules="[rules.required]"
:loading="isSubmitting"
prepend-icon="mdi-xml"
label="Code"
hint="The final code uploaded will be based on the content in this code editor."
rows="5"
filled
clearable
dense
style="font-family: monospace"
></v-textarea>
<v-file-input v-model="weightFile" :loading="isSubmitting" prepend-icon="mdi-file-outline" chips clearable dense
filled show-size label="Weight File (optional)" hint="choose file"></v-file-input>
<v-file-input v-model="codeFile" :rules="[rules.required]" :loading="isSubmitting"
@change="handleCodeFileUpload" prepend-icon="mdi-file-outline" chips clearable dense filled show-size
label="Code File" hint="choose file" data-test="model-upload-codefile"></v-file-input>
<v-textarea v-model="code" :rules="[rules.required]" :loading="isSubmitting" prepend-icon="mdi-xml" label="Code"
hint="The final code uploaded will be based on the content in this code editor." rows="5" filled clearable
dense style="font-family: monospace"></v-textarea>
</div>
</v-form>

<v-divider></v-divider>

<v-card-actions class="d-flex flex-column align-start py-8">
<div>
<v-btn :loading="isSubmitting" depressed color="primary" class="mr-4" @click="submit">
<v-btn :loading="isSubmitting" depressed color="primary" class="mr-4" @click="submit"
data-test="model-upload-submit-button">
Submit
</v-btn>
<v-btn :loading="isSubmitting" depressed @click="reset"> Reset </v-btn>
</div>
<div v-if="status">
<div class="mb-2 mt-4">
Status: <span class="orange--text">validating</span
><span class="green--text">success</span><span class="red--text">fail</span>
Status: <span class="orange--text">validating</span><span class="green--text">success</span><span
class="red--text">fail</span>
</div>
<div>Feedback</div>
<code class="d-block overflow-auto pa-3" style="max-height: 200px"
>print("hello world")
</code>
<code class="d-block overflow-auto pa-3" style="max-height: 200px">print("hello world")
</code>
</div>
</v-card-actions>
</v-card>
Expand Down Expand Up @@ -215,6 +129,11 @@ export default {
this.$root.alert('error', 'Failed to read file');
};
},
addModelClassAsTag() {
if (this.predefined && this.className && !this.tags.includes(this.className)) {
this.tags.push("predefined-"+this.className);
}
},
async submit() {
if (this.$refs.form.validate()) {
this.isSubmitting = true;
Expand Down
Loading