-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTesters.py
2561 lines (1987 loc) · 99.2 KB
/
Testers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import json
import random
import time
import uuid
import os
import urllib.request
from pycrescolib.utils import compress_param, decompress_param, get_jar_info
from pathlib import Path
def get_plugin_from_git(src_url, force=False):
dst_file = src_url.rsplit('/', 1)[1]
dst_path = 'plugins/' + dst_file
# create location to store downloaded plugins
if not os.path.exists('plugins'):
os.makedirs('plugins')
if force:
urllib.request.urlretrieve(src_url, dst_path)
else:
if not os.path.exists(dst_path):
print('Downloading ' + dst_path + ' plugin')
urllib.request.urlretrieve(src_url, dst_path)
return dst_path
def filerepo_deploy_single_node(client, dst_region, dst_agent):
#wait if client is not connected
while not client.connected():
print('Waiting on client connection')
time.sleep(10)
client.connect()
if client.agents.is_controller_active(dst_region, dst_agent):
# An optional custom logger callback
def logger_callback(n):
print("Custom logger callback Message = " + str(n))
# Optionally connect to the agent logger stream
log = client.get_logstreamer(logger_callback)
log.connect()
# Enable logging stream, this needs work, should be selectable via class and level
log.update_config(dst_region, dst_agent)
print('Global Controller Status: ' + str(client.agents.get_controller_status(dst_region, dst_agent)))
#upload filerepo plugin to global controller
jar_file_path = get_plugin_from_git("https://github.com/CrescoEdge/filerepo/releases/download/1.1-SNAPSHOT/filerepo-1.1-SNAPSHOT.jar")
reply = client.globalcontroller.upload_plugin_global(jar_file_path)
print("upload status: " + str(reply))
print("plugin config: " + decompress_param(reply['configparams']))
# create unique file repo name
filerepo_name = str(uuid.uuid1())
# location to sync
src_repo_path = 'test_data/' + str(uuid.uuid1())
src_repo_path = os.path.abspath(src_repo_path)
os.makedirs(src_repo_path)
print('src_repo_path: ' + src_repo_path)
# location to store
dst_repo_path = 'test_data/' + str(uuid.uuid1())
dst_repo_path = os.path.abspath(dst_repo_path)
os.makedirs(dst_repo_path)
print('dst_repo_path: ' + dst_repo_path)
# create files to replicate
for i in range(20):
Path(src_repo_path + '/' + str(i)).touch()
# describe the dataplane query allowing python client to listen in on filerepo communications
# this is not needed, but lets us see what is being communicated by the plugins
stream_query = "filerepo_name='" + filerepo_name + "' AND broadcast"
print('Client stream query ' + stream_query)
# create a dataplane listener for incoming data
# example of an (optional) custom callback to process incoming data from the dataframe
def dp_callback(n):
n = json.loads(n)
print("Custom DP callback Message = " + str(n))
print("Custom DP callback Message Type = " + str(type(n)))
print('Connecting to DP')
dp = client.get_dataplane(stream_query,dp_callback)
# connect the listener
dp.connect()
# node 0 : file repo sender configuration
# Use base configparams (plugin_name, md5, etc.) that were extracted during plugin upload
configparams = json.loads(decompress_param(reply['configparams']))
cadl = dict()
cadl['pipeline_id'] = '0'
cadl['pipeline_name'] = str(uuid.uuid1())
cadl['nodes'] = []
cadl['edges'] = []
params0 = dict()
# Add plugin information
params0['pluginname'] = configparams['pluginname']
params0['md5'] = configparams['md5']
params0['version'] = configparams['version']
# Add location information
params0["location_region"] = dst_region
params0["location_agent"] = dst_agent
# Add repo name, which is used in the broadcast of state
params0["filerepo_name"] = filerepo_name
# Add scan_dir config telling filerepo to be a sender, and sync our local repo
params0["scan_dir"] = src_repo_path
node0 = dict()
node0['type'] = 'dummy'
node0['node_name'] = 'SRC Plugin'
node0['node_id'] = 0
node0['isSource'] = False
node0['workloadUtil'] = 0
node0['params'] = params0
params1 = dict()
# Add plugin information
params1['pluginname'] = configparams['pluginname']
params1['md5'] = configparams['md5']
params1['version'] = configparams['version']
# Add location information
params1["location_region"] = dst_region
params1["location_agent"] = dst_agent
# Add repo name, which is used in the broadcast of state
params1["filerepo_name"] = filerepo_name
# Add repo_dir config telling filerepo to recv
params1["repo_dir"] = dst_repo_path
node1 = dict()
node1['type'] = 'dummy'
node1['node_name'] = 'DST Plugin'
node1['node_id'] = 1
node1['isSource'] = False
node1['workloadUtil'] = 0
node1['params'] = params1
edge0 = dict()
edge0['edge_id'] = 0
edge0['node_from'] = 0
edge0['node_to'] = 1
edge0['params'] = dict()
cadl['nodes'].append(node0)
cadl['nodes'].append(node1)
cadl['edges'].append(edge0)
# Push config and start sending repo plugin
reply = client.globalcontroller.submit_pipeline(cadl)
# name of pipeline remove when finished
print('Status of filerepo pipeline submit: ' + str(reply))
pipeline_id = reply['gpipeline_id']
while client.globalcontroller.get_pipeline_status(pipeline_id) != 10:
print('waiting for pipeline_id: ' + pipeline_id + ' to come online')
time.sleep(2)
# wait for sync
for i in range(20):
time.sleep(1)
# remove the pipeline
client.globalcontroller.remove_pipeline(pipeline_id)
while client.globalcontroller.get_pipeline_status(pipeline_id) == 10:
print('waiting for pipeline_id: ' + pipeline_id + ' to shutdown')
time.sleep(1)
def executor_deploy_single_node_plugin(client, dst_region, dst_agent):
#wait if client is not connected
while not client.connected():
print('Waiting on client connection')
time.sleep(10)
client.connect()
if client.agents.is_controller_active(dst_region, dst_agent):
# An optional custom logger callback
def logger_callback(n):
print("Custom logger callback Message = " + str(n))
# Optionally connect to the agent logger stream
#log = client.get_logstreamer(logger_callback)
#log.connect()
# Enable logging stream, this needs work, should be selectable via class and level
#log.update_config(dst_region, dst_agent)
print('Global Controller Status: ' + str(client.agents.get_controller_status(dst_region, dst_agent)))
#upload filerepo plugin to global controller
jar_file_path = get_plugin_from_git("https://github.com/CrescoEdge/executor/releases/download/1.1-SNAPSHOT/executor-1.1-SNAPSHOT.jar")
reply = client.globalcontroller.upload_plugin_global(jar_file_path)
print("upload status: " + str(reply))
print("plugin config: " + decompress_param(reply['configparams']))
stream_name = str(uuid.uuid1()) #this will be used to get input back from the dataplane
# describe the dataplane query allowing python client to listen in on filerepo communications
# this is not needed, but lets us see what is being communicated by the plugins
stream_query = "stream_name='" + stream_name + "'"
print('Client stream query ' + stream_query)
# create a dataplane listener for incoming data
# example of an (optional) custom callback to write executor output to a file
def dp_callback(n):
print("Custom DP callback Message = " + str(n))
#print('Connecting to DP')
#dp = client.get_dataplane(stream_query,dp_callback)
# connect the listener
#dp.connect()
# node 0 : file repo sender configuration
# Use base configparams (plugin_name, md5, etc.) that were extracted during plugin upload
configparams = json.loads(decompress_param(reply['configparams']))
plugin_count = 10000
plugin_list = []
for x in range(plugin_count):
reply = client.agents.add_plugin_agent(dst_region, dst_agent, configparams, None)
plugin_id = reply['pluginid']
plugin_list.append(plugin_id)
print('Status of executor plugin submit: ' + str(x) + ' ' + str(reply))
while not client.agents.status_plugin_agent(dst_region, dst_agent, plugin_id)['isactive']:
print('waiting for plugin_id: ' + plugin_id + ' to come online')
time.sleep(2)
'''
for plugin_id in plugin_list:
# this code makes use of a global message to find a specific plugin type, then send a message to that plugin
# send a config message to setup the config of the executor
message_event_type = 'CONFIG'
message_payload = dict()
message_payload['action'] = 'config_process'
message_payload['stream_name'] = stream_name
#adjust for windows vs linux
message_payload['command'] = 'ls -la'
result = client.messaging.global_plugin_msgevent(True, message_event_type, message_payload, dst_region, dst_agent, plugin_id)
print(result)
print('config status: ' + str(result['config_status']))
# Now send a message to start the process
message_payload['action'] = 'start_process'
message_payload['stream_name'] = stream_name
result = client.messaging.global_plugin_msgevent(True, message_event_type, message_payload, dst_region,
dst_agent, plugin_id)
print('start status: ' + str(result['start_status']))
# the process might have already ended, but this is also used to cleanup the task
message_payload['action'] = 'end_process'
message_payload['stream_name'] = stream_name
result = client.messaging.global_plugin_msgevent(True, message_event_type, message_payload, dst_region,
dst_agent, plugin_id)
print('end status: ' + str(result['end_status']))
'''
for plugin_id in plugin_list:
reply = client.agents.remove_plugin_agent(dst_region, dst_agent, plugin_id)
print(reply)
#print(client.agents.status_plugin_agent(dst_region, dst_agent, plugin_id))
def executor_deploy_single_node_pipeline(client, dst_region, dst_agent):
#wait if client is not connected
while not client.connected():
print('Waiting on client connection')
time.sleep(10)
client.connect()
if client.agents.is_controller_active(dst_region, dst_agent):
# An optional custom logger callback
def logger_callback(n):
print("Custom logger callback Message = " + str(n))
# Optionally connect to the agent logger stream
log = client.get_logstreamer(logger_callback)
log.connect()
# Enable logging stream, this needs work, should be selectable via class and level
log.update_config(dst_region, dst_agent)
print('Global Controller Status: ' + str(client.agents.get_controller_status(dst_region, dst_agent)))
#upload filerepo plugin to global controller
jar_file_path = get_plugin_from_git("https://github.com/CrescoEdge/executor/releases/download/1.1-SNAPSHOT/executor-1.1-SNAPSHOT.jar")
reply = client.globalcontroller.upload_plugin_global(jar_file_path)
print("upload status: " + str(reply))
print("plugin config: " + decompress_param(reply['configparams']))
stream_name = str(uuid.uuid1()) #this will be used to get input back from the dataplane
# describe the dataplane query allowing python client to listen in on filerepo communications
# this is not needed, but lets us see what is being communicated by the plugins
stream_query = "stream_name='" + stream_name + "'"
print('Client stream query ' + stream_query)
# create a dataplane listener for incoming data
# example of an (optional) custom callback to write executor output to a file
def dp_callback(n):
print("Custom DP callback Message = " + str(n))
print('Connecting to DP')
dp = client.get_dataplane(stream_query,dp_callback)
# connect the listener
dp.connect()
# node 0 : file repo sender configuration
# Use base configparams (plugin_name, md5, etc.) that were extracted during plugin upload
configparams = json.loads(decompress_param(reply['configparams']))
cadl = dict()
cadl['pipeline_id'] = '0'
cadl['pipeline_name'] = str(uuid.uuid1())
cadl['nodes'] = []
cadl['edges'] = []
params0 = dict()
# Add plugin information
params0['pluginname'] = configparams['pluginname']
params0['md5'] = configparams['md5']
params0['version'] = configparams['version']
# Add location information
params0["location_region"] = dst_region
params0["location_agent"] = dst_agent
# We can configure the plugin to run a job on startup, but in this case we will send several commands interactivly
# Add name of stream for subscription
#params0["stream_name"] = stream_name
# Add scan_dir config telling filerepo to be a sender, and sync our local repo
#params0["command"] = "ls -la"
node0 = dict()
node0['type'] = 'dummy'
node0['node_name'] = 'SRC Plugin'
node0['node_id'] = 0
node0['isSource'] = False
node0['workloadUtil'] = 0
node0['params'] = params0
edge0 = dict()
cadl['nodes'].append(node0)
#cadl['edges'].append(edge0)
# Push config and start executor plugin
reply = client.globalcontroller.submit_pipeline(cadl)
# name of pipeline remove when finished
print('Status of executor pipeline submit: ' + str(reply))
pipeline_id = reply['gpipeline_id']
while client.globalcontroller.get_pipeline_status(pipeline_id) != 10:
print('waiting for pipeline_id: ' + pipeline_id + ' to come online')
time.sleep(2)
#get the plugin_id of the executor plugin
executor_plugin_id = client.globalcontroller.get_pipeline_info(pipeline_id)['nodes'][0]['node_id']
# this code makes use of a global message to find a specific plugin type, then send a message to that plugin
# send a config message to setup the config of the executor
message_event_type = 'CONFIG'
message_payload = dict()
message_payload['action'] = 'config_process'
message_payload['stream_name'] = stream_name
#adjust for windows vs linux
message_payload['command'] = 'ls -la'
result = client.messaging.global_plugin_msgevent(True, message_event_type, message_payload, dst_region, dst_agent, executor_plugin_id)
print(result)
print('config status: ' + str(result['config_status']))
# Now send a message to start the process
message_payload['action'] = 'start_process'
message_payload['stream_name'] = stream_name
result = client.messaging.global_plugin_msgevent(True, message_event_type, message_payload, dst_region,
dst_agent, executor_plugin_id)
print('start status: ' + str(result['start_status']))
# the process might have already ended, but this is also used to cleanup the task
message_payload['action'] = 'end_process'
message_payload['stream_name'] = stream_name
result = client.messaging.global_plugin_msgevent(True, message_event_type, message_payload, dst_region,
dst_agent, executor_plugin_id)
print('end status: ' + str(result['end_status']))
# remove the pipeline
client.globalcontroller.remove_pipeline(pipeline_id)
while client.globalcontroller.get_pipeline_status(pipeline_id) == 10:
print('waiting for pipeline_id: ' + pipeline_id + ' to shutdown')
time.sleep(1)
def executor_deploy_single_node_plugin(client, dst_region, dst_agent):
#wait if client is not connected
while not client.connected():
print('Waiting on client connection')
time.sleep(10)
client.connect()
if client.agents.is_controller_active(dst_region, dst_agent):
# An optional custom logger callback
def logger_callback(n):
print("Custom logger callback Message = " + str(n))
# Optionally connect to the agent logger stream
#log = client.get_logstreamer(logger_callback)
#log.connect()
# Enable logging stream, this needs work, should be selectable via class and level
#log.update_config(dst_region, dst_agent)
print('Global Controller Status: ' + str(client.agents.get_controller_status(dst_region, dst_agent)))
#upload filerepo plugin to global controller
jar_file_path = get_plugin_from_git("https://github.com/CrescoEdge/executor/releases/download/1.1-SNAPSHOT/executor-1.1-SNAPSHOT.jar")
#jar_file_path = '/Users/cody/IdeaProjects/executor/target/executor-1.1-SNAPSHOT.jar'
reply = client.globalcontroller.upload_plugin_global(jar_file_path)
#print("upload status: " + str(reply))
#print("plugin config: " + decompress_param(reply['configparams']))
stream_name = str(uuid.uuid1()) #this will be used to get input back from the dataplane
# describe the dataplane query allowing python client to listen in on filerepo communications
# this is not needed, but lets us see what is being communicated by the plugins
stream_query = "stream_name='" + stream_name + "'"
print('Client stream query ' + stream_query)
# create a dataplane listener for incoming data
# example of an (optional) custom callback to write executor output to a file
def dp_callback(n):
print("Custom DP callback Message = " + str(n))
print('Connecting to DP')
dp = client.get_dataplane(stream_query,dp_callback)
print('Connecting to DP 1')
# connect the listener
dp.connect()
# node 0 : file repo sender configuration
# Use base configparams (plugin_name, md5, etc.) that were extracted during plugin upload
configparams = json.loads(decompress_param(reply['configparams']))
reply = client.agents.add_plugin_agent(dst_region, dst_agent, configparams, None)
print(reply)
executor_plugin_id = reply['pluginid']
while(client.agents.status_plugin_agent(dst_region,dst_agent,executor_plugin_id)['status_code'] != '10'):
print('waiting on startup')
time.sleep(1)
# this code makes use of a global message to find a specific plugin type, then send a message to that plugin
# send a config message to setup the config of the executor
message_event_type = 'CONFIG'
message_payload = dict()
message_payload['action'] = 'config_process'
message_payload['stream_name'] = stream_name
#adjust for windows vs linux
message_payload['command'] = 'dir "C:\\Users\\cornerstone"'
result = client.messaging.global_plugin_msgevent(True, message_event_type, message_payload, dst_region, dst_agent, executor_plugin_id)
print(result)
print('config status: ' + str(result['config_status']))
# Now send a message to start the process
message_payload['action'] = 'start_process'
message_payload['stream_name'] = stream_name
result = client.messaging.global_plugin_msgevent(True, message_event_type, message_payload, dst_region,
dst_agent, executor_plugin_id)
print('start status: ' + str(result['start_status']))
time.sleep(5)
# the process might have already ended, but this is also used to cleanup the task
message_payload['action'] = 'end_process'
message_payload['stream_name'] = stream_name
result = client.messaging.global_plugin_msgevent(True, message_event_type, message_payload, dst_region,
dst_agent, executor_plugin_id)
print(result)
print('end status: ' + str(result['end_status']))
# remove the pipeline
client.agents.remove_plugin_agent(dst_region,dst_agent,executor_plugin_id);
while (client.agents.status_plugin_agent(dst_region, dst_agent, executor_plugin_id)['status_code'] == '10'):
print('waiting on shutdown')
print(client.agents.status_plugin_agent(dst_region, dst_agent, executor_plugin_id)['status_code'])
time.sleep(1)
def aiapi_deploy_single_node_plugin(client, dst_region, dst_agent):
#wait if client is not connected
while not client.connected():
print('Waiting on client connection')
time.sleep(10)
client.connect()
if client.agents.is_controller_active(client.api.get_global_region(), client.api.get_global_agent()):
print('Global Controller Status: ' + str(client.agents.get_controller_status(client.api.get_global_region(), client.api.get_global_agent())))
jar_file_path = '/Users/cody/IdeaProjects/aiapi/target/aiapi-1.1-SNAPSHOT.jar'
#jar_file_path = '/Users/cody/IdeaProjects/executor/target/executor-1.1-SNAPSHOT.jar'
reply = client.globalcontroller.upload_plugin_global(jar_file_path)
print('upload plugin: ', reply)
#print("upload status: " + str(reply))
#print("plugin config: " + decompress_param(reply['configparams']))
# node 0 : file repo sender configuration
# Use base configparams (plugin_name, md5, etc.) that were extracted during plugin upload
configparams = json.loads(decompress_param(reply['configparams']))
print('Adding plugin to agent')
reply = client.agents.add_plugin_agent(dst_region, dst_agent, configparams, None)
print("Added plugin to agent: ", reply)
dst_plugin = reply['pluginid']
while(client.agents.status_plugin_agent(dst_region, dst_agent, dst_plugin)['status_code'] != '10'):
print('waiting on startup')
time.sleep(1)
print('plugin deployed')
time.sleep(2)
print('waiting')
#dst_region = 'global-region'
#dst_agent = 'inference_server'
#dst_plugin = 'plugin-b6255f1f-be67-403d-baa9-d404c468eead'
message_event_type = 'EXEC'
message_payload = dict()
message_payload['action'] = 'getllmadapter'
message_payload['s3_access_key'] = 'rHUYeAk58Ilhg6iUEFtr'
message_payload['s3_secret_key'] = 'IVimdW7BIQLq9PLyVpXzZUq8zS4nLfrsoiZSJanu'
message_payload['s3_url'] = 'http://localhost:9000'
message_payload['s3_bucket'] = 'llmadapters'
message_payload['s3_key'] = 'data/llm_factory_trainer/trainer_template_v0.efe93f27cbc844d78132a3994b6fe6a8/artifacts/adapter/custom_adapter.zip'
message_payload['local_path'] = 'efe93f27cbc844d78132a3994b6fe6a8.zip'
'''
paramList.add("s3_access_key");
paramList.add("s3_secret_key");
paramList.add("s3_url");
paramList.add("s3_bucket");
paramList.add("s3_key");
paramList.add("local_path");
'''
'''
message_event_type = 'EXEC'
message_payload = dict()
message_payload['action'] = 'getllmgenerate'
#message_payload['endpoint_url'] = 'http://10.10.10.55:8080'
message_payload['endpoint_url'] = 'http://10.10.10.55:8080'
message_payload['endpoint_payload'] = '{\"inputs\": "[INST] Natalia sold clips to 48 of her friends in April, and ' \
'then she sold half as many clips in May. How many clips did Natalia sell altogether ' \
'in April and May? [/INST]\",\"parameters\": {\"max_new_tokens\": 64}}'
'''
'''
message_event_type = 'EXEC'
message_payload = dict()
message_payload['action'] = 'getllm'
message_payload['endpoint_url'] = 'http://10.10.10.55:8080'
message_payload['input_text'] = 'Who does #2 work for?'
message_payload['max_tokens'] = 512
'''
print('location:', dst_region, dst_agent, dst_plugin)
print('payload:', message_payload)
reply = client.messaging.global_plugin_msgevent(True, message_event_type, message_payload, dst_region, dst_agent, dst_plugin)
print("RESPONSE:", reply)
#print('Output text:', reply['output_text'])
# print(reply)
# reply = json.loads(decompress_param(reply['plugin_status']))
# remove the pipeline
client.agents.remove_plugin_agent(dst_region, dst_agent, dst_plugin);
while (client.agents.status_plugin_agent(dst_region, dst_agent, dst_plugin)['status_code'] == '10'):
print('waiting on shutdown')
print(client.agents.status_plugin_agent(dst_region, dst_agent, dst_plugin)['status_code'])
time.sleep(1)
else:
print('BLAM')
def pathworker_executor_deploy_single_node_plugin(client, dst_region, dst_agent):
processmap = dict()
#wait if client is not connected
while not client.connected():
print('Waiting on client connection')
time.sleep(10)
client.connect()
if client.agents.is_controller_active(dst_region, dst_agent):
# An optional custom logger callback
def logger_callback(n):
print("Custom logger callback Message = " + str(n))
# Optionally connect to the agent logger stream
#log = client.get_logstreamer(logger_callback)
#log.connect()
#1.1.0.SNAPSHOT-2021-12-02T195342Z
#1.1.0.SNAPSHOT-2021-10-14T175814Z
# Enable logging stream, this needs work, should be selectable via class and level
#log.update_config(dst_region, dst_agent)
print('Global Controller Status: ' + str(client.agents.get_controller_status(dst_region, dst_agent)))
stream_name = str(uuid.uuid1()) #this will be used to get input back from the dataplane
# describe the dataplane query allowing python client to listen in on filerepo communications
# this is not needed, but lets us see what is being communicated by the plugins
stream_query = "stream_name='" + stream_name + "'"
print('Client stream query ' + stream_query)
# create a dataplane listener for incoming data
# example of an (optional) custom callback to write executor output to a file
def dp_callback(n):
try:
payload = json.loads(str(n))
print("json payload = " + str(payload))
except:
print("Custom DP callback Message = " + str(n))
print('Connecting to DP ' + stream_query)
dp = client.get_dataplane(stream_query, dp_callback)
# connect the listener
dp.connect()
# node 0 : file repo sender configuration
# Use base configparams (plugin_name, md5, etc.) that were extracted during plugin upload
#configparams = json.loads(decompress_param(reply['configparams']))
configparams = dict()
configparams['pluginname'] = 'io.cresco.executor'
configparams['version'] = '1.1.0.SNAPSHOT-2021-12-02T195342Z'
configparams['md5'] = '893deca0083ce5e301071577dccfdc9c'
print(configparams)
reply = client.agents.add_plugin_agent(dst_region, dst_agent, configparams, None)
print(reply)
executor_plugin_id = reply['pluginid']
while(client.agents.status_plugin_agent(dst_region,dst_agent,executor_plugin_id)['status_code'] != '10'):
print('waiting on startup')
time.sleep(1)
# this code makes use of a global message to find a specific plugin type, then send a message to that plugin
# send a config message to setup the config of the executor
message_event_type = 'CONFIG'
message_payload = dict()
message_payload['action'] = 'config_process'
message_payload['stream_name'] = stream_name
#adjust for windows vs linux
message_payload['command'] = 'cd /digitalpathprocessor/webapiclient; python3 client.py --test_mode=0'
#message_payload['command'] = 'cd /digitalpathprocessor/webapiclient; bash test.sh'
result = client.messaging.global_plugin_msgevent(True, message_event_type, message_payload, dst_region, dst_agent, executor_plugin_id)
print(result)
print('config status: ' + str(result['config_status']))
# Now send a message to start the process
message_payload['action'] = 'start_process'
message_payload['stream_name'] = stream_name
result = client.messaging.global_plugin_msgevent(True, message_event_type, message_payload, dst_region,
dst_agent, executor_plugin_id)
print('start status: ' + str(result['start_status']))
# the process might have already ended, but this is also used to cleanup the task
message_payload['action'] = 'status_process'
message_payload['stream_name'] = stream_name
result = client.messaging.global_plugin_msgevent(True, message_event_type, message_payload, dst_region,
dst_agent, executor_plugin_id)
print(result)
time.sleep(5)
result = client.messaging.global_plugin_msgevent(True, message_event_type, message_payload, dst_region,
dst_agent, executor_plugin_id)
print(result)
time.sleep(30)
# the process might have already ended, but this is also used to cleanup the task
message_payload['action'] = 'end_process'
message_payload['stream_name'] = stream_name
result = client.messaging.global_plugin_msgevent(True, message_event_type, message_payload, dst_region,
dst_agent, executor_plugin_id)
print(result)
print('end status: ' + str(result['end_status']))
# remove the pipeline
client.agents.remove_plugin_agent(dst_region,dst_agent,executor_plugin_id);
while (client.agents.status_plugin_agent(dst_region, dst_agent, executor_plugin_id)['status_code'] == '10'):
print('waiting on shutdown')
print(client.agents.status_plugin_agent(dst_region, dst_agent, executor_plugin_id)['status_code'])
time.sleep(1)
def interactive_executor_deploy_single_node_plugin(client, dst_region, dst_agent):
processmap = dict()
#wait if client is not connected
while not client.connected():
print('Waiting on client connection')
time.sleep(10)
client.connect()
if client.agents.is_controller_active(dst_region, dst_agent):
print('Global Controller Status: ' + str(client.agents.get_controller_status(dst_region, dst_agent)))
ident_key = 'stream_name'
ident_id = str(uuid.uuid1())
#stream_query = "stream_name='" + ident_id + "'"
config_dp = dict()
config_dp['ident_key'] = ident_key
config_dp['ident_id'] = ident_id
config_dp['io_type_key'] = 'type'
config_dp['output_id'] = 'output'
config_dp['input_id'] = 'input'
# example of an (optional) custom callback to write executor output to a file
def dp_callback(n):
try:
payload = json.loads(str(n))
print("json payload = " + str(payload))
except:
print(str(n))
print('Connecting to DP 0' + json.dumps(config_dp))
dp = client.get_dataplane(json.dumps(config_dp), dp_callback)
print('Connecting to DP 1' + json.dumps(config_dp))
# connect the listener
dp.connect()
print('Connecting to DP 2' + json.dumps(config_dp))
jar_file_path = '/Users/cody/IdeaProjects/executor/target/executor-1.1-SNAPSHOT.jar'
reply = client.globalcontroller.upload_plugin_global(jar_file_path)
configparams = json.loads(decompress_param(reply['configparams']))
print(configparams)
reply = client.agents.add_plugin_agent(dst_region, dst_agent, configparams, None)
print(reply)
executor_plugin_id = reply['pluginid']
while(client.agents.status_plugin_agent(dst_region,dst_agent,executor_plugin_id)['status_code'] != '10'):
print('waiting on startup')
time.sleep(1)
# this code makes use of a global message to find a specific plugin type, then send a message to that plugin
# send a config message to setup the config of the executor
message_event_type = 'CONFIG'
message_payload = dict()
message_payload['action'] = 'config_process'
message_payload['stream_name'] = ident_id
#adjust for windows vs linux
message_payload['command'] = '-interactive-'
#message_payload['command'] = 'cd /digitalpathprocessor/webapiclient; bash test.sh'
result = client.messaging.global_plugin_msgevent(True, message_event_type, message_payload, dst_region, dst_agent, executor_plugin_id)
print(result)
print('config status: ' + str(result['config_status']))
# Now send a message to start the process
message_payload['action'] = 'start_process'
message_payload['stream_name'] = ident_id
result = client.messaging.global_plugin_msgevent(True, message_event_type, message_payload, dst_region,
dst_agent, executor_plugin_id)
print('start status: ' + str(result['start_status']))
# the process might have already ended, but this is also used to cleanup the task
message_payload['action'] = 'status_process'
message_payload['stream_name'] = ident_id
result = client.messaging.global_plugin_msgevent(True, message_event_type, message_payload, dst_region,
dst_agent, executor_plugin_id)
print(result)
value = '1'
while (not value.startswith('-exit')):
if dp:
value = input('cshell# ')
dp.send(value)
else:
print('waiting active')
time.sleep(1)
# the process might have already ended, but this is also used to cleanup the task
message_payload['action'] = 'end_process'
message_payload['stream_name'] = ident_id
result = client.messaging.global_plugin_msgevent(True, message_event_type, message_payload, dst_region,
dst_agent, executor_plugin_id)
print(result)
print('end status: ' + str(result['end_status']))
# remove the pipeline
client.agents.remove_plugin_agent(dst_region,dst_agent,executor_plugin_id);
while (client.agents.status_plugin_agent(dst_region, dst_agent, executor_plugin_id)['status_code'] == '10'):
print('waiting on shutdown')
print(client.agents.status_plugin_agent(dst_region, dst_agent, executor_plugin_id)['status_code'])
time.sleep(1)
def interactive_executor_deploy_single_node_plugin_pushonly(client, dst_region, dst_agent):
processmap = dict()
#wait if client is not connected
while not client.connected():
print('Waiting on client connection')
time.sleep(10)
client.connect()
if client.agents.is_controller_active(dst_region, dst_agent):
print('Global Controller Status: ' + str(client.agents.get_controller_status(dst_region, dst_agent)))
ident_id = str(uuid.uuid1())
jar_file_path = '/Users/cody/IdeaProjects/executor/target/executor-1.1-SNAPSHOT.jar'
reply = client.globalcontroller.upload_plugin_global(jar_file_path)
configparams = json.loads(decompress_param(reply['configparams']))
print(configparams)
reply = client.agents.add_plugin_agent(dst_region, dst_agent, configparams, None)
print(reply)
executor_plugin_id = reply['pluginid']
while(client.agents.status_plugin_agent(dst_region,dst_agent,executor_plugin_id)['status_code'] != '10'):
print('waiting on startup')
time.sleep(1)
# this code makes use of a global message to find a specific plugin type, then send a message to that plugin
# send a config message to setup the config of the executor
message_event_type = 'CONFIG'
message_payload = dict()
message_payload['action'] = 'config_process'
message_payload['stream_name'] = ident_id
#adjust for windows vs linux
message_payload['command'] = '-interactive-'
result = client.messaging.global_plugin_msgevent(True, message_event_type, message_payload, dst_region, dst_agent, executor_plugin_id)
print(result)
print('config status: ' + str(result['config_status']))
# Now send a message to start the process
message_payload['action'] = 'start_process'
message_payload['stream_name'] = ident_id
result = client.messaging.global_plugin_msgevent(True, message_event_type, message_payload, dst_region,
dst_agent, executor_plugin_id)
print('start status: ' + str(result['start_status']))
# the process might have already ended, but this is also used to cleanup the task
message_payload['action'] = 'status_process'
message_payload['stream_name'] = ident_id
result = client.messaging.global_plugin_msgevent(True, message_event_type, message_payload, dst_region,
dst_agent, executor_plugin_id)
print(result)
def filerepo_deploy_multi_node_plugin(client, dst_region, dst_agent):
#wait if client is not connected
while not client.connected():
print('Waiting on client connection')
time.sleep(10)
client.connect()
if client.agents.is_controller_active(dst_region, dst_agent):
# An optional custom logger callback
def logger_callback(n):
print("Custom logger callback Message = " + str(n))
# Optionally connect to the agent logger stream
#log = client.get_logstreamer(logger_callback)
#log.connect()
# Enable logging stream, this needs work, should be selectable via class and level
#log.update_config(dst_region, dst_agent)
print('Global Controller Status: ' + str(client.agents.get_controller_status(dst_region, dst_agent)))
jar_file_path = '/Users/cody/IdeaProjects/filerepo/target/filerepo-1.1-SNAPSHOT.jar'
reply = client.globalcontroller.upload_plugin_global(jar_file_path)
print("upload status: " + str(reply))
print("plugin config: " + decompress_param(reply['configparams']))
filerepo_name = 'autopathworker'
# describe the dataplane query allowing python client to listen in on filerepo communications
# this is not needed, but lets us see what is being communicated by the plugins
stream_query = "filerepo_name='" + filerepo_name + "' AND broadcast"
print('Client stream query ' + stream_query)
# create a dataplane listener for incoming data
# example of an (optional) custom callback to write executor output to a file
def dp_callback(n):
print("Custom DP callback Message = " + str(n))
dp = client.get_dataplane(stream_query,dp_callback)
print('Connecting to DP')
# connect the listener
dp.connect()
# Use base configparams (plugin_name, md5, etc.) that were extracted during plugin upload
configparams = json.loads(decompress_param(reply['configparams']))
# node 0 : file repo sender configuration
node0_dst_region = 'dp'
node0_dst_agent = 'node0'
node0_configparams = configparams.copy()
node0_configparams["filerepo_name"] = filerepo_name
node0_configparams["scan_dir"] = '/Users/cody/Downloads/node0'
node0_configparams["scan_recursive"] = 'false'
node0_configparams["enable_scan"] = 'false'
reply = client.agents.add_plugin_agent(node0_dst_region, node0_dst_agent, node0_configparams, None)
print(reply)
node0_repo_plugin_id = reply['pluginid']
while(client.agents.status_plugin_agent(node0_dst_region,node0_dst_agent,node0_repo_plugin_id)['status_code'] != '10'):
print('waiting on startup')
time.sleep(1)
# node 1 : file repo sender configuration
node1_dst_region = 'dp'
node1_dst_agent = 'node1'
node1_configparams = configparams.copy()
node1_configparams["filerepo_name"] = filerepo_name