Skip to content

Commit 6a1873f

Browse files
committed
load model event
1 parent 372fdef commit 6a1873f

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package fsm
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
pb "github.com/seldonio/seldon-core/apis/go/v2/mlops/scheduler"
8+
)
9+
10+
// Concrete event types
11+
type LoadModelEvent struct {
12+
Request *pb.LoadModelRequest
13+
}
14+
15+
func (e *LoadModelEvent) Type() EventType {
16+
return EventTypeUnloadModel
17+
}
18+
19+
func (e *LoadModelEvent) Marshal() ([]byte, error) {
20+
// TODO: implement proto marshaling
21+
return nil, fmt.Errorf("not implemented")
22+
}
23+
24+
type LoadModelEventHandler struct {
25+
store KVStore
26+
}
27+
28+
func NewLoadModelEventHandler(store KVStore) *LoadModelEventHandler {
29+
return &LoadModelEventHandler{store: store}
30+
}
31+
32+
// Handle implementations (business logic goes here)
33+
func (e *LoadModelEventHandler) Handle(ctx context.Context, event Event) ([]OutputEvent, error) {
34+
loadEvent, ok := event.(*LoadModelEvent)
35+
if !ok {
36+
return nil, fmt.Errorf("invalid event type")
37+
}
38+
39+
// save new model to storage if new
40+
41+
// if not new update model storage
42+
43+
// generate model event status for other services to ingest
44+
45+
// schedule model into server
46+
47+
// retrieve servers and their models
48+
49+
// filter out the server
50+
51+
// find a suitable server to schedule
52+
53+
// generate agent schedule event
54+
55+
// generate event to update pipeline status if pipeline is affected by model
56+
57+
/*
58+
Errors:
59+
- event validation failed
60+
Events
61+
- Model Event Message (currently used to maintain replicated store in Agent and to update downstream)
62+
- status with failed scheduling due to replicas and server
63+
- normal status created
64+
- Load Model (for Agent)
65+
- Server Scale UP
66+
- server Scale Down
67+
- Unload Model versions
68+
-
69+
70+
*/
71+
72+
// TODO: Implement business logic
73+
// - Validate request
74+
// - Update model state in KVStore
75+
// - Generate output events (e.g., "ModelLoadStarted", "NotifyServer", etc.)
76+
77+
_ = loadEvent // use the event
78+
79+
return []OutputEvent{}, nil
80+
}

0 commit comments

Comments
 (0)