Skip to content

Commit 337af9e

Browse files
Feature: Edit existing model servers from UI (#114)
* Feat: Added model edit feature through UI (#14) * Implement editing model servers (#13) * Added Model Edit feature * fix: apply prettier formatting Signed-off-by: LogicalGuy77 <harshitacademia@gmail.com> Co-authored-by: Mark Winter <mark.winter@navercorp.com> Signed-off-by: LogicalGuy77 <harshitacademia@gmail.com> * refactored edit-component styles Signed-off-by: LogicalGuy77 <harshitacademia@gmail.com> * chore: cleaned up code Signed-off-by: LogicalGuy77 <harshitacademia@gmail.com> --------- Signed-off-by: LogicalGuy77 <harshitacademia@gmail.com> Co-authored-by: Mark Winter <mark.winter@navercorp.com>
1 parent a304046 commit 337af9e

File tree

16 files changed

+475
-4
lines changed

16 files changed

+475
-4
lines changed

backend/apps/v1beta1/routes/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
bp = Blueprint("default_routes", __name__)
55

6-
from . import post # noqa: F401, E402
6+
from . import post, put # noqa: F401, E402

backend/apps/v1beta1/routes/put.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from flask import request
2+
3+
from kubeflow.kubeflow.crud_backend import api, decorators, logging
4+
5+
from ...common import versions
6+
from . import bp
7+
8+
log = logging.getLogger(__name__)
9+
10+
11+
@bp.route("/api/namespaces/<namespace>/inferenceservices/<isvc>",
12+
methods=["PUT"])
13+
@decorators.request_is_json_type
14+
@decorators.required_body_params("apiVersion", "kind", "metadata", "spec")
15+
def replace_inference_service(namespace: str, isvc: str):
16+
gvk = versions.inference_service_gvk()
17+
api.authz.ensure_authorized(
18+
"update",
19+
group=gvk["group"],
20+
version=gvk["version"],
21+
resource=gvk["kind"],
22+
namespace=namespace,
23+
)
24+
25+
cr = request.get_json()
26+
27+
api.custom_api.replace_namespaced_custom_object(
28+
group=gvk["group"],
29+
version=gvk["version"],
30+
plural=gvk["kind"],
31+
namespace=namespace,
32+
name=isvc,
33+
body=cr)
34+
35+
return api.success_response(
36+
"message",
37+
"InferenceService successfully updated"
38+
)

frontend/COMMIT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
78969ee
1+
78969ee

frontend/angular.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
"glob": "**/*",
4040
"input": "node_modules/monaco-editor",
4141
"output": "assets/monaco-editor"
42+
},
43+
{
44+
"glob": "**/*",
45+
"input": "node_modules/ace-builds/src-min-noconflict",
46+
"output": "assets/ace-builds"
4247
}
4348
],
4449
"styles": ["src/styles.scss"],

frontend/package-lock.json

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@
3838
"@fortawesome/free-brands-svg-icons": "^5.15.4",
3939
"@fortawesome/free-solid-svg-icons": "^5.15.4",
4040
"@kubernetes/client-node": "^0.17.0",
41+
"ace-builds": "^1.40.0",
4142
"date-fns": "^1.29.0",
4243
"js-yaml": "^4.1.0",
4344
"lodash": "^4.17.21",
4445
"lodash-es": "^4.17.21",
4546
"material-icons": "^1.10.8",
4647
"monaco-editor": "^0.33.0",
48+
"ngx-ace-wrapper": "^14.0.0",
4749
"rxjs": "~7.5.6",
4850
"tslib": "^2.4.0",
4951
"zone.js": "~0.11.5"
@@ -72,6 +74,7 @@
7274
"karma-coverage-istanbul-reporter": "~3.0.3",
7375
"karma-jasmine": "~5.1.0",
7476
"karma-jasmine-html-reporter": "^2.0.0",
77+
"prettier": "^2.8.8",
7578
"protractor": "~7.0.0",
7679
"ts-node": "~10.9.1",
7780
"typescript": "~4.8.0"

frontend/src/app/ace-config.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as ace from 'ace-builds';
2+
3+
export function configureAce() {
4+
return () => {
5+
try {
6+
const basePath = '/assets/ace-builds';
7+
ace.config.set('basePath', basePath);
8+
ace.config.set('modePath', basePath);
9+
ace.config.set('themePath', basePath);
10+
ace.config.set('workerPath', basePath);
11+
12+
console.log('[Debug] ACE editor configuration completed');
13+
return Promise.resolve();
14+
} catch (error) {
15+
console.error('[Debug] ACE editor configuration failed:', error);
16+
return Promise.reject(error);
17+
}
18+
};
19+
}

frontend/src/app/app.module.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { BrowserModule } from '@angular/platform-browser';
2-
import { NgModule } from '@angular/core';
2+
import { NgModule, APP_INITIALIZER } from '@angular/core';
3+
import { configureAce } from './ace-config';
34

45
import { AppRoutingModule } from './app-routing.module';
56
import { AppComponent } from './app.component';
@@ -33,6 +34,11 @@ const MwaSnackBarConfig: MatSnackBarConfig = {
3334
],
3435
providers: [
3536
{ provide: MAT_SNACK_BAR_DEFAULT_OPTIONS, useValue: MwaSnackBarConfig },
37+
{
38+
provide: APP_INITIALIZER,
39+
useFactory: () => configureAce,
40+
multi: true,
41+
},
3642
],
3743
bootstrap: [AppComponent],
3844
})
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<div class="edit-component">
2+
<div
3+
#editorWrapper
4+
style="border: 1px solid #ccc"
5+
[style.width]="editorStyle.width"
6+
[style.height]="editorStyle.height"
7+
[style.fontSize]="editorStyle.fontSize"
8+
></div>
9+
10+
<div style="margin-top: 10px">
11+
<button
12+
mat-raised-button
13+
color="primary"
14+
(click)="submit()"
15+
[disabled]="applying"
16+
>
17+
<mat-spinner
18+
*ngIf="applying"
19+
diameter="20"
20+
style="display: inline-block; margin-right: 5px"
21+
></mat-spinner>
22+
Submit
23+
</button>
24+
<button
25+
mat-stroked-button
26+
(click)="cancelEdit.emit(true)"
27+
[disabled]="applying"
28+
style="margin-left: 10px"
29+
>
30+
Cancel
31+
</button>
32+
</div>
33+
</div>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
ace {
2+
display: block;
3+
border: 1px solid #e0e0e0;
4+
width: 100%;
5+
}
6+
7+
.edit-component {
8+
margin-top: 1rem;
9+
10+
button[mat-raised-button][color='primary'] {
11+
background-color: #1976d2;
12+
color: white;
13+
}
14+
}
15+
16+
.waiting-button-wrapper {
17+
display: flex;
18+
}
19+
20+
.waiting-button-wrapper .mat-spinner {
21+
margin: auto 0.2rem;
22+
}

0 commit comments

Comments
 (0)