Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
fix retiarii
Browse files Browse the repository at this point in the history
  • Loading branch information
liuzhe-lz committed Jan 5, 2021
1 parent 9eae8e8 commit fdc0e5f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 27 deletions.
5 changes: 4 additions & 1 deletion nni/experiment/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def start(self, port: int = 8080, debug: bool = False) -> None:

# dispatcher must be launched after pipe initialized
# the logic to launch dispatcher in background should be refactored into dispatcher api
self._dispatcher = MsgDispatcher(self.tuner, None)
self._dispatcher = self._create_dispatcher()
self._dispatcher_thread = Thread(target=self._dispatcher.run)
self._dispatcher_thread.start()

Expand All @@ -140,6 +140,9 @@ def start(self, port: int = 8080, debug: bool = False) -> None:
msg = 'Web UI URLs: ' + colorama.Fore.CYAN + ' '.join(ips) + colorama.Style.RESET_ALL
_logger.info(msg)

def _create_dispatcher(self): # overrided by retiarii, temporary solution
return MsgDispatcher(self.tuner, None)


def stop(self) -> None:
"""
Expand Down
29 changes: 3 additions & 26 deletions nni/retiarii/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,34 +159,11 @@ def start(self, port: int = 8080, debug: bool = False) -> None:
debug
Whether to start in debug mode.
"""
atexit.register(self.stop)

if debug:
logging.getLogger('nni').setLevel(logging.DEBUG)

self._proc, self._pipe = launcher.start_experiment(self.config, port, debug)
assert self._proc is not None
assert self._pipe is not None

self.port = port # port will be None if start up failed

# dispatcher must be created after pipe initialized
# the logic to launch dispatcher in background should be refactored into dispatcher api
self._dispatcher_thread = Thread(target=self._dispatcher.run)
self._dispatcher_thread.start()

super().start(port, debug)
self._start_strategy()

ips = [self.config.nni_manager_ip]
for interfaces in psutil.net_if_addrs().values():
for interface in interfaces:
if interface.family == socket.AF_INET:
ips.append(interface.address)
ips = [f'http://{ip}:{port}' for ip in ips if ip]
msg = 'Web UI URLs: ' + colorama.Fore.CYAN + ' '.join(ips)
_logger.info(msg)

# TODO: register experiment management metadata
def _create_dispatcher(self):
return self._dispatcher

def run(self, config: RetiariiExeConfig = None, port: int = 8080, debug: bool = False) -> str:
"""
Expand Down

0 comments on commit fdc0e5f

Please sign in to comment.