Skip to content

Commit 343b940

Browse files
authored
Merge pull request #2153 from FedML-AI/alaydshah/inference_gateway/hotfix
Hot fix to support local debugging
2 parents 8247dd2 + 2de8c37 commit 343b940

3 files changed

Lines changed: 18 additions & 19 deletions

File tree

python/fedml/api/modules/device.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import fedml
88
from fedml.api.modules.constants import ModuleConstants
99
from fedml.computing.scheduler.comm_utils import sys_utils
10+
from fedml.computing.scheduler.comm_utils.constants import SchedulerConstants
1011
from fedml.computing.scheduler.comm_utils.run_process_utils import RunProcessUtils
1112
from fedml.computing.scheduler.master.server_constants import ServerConstants
1213
from fedml.computing.scheduler.master.server_login import logout as server_logout
@@ -23,11 +24,6 @@ def bind(
2324
device_id = "0"
2425
os_name = ""
2526
docker = None
26-
docker_rank = 1
27-
infer_host = "127.0.0.1"
28-
redis_addr = "local"
29-
redis_port = "6379"
30-
redis_password = "fedml_default"
3127
role = ""
3228
is_client = computing
3329
is_server = server
@@ -47,26 +43,22 @@ def bind(
4743
_bind(
4844
userid, computing, server,
4945
api_key, role, runner_cmd, device_id, os_name,
50-
docker, docker_rank, infer_host,
51-
redis_addr, redis_port, redis_password
52-
)
46+
docker)
5347

5448

5549
def _bind(
5650
userid, computing, server,
5751
api_key, role, runner_cmd, device_id, os_name,
58-
docker, docker_rank, infer_host,
59-
redis_addr, redis_port, redis_password
60-
):
52+
docker):
6153
fedml.load_env()
6254
if os.getenv(ModuleConstants.ENV_FEDML_INFER_HOST) is None:
63-
fedml.set_env_kv(ModuleConstants.ENV_FEDML_INFER_HOST, infer_host)
55+
fedml.set_env_kv(ModuleConstants.ENV_FEDML_INFER_HOST, SchedulerConstants.REDIS_INFER_HOST)
6456
if os.getenv(ModuleConstants.ENV_FEDML_INFER_REDIS_ADDR) is None:
65-
fedml.set_env_kv(ModuleConstants.ENV_FEDML_INFER_REDIS_ADDR, redis_addr)
57+
fedml.set_env_kv(ModuleConstants.ENV_FEDML_INFER_REDIS_ADDR, SchedulerConstants.REDIS_ADDR)
6658
if os.getenv(ModuleConstants.ENV_FEDML_INFER_REDIS_PORT) is None:
67-
fedml.set_env_kv(ModuleConstants.ENV_FEDML_INFER_REDIS_PORT, redis_port)
59+
fedml.set_env_kv(ModuleConstants.ENV_FEDML_INFER_REDIS_PORT, SchedulerConstants.REDIS_PORT)
6860
if os.getenv(ModuleConstants.ENV_FEDML_INFER_REDIS_PASSWORD) is None:
69-
fedml.set_env_kv(ModuleConstants.ENV_FEDML_INFER_REDIS_PASSWORD, redis_password)
61+
fedml.set_env_kv(ModuleConstants.ENV_FEDML_INFER_REDIS_PASSWORD, SchedulerConstants.REDIS_PASSWORD)
7062

7163
url = fedml._get_backend_service()
7264
platform_name = platform.system()

python/fedml/computing/scheduler/comm_utils/constants.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ class SchedulerConstants:
109109
IMAGE_PULL_POLICY_IF_NOT_PRESENT = "IfNotPresent"
110110
IMAGE_PULL_POLICY_NEVER = "Never"
111111

112+
REDIS_INFER_HOST = "127.0.0.1"
113+
REDIS_ADDR = "local"
114+
REDIS_PORT = "6379"
115+
REDIS_PASSWORD = "fedml_default"
116+
117+
112118
@staticmethod
113119
def get_log_source(run_json):
114120
run_config = run_json.get("run_config", {})

python/fedml/computing/scheduler/model_scheduler/device_model_inference.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import fedml
1515
from fedml.api.modules.constants import ModuleConstants
16+
from fedml.computing.scheduler.comm_utils.constants import SchedulerConstants
1617
from fedml.computing.scheduler.model_scheduler.device_client_constants import ClientConstants
1718
from fedml.computing.scheduler.model_scheduler.device_http_inference_protocol import FedMLHttpInference
1819
from fedml.computing.scheduler.model_scheduler.device_server_constants import ServerConstants
@@ -27,10 +28,10 @@
2728
class Settings:
2829
server_name = "DEVICE_INFERENCE_GATEWAY"
2930
fedml.load_env()
30-
redis_addr = os.getenv(ModuleConstants.ENV_FEDML_INFER_REDIS_ADDR)
31-
redis_port = os.getenv(ModuleConstants.ENV_FEDML_INFER_REDIS_PORT)
32-
redis_password = os.getenv(ModuleConstants.ENV_FEDML_INFER_REDIS_PASSWORD)
33-
model_infer_host = os.getenv(ModuleConstants.ENV_FEDML_INFER_HOST)
31+
redis_addr = os.getenv(ModuleConstants.ENV_FEDML_INFER_REDIS_ADDR, SchedulerConstants.REDIS_ADDR)
32+
redis_port = os.getenv(ModuleConstants.ENV_FEDML_INFER_REDIS_PORT, SchedulerConstants.REDIS_PORT)
33+
redis_password = os.getenv(ModuleConstants.ENV_FEDML_INFER_REDIS_PASSWORD, SchedulerConstants.REDIS_PASSWORD)
34+
model_infer_host = os.getenv(ModuleConstants.ENV_FEDML_INFER_HOST, SchedulerConstants.REDIS_INFER_HOST)
3435
version = fedml.get_env_version()
3536
mqtt_config = MLOpsConfigs.fetch_mqtt_config()
3637

0 commit comments

Comments
 (0)