@@ -146,6 +146,19 @@ function OpToNodes(nodes: Node[]): Record<string, string[]> {
146146 return opToNodes
147147}
148148
149+ function OpToLib ( nodes : Node [ ] ) : Record < string , string > {
150+ const opToLib : Record < string , string > = { }
151+
152+ for ( const node of nodes ) {
153+ for ( const [ lib , ops ] of Object . entries ( node . data . loaded_libs ) ) {
154+ for ( const op of ops ) {
155+ opToLib [ op ] = lib ;
156+ }
157+ }
158+ }
159+ return opToLib ;
160+ }
161+
149162export default function JobRunner ( { nodes } : DialogDemoProps ) {
150163 const [ selectedOp , setSelectedOp ] = useState < string | null > ( null ) ;
151164 const [ selectedNode , setSelectedNode ] = useState < string | null > ( null ) ;
@@ -157,8 +170,14 @@ export default function JobRunner({ nodes }: DialogDemoProps) {
157170 const [ isJsonValid , setIsJsonValid ] = useState < boolean > ( true ) ;
158171
159172 const opToNodes = OpToNodes ( nodes ) ;
173+ const opToLib = OpToLib ( nodes ) ;
160174 const allOps = Object . keys ( opToNodes ) ;
161- const nodesForOp = selectedOp ? opToNodes [ selectedOp ] ?? [ ] : [ ]
175+ const nodesForOp = selectedOp ? opToNodes [ selectedOp ] ?? [ ] : [ ] ;
176+
177+ let jc = new JobController ( placement ) ;
178+ for ( const node of nodes ) {
179+ jc . registerNode ( node . hostname , node . hostname , node . port ) ;
180+ }
162181
163182 const handlePlace = ( ) => {
164183 if ( ! selectedOp ) {
@@ -204,16 +223,16 @@ export default function JobRunner({ nodes }: DialogDemoProps) {
204223 setPlacement ( newPlacement ) ;
205224 } ;
206225
207- const handleDeploy = ( ) => {
208- let jc = new JobController ( placement ) ;
209- jc . startJob ( [ ... placement . get_actors ( ) ] ) ;
226+ const handleDeploy = ( ) => {
227+ jc . startJob ( [ ... placement . get_ops ( opToLib ) ] ) ;
228+ toast . success ( "Job Deployed sucessfully" ) ;
210229 } ;
211230
212231 return (
213232 < Sheet >
214233 < Toaster position = "top-center" richColors />
215234 < SheetTrigger asChild >
216- < Button onClick = { handleDeploy } > Deploy Job</ Button >
235+ < Button > Deploy Job</ Button >
217236 </ SheetTrigger >
218237 < SheetContent className = "w-[1000px] sm:w-[1000px]" >
219238 < SheetHeader >
@@ -295,7 +314,7 @@ export default function JobRunner({ nodes }: DialogDemoProps) {
295314 < SheetFooter >
296315 < Button variant = "secondary" > Load</ Button >
297316 < Button variant = "secondary" > Save changes</ Button >
298- < Button type = "submit" > Deploy</ Button >
317+ < Button type = "submit" onClick = { handleDeploy } > Deploy</ Button >
299318 < SheetClose asChild >
300319 < Button variant = "outline" > Close</ Button >
301320 </ SheetClose >
0 commit comments