@@ -13,13 +13,15 @@ def __init__(self, node_must_exists: bool = False,
13
13
site_must_exists : bool = False ,
14
14
pir_must_exists : bool = False ,
15
15
jupyter_must_exists : bool = False ,
16
- model_must_exists : bool = False ):
16
+ model_must_exists : bool = False ,
17
+ mpc_service_must_exists : bool = False ):
17
18
self .node_must_exists = node_must_exists
18
19
self .gateway_must_exists = gateway_must_exists
19
20
self .site_must_exists = site_must_exists
20
21
self .pir_must_exists = pir_must_exists
21
22
self .jupyter_must_exists = jupyter_must_exists
22
23
self .model_must_exists = model_must_exists
24
+ self .mpc_service_must_exists = mpc_service_must_exists
23
25
24
26
25
27
class PeerInfo :
@@ -70,18 +72,31 @@ def __init__(self, config, section_name: str, component_switch: ComponentSwitch)
70
72
self .config , self .section_name , "wedpr_jupyter_worker_image_desc" ,
71
73
None , self .component_switch .jupyter_must_exists )
72
74
# the cpp component image desc
73
- self .wedpr_cpp_component_image_desc = utilities .get_value (
74
- self .config , self .section_name , "wedpr_cpp_component_image_desc" , None ,
75
- (self .component_switch .gateway_must_exists or self .component_switch .node_must_exists ))
75
+ self .wedpr_gateway_service_image_desc = utilities .get_value (
76
+ self .config , self .section_name , "wedpr_gateway_service_image_desc" , None ,
77
+ self .component_switch .gateway_must_exists and self .docker_mode is True )
78
+ # the node service image desc
79
+ self .wedpr_node_service_image_desc = utilities .get_value (
80
+ self .config , self .section_name ,
81
+ "wedpr_node_service_image_desc" , None ,
82
+ self .component_switch .node_must_exists and self .docker_mode is True )
83
+ # the mpc service image desc
84
+ self .wedpr_mpc_service_image_desc = utilities .get_value (
85
+ self .config , self .section_name ,
86
+ "wedpr_mpc_service_image_desc" , None ,
87
+ self .docker_mode is True and self .component_switch .mpc_service_must_exists )
76
88
# the model image desc
77
89
self .wedpr_model_image_desc = utilities .get_value (
78
- self .config , self .section_name , "wedpr_model_image_desc" , None , self .component_switch .model_must_exists )
90
+ self .config , self .section_name , "wedpr_model_image_desc" , None ,
91
+ self .component_switch .model_must_exists )
79
92
# the pir image
80
93
self .wedpr_pir_image_desc = utilities .get_value (
81
- self .config , self .section_name , "wedpr_pir_image_desc" , None , self .component_switch .pir_must_exists )
94
+ self .config , self .section_name , "wedpr_pir_image_desc" , None ,
95
+ self .component_switch .pir_must_exists )
82
96
# the site image
83
97
self .wedpr_site_image_desc = utilities .get_value (
84
- self .config , self .section_name , "wedpr_site_image_desc" , None , self .component_switch .site_must_exists )
98
+ self .config , self .section_name , "wedpr_site_image_desc" , None ,
99
+ self .component_switch .site_must_exists )
85
100
86
101
# Note: jupyter only use docker mode
87
102
def get_dist_path_by_service_type (self , service_type : str ) -> str :
@@ -102,9 +117,12 @@ def get_image_desc_by_service_name(self, service_type: str) -> str:
102
117
return self .wedpr_pir_image_desc
103
118
if service_type == constant .ServiceInfo .wedpr_jupyter_worker_service :
104
119
return self .wedpr_jupyter_worker_image_desc
105
- if service_type == constant .ServiceInfo .gateway_service_type or \
106
- service_type == constant .ServiceInfo .node_service_type :
107
- return self .wedpr_cpp_component_image_desc
120
+ if service_type == constant .ServiceInfo .gateway_service_type :
121
+ return self .wedpr_gateway_service_image_desc
122
+ if service_type == constant .ServiceInfo .node_service_type :
123
+ return self .wedpr_node_service_image_desc
124
+ if service_type == constant .ServiceInfo .wedpr_mpc_service :
125
+ return self .wedpr_mpc_service_image_desc
108
126
return None
109
127
110
128
def __repr__ (self ):
@@ -162,9 +180,13 @@ class GatewayConfig:
162
180
the gateway config
163
181
"""
164
182
165
- def __init__ (self , agency_name : str , holding_msg_minutes : int ,
183
+ def __init__ (self , agency_name : str ,
184
+ env_config : EnvConfig ,
185
+ holding_msg_minutes : int ,
166
186
config , config_section : str , must_exist : bool ):
167
187
self .config = config
188
+ self .service_type = constant .ServiceInfo .gateway_service_type
189
+ self .env_config = env_config
168
190
self .config_section = config_section
169
191
self .holding_msg_minutes = holding_msg_minutes
170
192
self .agency_name = agency_name
@@ -494,10 +516,14 @@ class NodeConfig:
494
516
the ppc-node config
495
517
"""
496
518
497
- def __init__ (self , agency_name : str , holding_msg_minutes : int , gateway_targets ,
519
+ def __init__ (self , agency_name : str ,
520
+ env_config : EnvConfig ,
521
+ holding_msg_minutes : int , gateway_targets ,
498
522
hdfs_storage_config : HDFSStorageConfig , config , must_exist : bool ):
499
523
self .config = config
500
524
self .section_name = "[[agency.node]]."
525
+ self .service_type = constant .ServiceInfo .node_service_type
526
+ self .env_config = env_config
501
527
self .holding_msg_minutes = holding_msg_minutes
502
528
# the hdfs config
503
529
self .hdfs_storage_config = hdfs_storage_config
@@ -599,7 +625,8 @@ def __init__(self, config, env_config: EnvConfig,
599
625
self .gateway_config = None
600
626
if gateway_config_object is not None :
601
627
self .gateway_config = GatewayConfig (
602
- self .agency_name , self .holding_msg_minutes , gateway_config_object ,
628
+ self .agency_name , self .env_config ,
629
+ self .holding_msg_minutes , gateway_config_object ,
603
630
gateway_config_section_name , self .component_switch .gateway_must_exists )
604
631
utilities .log_debug ("load the gateway config success" )
605
632
@@ -657,6 +684,7 @@ def __init__(self, config, env_config: EnvConfig,
657
684
for node_object in node_config_list :
658
685
node_config = NodeConfig (
659
686
agency_name = self .agency_name ,
687
+ env_config = self .env_config ,
660
688
holding_msg_minutes = self .holding_msg_minutes ,
661
689
hdfs_storage_config = self .hdfs_storage_config ,
662
690
config = node_object ,
@@ -711,6 +739,8 @@ def to_properties(self) -> {}:
711
739
{constant .ConfigProperities .WEDPR_AGENCY : self .agency_name })
712
740
props .update (
713
741
{constant .ConfigProperities .PSI_API_TOKEN : self .psi_api_token })
742
+ # EXTENDED_MOUNT_CONF default is empty string
743
+ props .update ({constant .ConfigProperities .EXTENDED_MOUNT_CONF : "" })
714
744
return props
715
745
716
746
def get_wedpr_model_properties (self , deploy_ip : str , node_index : int ) -> {}:
@@ -734,6 +764,42 @@ def get_wedpr_model_properties(self, deploy_ip: str, node_index: int) -> {}:
734
764
constant .ConfigInfo .get_docker_path ("model/logs" )})
735
765
return props
736
766
767
+ @staticmethod
768
+ def generate_cpp_component_docker_properties (
769
+ prefix_path , service_type : str , env_config ,
770
+ exposed_port_list : str , node_index : int ):
771
+ props = {}
772
+ # the config mount info
773
+ props .update (
774
+ {constant .ConfigProperities .WEDPR_CONFIG_DIR : "config.ini" })
775
+ path = constant .ConfigInfo .get_docker_path (f"{ prefix_path } /config.ini" )
776
+ props .update (
777
+ {constant .ConfigProperities .DOCKER_CONF_PATH : path })
778
+ # set the extended mont config
779
+ local_mount_dir = '${SHELL_FOLDER}/conf'
780
+ remote_mount_dir = constant .ConfigInfo .get_docker_path (
781
+ f"{ prefix_path } /conf" )
782
+ extended_mount_conf = f"-v { local_mount_dir } :{ remote_mount_dir } "
783
+ props .update (
784
+ {constant .ConfigProperities .EXTENDED_MOUNT_CONF : extended_mount_conf })
785
+ # specify the conf path to mount
786
+ props .update ({constant .ConfigProperities .WEDPR_LOG_DIR : "logs" })
787
+ props .update ({constant .ConfigProperities .DOCKER_LOG_PATH :
788
+ constant .ConfigInfo .get_docker_path (f"{ prefix_path } /logs" )})
789
+ # set the image desc for docker mode
790
+ image_desc = env_config .get_image_desc_by_service_name (service_type )
791
+ if image_desc is not None :
792
+ props .update (
793
+ {constant .ConfigProperities .WEDPR_IMAGE_DESC : image_desc })
794
+ # set the exposed port
795
+ props .update (
796
+ {constant .ConfigProperities .WEDPR_DOCKER_EXPORSE_PORT_LIST : exposed_port_list })
797
+ # set the docker name
798
+ docker_name = f"{ service_type } -node{ node_index } "
799
+ props .update (
800
+ {constant .ConfigProperities .WEDPR_DOCKER_NAME : docker_name })
801
+ return props
802
+
737
803
def __generate_java_service_docker_properties__ (self , prefix_path ) -> {}:
738
804
props = {}
739
805
# the config mount info
0 commit comments