MCPcopy
hub / github.com/FedML-AI/FedML / init

Function init

python/fedml/core/mlops/__init__.py:91–150  ·  view source on GitHub ↗
(args, should_init_logs=True)

Source from the content-addressed store, hash-verified

89
90
91def init(args, should_init_logs=True):
92 MLOpsStore.mlops_args = args
93 if not mlops_parrot_enabled(args):
94 if not hasattr(args, "config_version"):
95 args.config_version = "release"
96 fetch_config(args, args.config_version)
97 if should_init_logs:
98 MLOpsRuntimeLog.get_instance(args).init_logs()
99 return
100 else:
101 if hasattr(args, "simulator_daemon"):
102 # Bind local device as simulation device on FedML® Nexus AI Platform
103 setattr(args, "using_mlops", True)
104 setattr(args, "rank", 1)
105 MLOpsStore.mlops_bind_result = bind_simulation_device(args, args.user)
106 return
107
108 project_name = None
109 api_key = None
110 run_name = None
111 if hasattr(args, "mlops_project_name"):
112 project_name = args.mlops_project_name
113 if hasattr(args, "mlops_api_key"):
114 api_key = args.mlops_api_key
115 if hasattr(args, "mlops_run_name"):
116 run_name = args.mlops_run_name
117 if project_name is None or api_key is None:
118 raise Exception("Please check mlops_project_name and mlops_api_key params.")
119
120 # Bind local device as simulation device on FedML® Nexus AI Platform
121 setattr(args, "using_mlops", True)
122 setattr(args, "rank", 1)
123 MLOpsStore.mlops_bind_result = bind_simulation_device(args, api_key, args.config_version)
124 if not MLOpsStore.mlops_bind_result:
125 setattr(args, "using_mlops", False)
126 if should_init_logs:
127 MLOpsRuntimeLog.get_instance(args).init_logs()
128 return
129
130 # Init project and run
131 result_project, project_id = create_project(project_name, api_key)
132 if result_project:
133 result_run, run_id = create_run(project_id, api_key, run_name)
134 if result_run:
135 MLOpsStore.mlops_project_id = project_id
136 MLOpsStore.mlops_run_id = run_id
137 if result_project is False or result_run is False:
138 click.echo("Failed to init project and run.")
139 return
140
141 # Init runtime logs
142 if should_init_logs:
143 init_logs(MLOpsStore.mlops_args, MLOpsStore.mlops_edge_id)
144 logging.info("mlops.init args {}".format(MLOpsStore.mlops_args))
145
146 # Save current process id
147 MLOpsStore.current_parrot_process = os.getpid()
148

Callers

nothing calls this directly

Calls 10

mlops_parrot_enabledFunction · 0.85
fetch_configFunction · 0.85
bind_simulation_deviceFunction · 0.85
create_projectFunction · 0.85
mlops_simulator_loginFunction · 0.85
init_logsMethod · 0.80
create_runFunction · 0.70
init_logsFunction · 0.70
get_instanceMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected