Skip to content

Commit 30a8366

Browse files
Improvements and Fixes: Automation (Samagra-Development#256)
* Ability to add deployment constraints as a part of config.json --------- Co-authored-by: Gautam <[email protected]>
1 parent 00fe9b7 commit 30a8366

File tree

2 files changed

+37
-13
lines changed

2 files changed

+37
-13
lines changed

config.json

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"apiBasePath": "text_classification/flow_classification/local/",
2323
"containerPort": 8000,
2424
"environment": {},
25-
"nginx": []
25+
"nginx": [],
26+
"constraints": ["node.role==worker"]
2627
},
2728
{
2829
"serviceName": "text_translation_azure_dict",
@@ -42,23 +43,26 @@
4243
"environment": {
4344
"OPENAI_API_KEY": "${OPENAI_API_KEY}"
4445
},
45-
"nginx": []
46+
"nginx": [],
47+
"constraints": ["node.labels.node_vm_type==gpu"]
4648
},
4749
{
4850
"serviceName": "coref_spacy",
4951
"modelBasePath": "src/coref/spacy/local/.",
5052
"apiBasePath": "/coref/spacy/local",
5153
"containerPort": 8000,
5254
"environment": {},
53-
"nginx": []
55+
"nginx": [],
56+
"constraints": ["node.labels.node_vm_type==gpu"]
5457
},
5558
{
5659
"serviceName": "coref_bart",
5760
"modelBasePath": "src/coref/bart/local/.",
5861
"apiBasePath": "/coref/bart/local",
5962
"containerPort": 8000,
6063
"environment": {},
61-
"nginx": []
64+
"nginx": [],
65+
"constraints": ["node.labels.node_vm_type==gpu"]
6266
},
6367
{
6468
"serviceName": "text_translation_azure",
@@ -68,45 +72,51 @@
6872
"environment": {
6973
"AZURE_TRANSLATE_KEY": "${AZURE_TRANSLATE_KEY}"
7074
},
71-
"nginx": []
75+
"nginx": [],
76+
"constraints": ["node.labels.node_vm_type==gpu"]
7277
},
7378
{
7479
"serviceName": "asr_mms",
7580
"modelBasePath": "src/asr/fairseq_mms/local/.",
7681
"apiBasePath": "/asr/fairseq_mms/local",
7782
"containerPort": 8000,
7883
"environment": {},
79-
"nginx": ["client_max_body_size 100M;", "proxy_read_timeout 600;", "proxy_connect_timeout 600;", "proxy_send_timeout 600;"]
84+
"nginx": ["client_max_body_size 100M;", "proxy_read_timeout 600;", "proxy_connect_timeout 600;", "proxy_send_timeout 600;"],
85+
"constraints": ["node.labels.node_vm_type==gpu"]
8086
},
8187
{
8288
"serviceName": "coref_fcoref",
8389
"modelBasePath": "src/coref/fcoref/local/.",
8490
"apiBasePath": "/coref/fcoref/local",
8591
"containerPort": 8000,
8692
"environment": {},
87-
"nginx": []
93+
"nginx": [],
94+
"constraints": ["node.labels.node_vm_type==gpu"]
8895
},
8996
{
9097
"serviceName": "text_translation_bhashini",
9198
"modelBasePath": "src/text_translation/bhashini/remote/.",
9299
"apiBasePath": "/text_translation/bhashini/remote",
93100
"containerPort": 8000,
94101
"environment": {},
95-
"nginx": []
102+
"nginx": [],
103+
"constraints": ["node.labels.node_vm_type==gpu"]
96104
},
97105
{
98106
"serviceName": "text_translation_ai4bharat",
99107
"modelBasePath": "src/text_translation/ai4bharat/remote/.",
100108
"apiBasePath": "src/text_translation/ai4bharat/remote",
101109
"containerPort": 8000,
102-
"environment": {}
110+
"environment": {},
111+
"constraints": ["node.labels.node_vm_type==gpu"]
103112
},
104113
{
105114
"serviceName": "text_lang_detection_bhashini",
106115
"modelBasePath": "src/text_lang_detection/bhashini/remote/.",
107116
"apiBasePath": "/text_lang_detection/bhashini/remote",
108117
"containerPort": 8000,
109-
"environment": {}
118+
"environment": {},
119+
"constraints": ["node.labels.node_vm_type==gpu"]
110120
},
111121
{
112122
"serviceName": "chunking_mpnet",
@@ -116,7 +126,8 @@
116126
"environment": {
117127
"OPENAI_API_KEY": "${OPENAI_API_KEY}"
118128
},
119-
"nginx": ["client_max_body_size 100M;", "proxy_read_timeout 600;", "proxy_connect_timeout 600;", "proxy_send_timeout 600;"]
129+
"nginx": ["client_max_body_size 100M;", "proxy_read_timeout 600;", "proxy_connect_timeout 600;", "proxy_send_timeout 600;"],
130+
"constraints": ["node.labels.node_vm_type==gpu"]
120131
},
121132
{
122133
"serviceName": "embedding_instructor",
@@ -126,7 +137,8 @@
126137
"environment": {
127138
"OPENAI_API_KEY": "${OPENAI_API_KEY}"
128139
},
129-
"nginx": ["client_max_body_size 100M;", "proxy_read_timeout 600;", "proxy_connect_timeout 600;", "proxy_send_timeout 600;"]
140+
"nginx": ["client_max_body_size 100M;", "proxy_read_timeout 600;", "proxy_connect_timeout 600;", "proxy_send_timeout 600;"],
141+
"constraints": ["node.labels.node_vm_type==gpu"]
130142
},
131143
{
132144
"serviceName": "llm_openai_gpt3",
@@ -136,7 +148,8 @@
136148
"environment": {
137149
"OPENAI_API_KEY": "${OPENAI_API_KEY}"
138150
},
139-
"nginx": []
151+
"nginx": [],
152+
"constraints": ["node.labels.node_vm_type==gpu"]
140153
}
141154
]
142155
}

generate_independent_docker.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ for ((i=0; i<$count; i++)); do
2222
apiBasePath=$(jq -r ".models[$i].apiBasePath" config.json)
2323
containerPort=$(jq -r ".models[$i].containerPort" config.json)
2424

25+
countConstraints=$(jq ".models[$i].constraints | length" config.json)
26+
2527
# Calculate the exposed port for the model
2628
exposedPort=$((8000 + i))
2729

@@ -31,6 +33,15 @@ for ((i=0; i<$count; i++)); do
3133
# Add service details to docker-compose.yaml
3234
printf " ${serviceName}:\n image: ${DOCKER_REGISTRY_URL}/${GITHUB_REPOSITORY_URL}/${serviceName}:latest\n ports:\n - ${exposedPort}:${containerPort}\n" >> docker-compose-independent-generated.yaml
3335

36+
if [[ countConstraints -gt 0 ]]; then
37+
printf " deploy:\n placement:\n constraints:\n" >> docker-compose-independent-generated.yaml
38+
fi
39+
for ((j=0; j<$countConstraints; j++)); do
40+
constraintLine=$(jq -r ".models[$i].constraints[$j]" config.json)
41+
42+
printf " - ${constraintLine}\n" >> docker-compose-independent-generated.yaml
43+
done
44+
3445
# Add environment variables to docker-compose.yaml
3546
if [[ ${#environment[@]} -gt 0 ]]; then
3647
printf " environment:\n" >> docker-compose-independent-generated.yaml

0 commit comments

Comments
 (0)