Skip to content

Commit

Permalink
fixed get_module_level_config key err while launching daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
visualDust committed Nov 23, 2023
1 parent 18ace58 commit a13e323
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions neetbox.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ updateInterval = 10

[daemon]
enable = true
server = "localhost"
host = "localhost"
port = 20202
allowIpython = false
mute = true
mode = "attached"
mode = "detached"
uploadInterval = 10

[integrations.environment.hardware]
Expand Down
2 changes: 1 addition & 1 deletion neetbox/config/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"daemon": {
"enable": True,
"server": "localhost",
"host": "localhost",
"port": 20202,
"displayName": None,
"allowIpython": False,
Expand Down
7 changes: 3 additions & 4 deletions neetbox/daemon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,17 @@ def __attach_daemon(daemon_config):
logger.log("daemon connection status: " + str(_is_daemon_server_online))
if not _is_daemon_server_online: # if no daemon online
# check if possible to launch
if daemon_config["server"] not in ["localhost", "127.0.0.1", "0.0.0.0"]:
if daemon_config["host"] not in ["localhost", "127.0.0.1", "0.0.0.0"]:
# daemon not running on localhost
logger.err(
f"No daemon running at {daemon_config['server']}:{daemon_config['port']}, daemon will not be attached. Continue anyway."
f"No daemon running at {daemon_config['host']}:{daemon_config['port']}, daemon will not be attached. Continue anyway."
)
return False

logger.warn(
f"No daemon running at {daemon_config['server']}:{daemon_config['port']}, trying to create daemon..."
f"No daemon running at {daemon_config['host']}:{daemon_config['port']}, trying to create daemon..."
)

# TODO BAD NEWS daemon process seems not launching properly
popen = DaemonableProcess(
target="neetbox.daemon.server._daemon_launcher",
args=["--config", json.dumps(daemon_config)],
Expand Down
2 changes: 1 addition & 1 deletion neetbox/daemon/client/_client_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
logger = logger("NEETBOX DAEMON API")

__cfg = get_module_level_config()
daemon_address = f"{__cfg['server']}:{__cfg['port']}"
daemon_address = f"{__cfg['host']}:{__cfg['port']}"
base_addr = f"http://{daemon_address}"


Expand Down
6 changes: 3 additions & 3 deletions neetbox/daemon/client/_daemon_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

from neetbox.config import get_module_level_config
from neetbox.daemon.client._connection import _local_http_client
from neetbox.daemon.server._server import CLIENT_API_ROOT
from neetbox.logging import logger
from neetbox.pipeline._signal_and_slot import _update_value_dict
from neetbox.daemon.server._server import CLIENT_API_ROOT

__TIME_UNIT_SEC = 0.1

Expand Down Expand Up @@ -68,8 +68,8 @@ def connect_daemon(cfg=None, launch_upload_thread=True):
_launch_config = get_module_level_config("@")
_display_name = _display_name or _launch_config["name"]

logger.log(f"Connecting to daemon at {cfg['server']}:{cfg['port']} ...")
_daemon_server_address = f"{cfg['server']}:{cfg['port']}"
logger.log(f"Connecting to daemon at {cfg['host']}:{cfg['port']} ...")
_daemon_server_address = f"{cfg['host']}:{cfg['port']}"
_base_addr = f"http://{_daemon_server_address}"

# check if daemon is alive
Expand Down
2 changes: 1 addition & 1 deletion neetbox/daemon/server/_daemon_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import json
import sys

from neetbox.daemon.server._flask_server import daemon_process
from neetbox.daemon.server._server import daemon_process

# sys.stdout=open(r'D:\Projects\ML\neetbox\logdir\daemon.log', 'a+')

Expand Down

0 comments on commit a13e323

Please sign in to comment.