-
Notifications
You must be signed in to change notification settings - Fork 0
/
entry_provision.py
73 lines (61 loc) · 2.23 KB
/
entry_provision.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
import json
import os
import logging
import sys
import argparse
from provisioning.code.provision_run import provision_run
# Set up logging
logger = logging.getLogger(__name__)
logging.basicConfig(
level=logging.INFO,
stream=sys.stdout,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
force=True
)
def load_provision_input(provision_input_path: str) -> dict:
try:
with open(provision_input_path, 'r') as file:
provision_input = json.load(file)
logger.info(f"Provision input loaded from {provision_input_path}")
return provision_input
except Exception as e:
logger.error(f"Failed to load provision input: {e}")
raise
def main():
# Set up argument parser
parser = argparse.ArgumentParser(description="Run provisioning script")
# Input provision file argument
parser.add_argument(
'--input',
default='/provisioning/provision_input.json',
help='Path to the provision input file (default: /provisioning/provision_input.json)'
)
args = parser.parse_args()
provision_input_path = args.input
# Load provision input
provision_input = load_provision_input(provision_input_path)
path_run = os.path.join('/provisioning')
# Extract arguments from provision input
user_ids = provision_input.get('user_ids')
computation_parameters = provision_input.get('computation_parameters')
fed_learn_port = provision_input.get('fed_learn_port')
admin_port = provision_input.get('admin_port')
host_identifier = provision_input.get('host_identifier')
print(f'user_ids: {user_ids}')
print(f'path_run: {path_run}')
print(f'computation_parameters: {computation_parameters}')
print(f'fed_learn_port: {fed_learn_port}')
print(f'admin_port: {admin_port}')
print(f'host_identifier: {host_identifier}')
# Call the provision_run function with the loaded arguments
provision_run(
user_ids=user_ids,
path_run=path_run,
path_app="/workspace/app",
computation_parameters=computation_parameters,
fed_learn_port=fed_learn_port,
admin_port=admin_port,
host_identifier=host_identifier,
)
if __name__ == '__main__':
main()