Commit b345da07 authored by QuanluZhang's avatar QuanluZhang Committed by fishyds
Browse files

update makefile (#350)

* update makefile

* update launcher.py to fix the problem of finding main.js

* remove duplicated lib
parent b1d4c129
...@@ -25,7 +25,6 @@ BIN_FOLDER ?= $(ROOT_FOLDER)/bin ...@@ -25,7 +25,6 @@ BIN_FOLDER ?= $(ROOT_FOLDER)/bin
NNI_PKG_FOLDER ?= $(ROOT_FOLDER)/nni NNI_PKG_FOLDER ?= $(ROOT_FOLDER)/nni
## Dependency information ## Dependency information
$(info $(_INFO) Installing dependencies, use local toolchain $(_END))
NNI_NODE_TARBALL ?= /tmp/nni-node-linux-x64.tar.xz NNI_NODE_TARBALL ?= /tmp/nni-node-linux-x64.tar.xz
NNI_NODE_FOLDER = /tmp/nni-node-linux-x64 NNI_NODE_FOLDER = /tmp/nni-node-linux-x64
NNI_NODE ?= $(BIN_FOLDER)/node NNI_NODE ?= $(BIN_FOLDER)/node
...@@ -104,6 +103,17 @@ uninstall: ...@@ -104,6 +103,17 @@ uninstall:
-rm -f $(BIN_FOLDER)/nnictl -rm -f $(BIN_FOLDER)/nnictl
-rm -f $(BASH_COMP_SCRIPT) -rm -f $(BASH_COMP_SCRIPT)
.PHONY: clean
clean:
-rm -rf tools/build
-rm -rf tools/nnictl.egg-info
-rm -rf src/nni_manager/dist
-rm -rf src/nni_manager/node_modules
-rm -rf src/sdk/pynni/build
-rm -rf src/sdk/pynni/nni_sdk.egg-info
-rm -rf src/webui/build
-rm -rf src/webui/node_modules
# Main targets end # Main targets end
# Helper targets # Helper targets
...@@ -116,7 +126,7 @@ $(NNI_YARN_TARBALL): ...@@ -116,7 +126,7 @@ $(NNI_YARN_TARBALL):
#$(_INFO) Downloading Yarn $(_END) #$(_INFO) Downloading Yarn $(_END)
wget https://aka.ms/yarn-download -O $(NNI_YARN_TARBALL) wget https://aka.ms/yarn-download -O $(NNI_YARN_TARBALL)
.PHONY: intall-dependencies .PHONY: install-dependencies
install-dependencies: $(NNI_NODE_TARBALL) $(NNI_YARN_TARBALL) install-dependencies: $(NNI_NODE_TARBALL) $(NNI_YARN_TARBALL)
#$(_INFO) Extracting Node.js $(_END) #$(_INFO) Extracting Node.js $(_END)
rm -rf $(NNI_NODE_FOLDER) rm -rf $(NNI_NODE_FOLDER)
......
...@@ -34,7 +34,7 @@ from .common_utils import get_yml_content, get_json_content, print_error, print_ ...@@ -34,7 +34,7 @@ from .common_utils import get_yml_content, get_json_content, print_error, print_
from .constants import * from .constants import *
import time import time
import random import random
import string import site
from pathlib import Path from pathlib import Path
...@@ -73,8 +73,17 @@ def start_rest_server(port, platform, mode, config_file_name, experiment_id=None ...@@ -73,8 +73,17 @@ def start_rest_server(port, platform, mode, config_file_name, experiment_id=None
exit(1) exit(1)
print_normal('Starting restful server...') print_normal('Starting restful server...')
base_dir = str(Path(os.path.dirname(__file__)).parents[3]) python_dir = str(Path(site.getusersitepackages()).parents[2])
cmds = ['node', os.path.join(base_dir, 'nni', 'main.js'), '--port', str(port), '--mode', platform, '--start_mode', mode] entry_file = os.path.join(python_dir, 'nni', 'main.js')
entry_dir = os.path.join(python_dir, 'nni')
local_entry_dir = entry_dir
if not os.path.isfile(entry_file):
python_dir = str(Path(site.getsitepackages()[0]).parents[2])
entry_file = os.path.join(python_dir, 'nni', 'main.js')
entry_dir = os.path.join(python_dir, 'nni')
if not os.path.isfile(entry_file):
raise Exception('Fail to find main.js under both %s and %s!' % (local_entry_dir, entry_dir))
cmds = ['node', entry_file, '--port', str(port), '--mode', platform, '--start_mode', mode]
if mode == 'resume': if mode == 'resume':
cmds += ['--experiment_id', experiment_id] cmds += ['--experiment_id', experiment_id]
stdout_full_path, stderr_full_path = get_log_path(config_file_name) stdout_full_path, stderr_full_path = get_log_path(config_file_name)
...@@ -85,7 +94,7 @@ def start_rest_server(port, platform, mode, config_file_name, experiment_id=None ...@@ -85,7 +94,7 @@ def start_rest_server(port, platform, mode, config_file_name, experiment_id=None
log_header = LOG_HEADER % str(time_now) log_header = LOG_HEADER % str(time_now)
stdout_file.write(log_header) stdout_file.write(log_header)
stderr_file.write(log_header) stderr_file.write(log_header)
process = Popen(cmds, cwd=os.path.join(base_dir, 'nni'), stdout=stdout_file, stderr=stderr_file) process = Popen(cmds, cwd=entry_dir, stdout=stdout_file, stderr=stderr_file)
return process, str(time_now) return process, str(time_now)
def set_trial_config(experiment_config, port, config_file_name): def set_trial_config(experiment_config, port, config_file_name):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment