-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_max_workers.py
executable file
·46 lines (38 loc) · 1.32 KB
/
update_max_workers.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
#!/usr/bin/env python3
import argparse
import json
import runpod
def get_args():
parser = argparse.ArgumentParser(
description='Update Max Workers for a Serverless Endpoint',
)
parser.add_argument(
'--endpoint_id', '-endpoint_id', '--endpoint', '-endpoint', '--e', '-e',
type=str,
required=True,
help='endpoint id (eg. dg31b9aqtupn2z)'
)
parser.add_argument(
'--max_workers', '-max_workers', '--min', '-min', '--m', '-m',
type=int,
required=True,
help='min workers (eg. 1)'
)
return parser.parse_args()
if __name__ == '__main__':
args = get_args()
runpod = runpod.API()
response = runpod.update_max_workers(args.endpoint_id, args.max_workers)
resp_json = response.json()
if response.status_code == 200:
if 'errors' in resp_json:
print('ERROR:')
for error in resp_json['errors']:
print(error['message'])
else:
endpoint = resp_json['data']['updateEndpointWorkersMax']
print('Max workers updated successfully.')
print(f"endpoint id: {endpoint['id']}")
print(f"template id: {endpoint['templateId']}")
print(f"min workers: {endpoint['workersMin']}")
print(f"max workers: {endpoint['workersMax']}")