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

Function bind_simulation_device

python/fedml/core/mlops/__init__.py:983–1065  ·  view source on GitHub ↗
(args, userid)

Source from the content-addressed store, hash-verified

981
982
983def bind_simulation_device(args, userid):
984 setattr(args, "account_id", userid)
985 setattr(args, "current_running_dir", ClientConstants.get_fedml_home_dir())
986
987 sys_name = platform.system()
988 if sys_name == "Darwin":
989 sys_name = "MacOS"
990 setattr(args, "os_name", sys_name)
991 version = fedml.get_env_version()
992 setattr(args, "version", version)
993 if args.rank == 0:
994 setattr(args, "log_file_dir", ServerConstants.get_log_file_dir())
995 setattr(args, "device_id", FedMLServerRunner.get_device_id())
996 runner = FedMLServerRunner(args)
997 else:
998 setattr(args, "log_file_dir", ClientConstants.get_log_file_dir())
999 setattr(args, "device_id", FedMLClientRunner.get_device_id())
1000 runner = FedMLClientRunner(args)
1001 setattr(args, "config_version", version)
1002 setattr(args, "cloud_region", "")
1003
1004 # Fetch configs from the MLOps config server.
1005 service_config = dict()
1006 config_try_count = 0
1007 edge_id = 0
1008 while config_try_count < 5:
1009 try:
1010 mqtt_config, s3_config, mlops_config, docker_config = runner.fetch_configs()
1011 service_config["mqtt_config"] = mqtt_config
1012 service_config["s3_config"] = s3_config
1013 service_config["ml_ops_config"] = mlops_config
1014 service_config["docker_config"] = docker_config
1015 runner.agent_config = service_config
1016 MLOpsStore.mlops_log_agent_config = service_config
1017 # setattr(args, "mqtt_config_path", mqtt_config)
1018 # setattr(args, "s3_config_path", s3_config)
1019 setattr(args, "log_server_url", mlops_config["LOG_SERVER_URL"])
1020 break
1021 except Exception as e:
1022 config_try_count += 1
1023 time.sleep(0.5)
1024 continue
1025
1026 if config_try_count >= 5:
1027 click.echo("\nNote: Internet is not connected. "
1028 "Experimental tracking results will not be synchronized to the MLOps (open.fedml.ai).\n")
1029 return False
1030
1031 # Build unique device id
1032 if args.device_id is not None and len(str(args.device_id)) > 0:
1033 device_role = "Edge.Simulator"
1034 unique_device_id = "{}@{}.{}".format(args.device_id, args.os_name, device_role)
1035
1036 # Bind account id to FedML® Nexus AI Platform
1037 register_try_count = 0
1038 edge_id = 0
1039 while register_try_count < 5:
1040 try:

Callers 1

initFunction · 0.85

Calls 7

fetch_configsMethod · 0.95
FedMLServerRunnerClass · 0.50
FedMLClientRunnerClass · 0.50
get_fedml_home_dirMethod · 0.45
get_log_file_dirMethod · 0.45
get_device_idMethod · 0.45

Tested by

no test coverage detected