From d130d44ff49850269dcbfc195554a01c934acc5e Mon Sep 17 00:00:00 2001 From: Crysple Date: Fri, 28 Dec 2018 11:56:32 +0800 Subject: [PATCH 01/23] support venv --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a00900788f..473ddd08fa 100644 --- a/Makefile +++ b/Makefile @@ -19,12 +19,11 @@ else endif ## Install directories +ROOT_FOLDER ?= $(shell python3 -c 'from distutils.sysconfig import get_python_lib; from pathlib import Path; print(Path(get_python_lib()).parents[2])') ifeq ($(shell id -u), 0) # is root _ROOT := 1 - ROOT_FOLDER ?= $(shell python3 -c 'import site; from pathlib import Path; print(Path(site.getsitepackages()[0]).parents[2])') BASH_COMP_PREFIX ?= /usr/share/bash-completion/completions else # is normal user - ROOT_FOLDER ?= $(shell python3 -c 'import site; from pathlib import Path; print(Path(site.getusersitepackages()).parents[2])') ifndef VIRTUAL_ENV PIP_MODE ?= --user endif From a0479834fe2b5d1c33f8d169117252f3464d5973 Mon Sep 17 00:00:00 2001 From: Crysple Date: Fri, 28 Dec 2018 17:25:31 +0800 Subject: [PATCH 02/23] adapt venv --- tools/nni_cmd/launcher.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/nni_cmd/launcher.py b/tools/nni_cmd/launcher.py index 22984f3fa4..a3c423da52 100644 --- a/tools/nni_cmd/launcher.py +++ b/tools/nni_cmd/launcher.py @@ -34,8 +34,8 @@ from .constants import * import time import random -import site from pathlib import Path +from distutils.sysconfig import get_python_lib def get_log_path(config_file_name): '''generate stdout and stderr log path''' @@ -72,12 +72,11 @@ def start_rest_server(port, platform, mode, config_file_name, experiment_id=None exit(1) print_normal('Starting restful server...') - python_dir = str(Path(site.getusersitepackages()).parents[2]) + python_dir = str(Path(get_python_lib()).parents[2]) 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): From 8e482138a2602b6a699dbf68cb322ebbfccde4c0 Mon Sep 17 00:00:00 2001 From: Crysple Date: Fri, 28 Dec 2018 17:51:25 +0800 Subject: [PATCH 03/23] adapt venv --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 473ddd08fa..283c25d540 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,9 @@ ifeq ($(shell id -u), 0) # is root BASH_COMP_PREFIX ?= /usr/share/bash-completion/completions else # is normal user ifndef VIRTUAL_ENV - PIP_MODE ?= --user + ifeq (, $(shell echo $$PATH | grep 'conda')) + PIP_MODE ?= --user + endif endif BASH_COMP_PREFIX ?= ${HOME}/.bash_completion.d endif From 89cdc498d6ac258bd718fcdb758d88d17213b9d5 Mon Sep 17 00:00:00 2001 From: Crysple Date: Fri, 28 Dec 2018 17:52:40 +0800 Subject: [PATCH 04/23] adapt venv --- install.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/install.sh b/install.sh index 3d5199e187..5862f7da3d 100644 --- a/install.sh +++ b/install.sh @@ -1,3 +1,2 @@ #!/bin/bash make easy-install -source ~/.bashrc From 502db60e52338767738305a668c347496c298015 Mon Sep 17 00:00:00 2001 From: Crysple Date: Fri, 28 Dec 2018 18:43:31 +0800 Subject: [PATCH 05/23] adapt venv --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4d57b720a0..eaee565816 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ The tool dispatches and runs trial jobs generated by tuning algorithms to search **Install through pip** * We support Linux and MacOS in current stage, Ubuntu 16.04 or higher, along with MacOS 10.14.1 are tested and supported. Simply run the following `pip install` in an environment that has `python >= 3.5`. ```bash - python3 -m pip install --user --upgrade nni + python3 -m pip install --upgrade nni ``` * Note: * If you are in docker container (as root), please remove `--user` from the installation command. From 8095896598a1ab26fde59e4ac75120ef0934b2b4 Mon Sep 17 00:00:00 2001 From: Crysple Date: Sat, 29 Dec 2018 10:07:54 +0800 Subject: [PATCH 06/23] new test --- Makefile | 10 ++++++++++ tools/nni_cmd/launcher.py | 19 ++++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 283c25d540..3e9d650811 100644 --- a/Makefile +++ b/Makefile @@ -20,10 +20,20 @@ endif ## Install directories ROOT_FOLDER ?= $(shell python3 -c 'from distutils.sysconfig import get_python_lib; from pathlib import Path; print(Path(get_python_lib()).parents[2])') +IS_SYS_PYTHON ?= FALSE +ifneq (, $(shell echo $(ROOT_FOLDER) | grep 'dist-package')) + IS_SYS_PYTHON := TRUE +endif ifeq ($(shell id -u), 0) # is root _ROOT := 1 + ifeq (TRUE, $(IS_SYS_PYTHON)) + ROOT_FOLDER := $(shell python3 -c 'import site; from pathlib import Path; print(Path(site.getsitepackages()[0]).parents[2])') + endif BASH_COMP_PREFIX ?= /usr/share/bash-completion/completions else # is normal user + ifeq (TRUE, $(IS_SYS_PYTHON)) + ROOT_FOLDER := $(shell python3 -c 'import site; from pathlib import Path; print(Path(site.getusersitepackages()).parents[2])') + endif ifndef VIRTUAL_ENV ifeq (, $(shell echo $$PATH | grep 'conda')) PIP_MODE ?= --user diff --git a/tools/nni_cmd/launcher.py b/tools/nni_cmd/launcher.py index a3c423da52..21383e3b96 100644 --- a/tools/nni_cmd/launcher.py +++ b/tools/nni_cmd/launcher.py @@ -36,6 +36,7 @@ import random from pathlib import Path from distutils.sysconfig import get_python_lib +import site def get_log_path(config_file_name): '''generate stdout and stderr log path''' @@ -72,15 +73,19 @@ def start_rest_server(port, platform, mode, config_file_name, experiment_id=None exit(1) print_normal('Starting restful server...') - python_dir = str(Path(get_python_lib()).parents[2]) - 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): + # Find nni lib from the following locations in order + python_dirs = [Path(get_python_lib()), Path(site.getusersitepackages()), Path(site.getsitepackages()[0])] + python_dirs = [str(path.parents[2]) for path in python_dirs] + for python_dir in python_dirs: 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)) + if os.path.isfile(entry_file): + break + # Nothing is found + if not os.path.isfile(entry_file): + cannot_find_location = '" and "'.join([os.path.join(python_dir, 'nni') for python_dir in python_dirs]) + raise Exception('Fail to find main.js under both "%s"' % cannot_find_location) + cmds = ['node', entry_file, '--port', str(port), '--mode', platform, '--start_mode', mode] if mode == 'resume': cmds += ['--experiment_id', experiment_id] From 72cf8398e8fd0e40f45521be36f7698771f1df53 Mon Sep 17 00:00:00 2001 From: Crysple Date: Sat, 29 Dec 2018 10:16:39 +0800 Subject: [PATCH 07/23] new test --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3e9d650811..da49b17ea3 100644 --- a/Makefile +++ b/Makefile @@ -19,10 +19,12 @@ else endif ## Install directories -ROOT_FOLDER ?= $(shell python3 -c 'from distutils.sysconfig import get_python_lib; from pathlib import Path; print(Path(get_python_lib()).parents[2])') +ROOT_FOLDER ?= $(shell python3 -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())') IS_SYS_PYTHON ?= FALSE ifneq (, $(shell echo $(ROOT_FOLDER) | grep 'dist-package')) IS_SYS_PYTHON := TRUE +else + ROOT_FOLDER := ROOT_FOLDER ?= $(shell python3 -c 'from distutils.sysconfig import get_python_lib; from pathlib import Path; print(Path(get_python_lib()).parents[2])') endif ifeq ($(shell id -u), 0) # is root _ROOT := 1 From 8a9cc7d849ef42da3a56b3c88db40efc4197e0a6 Mon Sep 17 00:00:00 2001 From: Crysple Date: Sat, 29 Dec 2018 10:18:52 +0800 Subject: [PATCH 08/23] new test --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index da49b17ea3..5febdadc81 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ IS_SYS_PYTHON ?= FALSE ifneq (, $(shell echo $(ROOT_FOLDER) | grep 'dist-package')) IS_SYS_PYTHON := TRUE else - ROOT_FOLDER := ROOT_FOLDER ?= $(shell python3 -c 'from distutils.sysconfig import get_python_lib; from pathlib import Path; print(Path(get_python_lib()).parents[2])') + ROOT_FOLDER := $(shell python3 -c 'from distutils.sysconfig import get_python_lib; from pathlib import Path; print(Path(get_python_lib()).parents[2])') endif ifeq ($(shell id -u), 0) # is root _ROOT := 1 From 0030cf744629684816acb87cc03421d01716129c Mon Sep 17 00:00:00 2001 From: Crysple Date: Tue, 1 Jan 2019 12:16:40 +0800 Subject: [PATCH 09/23] support venv --- Makefile | 13 +++---------- tools/nni_cmd/launcher.py | 26 +++++++++++++++++--------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 5febdadc81..6ac7a4265c 100644 --- a/Makefile +++ b/Makefile @@ -19,18 +19,11 @@ else endif ## Install directories -ROOT_FOLDER ?= $(shell python3 -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())') -IS_SYS_PYTHON ?= FALSE -ifneq (, $(shell echo $(ROOT_FOLDER) | grep 'dist-package')) - IS_SYS_PYTHON := TRUE -else - ROOT_FOLDER := $(shell python3 -c 'from distutils.sysconfig import get_python_lib; from pathlib import Path; print(Path(get_python_lib()).parents[2])') -endif +ROOT_FOLDER := $(shell python3 -c 'import site; from pathlib import Path; print(Path(site.getsitepackages()[0]).parents[2])') +IS_SYS_PYTHON ?= $(shell [[ $ROOT_FOLDER == /usr* || $ROOT_FOLDER == /Library* ]] && echo TRUE || echo FALSE) + ifeq ($(shell id -u), 0) # is root _ROOT := 1 - ifeq (TRUE, $(IS_SYS_PYTHON)) - ROOT_FOLDER := $(shell python3 -c 'import site; from pathlib import Path; print(Path(site.getsitepackages()[0]).parents[2])') - endif BASH_COMP_PREFIX ?= /usr/share/bash-completion/completions else # is normal user ifeq (TRUE, $(IS_SYS_PYTHON)) diff --git a/tools/nni_cmd/launcher.py b/tools/nni_cmd/launcher.py index 21383e3b96..7d327a5a93 100644 --- a/tools/nni_cmd/launcher.py +++ b/tools/nni_cmd/launcher.py @@ -74,17 +74,25 @@ def start_rest_server(port, platform, mode, config_file_name, experiment_id=None print_normal('Starting restful server...') # Find nni lib from the following locations in order - python_dirs = [Path(get_python_lib()), Path(site.getusersitepackages()), Path(site.getsitepackages()[0])] - python_dirs = [str(path.parents[2]) for path in python_dirs] - for python_dir in python_dirs: + sys_wide_python = True + python_sitepackage = site.getsitepackages()[0] + # If system-wide python is used, we will first check if nni exists locally + if python_sitepackage.startswith('/usr') or python_sitepackage.startswith('/Library'): + local_python_dir = str(Path(site.getusersitepackages()).parents[2]) + entry_file = os.path.join(local_python_dir, 'nni', 'main.js') + entry_dir = os.path.join(local_python_dir, 'nni') + else: + # If this python is not system-wide python, we will use its site-package directly + sys_wide_python = False + + if not sys_wide_python or not os.path.isfile(entry_file): + python_dir = str(Path(python_sitepackage).parents[2]) entry_file = os.path.join(python_dir, 'nni', 'main.js') entry_dir = os.path.join(python_dir, 'nni') - if os.path.isfile(entry_file): - break - # Nothing is found - if not os.path.isfile(entry_file): - cannot_find_location = '" and "'.join([os.path.join(python_dir, 'nni') for python_dir in python_dirs]) - raise Exception('Fail to find main.js under both "%s"' % cannot_find_location) + # Nothing is found + if not os.path.isfile(entry_file): + cannot_find_location = '" and "'.join([os.path.join(python_dir, 'nni') for python_dir in python_dirs]) + raise Exception('Fail to find nni under both "%s" and "%s"' % (local_python_dir, python_dir)) cmds = ['node', entry_file, '--port', str(port), '--mode', platform, '--start_mode', mode] if mode == 'resume': From 900a8e6647d130502c59bd578d8f2685e43d8aa6 Mon Sep 17 00:00:00 2001 From: Crysple Date: Tue, 1 Jan 2019 12:28:20 +0800 Subject: [PATCH 10/23] support venv --- Makefile | 4 ++-- tools/nni_cmd/launcher.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 6ac7a4265c..a62afecf52 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # Setting variables - +SHELL := /bin/bash PIP_INSTALL := python3 -m pip install --no-cache-dir PIP_UNINSTALL := python3 -m pip uninstall @@ -19,7 +19,7 @@ else endif ## Install directories -ROOT_FOLDER := $(shell python3 -c 'import site; from pathlib import Path; print(Path(site.getsitepackages()[0]).parents[2])') +ROOT_FOLDER ?= $(shell python3 -c 'import site; from pathlib import Path; print(Path(site.getsitepackages()[0]).parents[2])') IS_SYS_PYTHON ?= $(shell [[ $ROOT_FOLDER == /usr* || $ROOT_FOLDER == /Library* ]] && echo TRUE || echo FALSE) ifeq ($(shell id -u), 0) # is root diff --git a/tools/nni_cmd/launcher.py b/tools/nni_cmd/launcher.py index 7d327a5a93..d2ec0d5539 100644 --- a/tools/nni_cmd/launcher.py +++ b/tools/nni_cmd/launcher.py @@ -76,7 +76,7 @@ def start_rest_server(port, platform, mode, config_file_name, experiment_id=None # Find nni lib from the following locations in order sys_wide_python = True python_sitepackage = site.getsitepackages()[0] - # If system-wide python is used, we will first check if nni exists locally + # If system-wide python is used, we will give priority to using user-sitepackage given that nni exists there if python_sitepackage.startswith('/usr') or python_sitepackage.startswith('/Library'): local_python_dir = str(Path(site.getusersitepackages()).parents[2]) entry_file = os.path.join(local_python_dir, 'nni', 'main.js') From 0db6f074fae7698181c73fb1e8b8b0dd47e2385a Mon Sep 17 00:00:00 2001 From: Crysple Date: Tue, 1 Jan 2019 12:37:44 +0800 Subject: [PATCH 11/23] support venv --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index a62afecf52..edf3bdc913 100644 --- a/Makefile +++ b/Makefile @@ -151,6 +151,9 @@ $(NNI_YARN_TARBALL): .PHONY: install-dependencies install-dependencies: $(NNI_NODE_TARBALL) $(NNI_YARN_TARBALL) + echo $(shell python3 -c 'import site; print(site.getsitepackages())') + echo $(IS_SYS_PYTHON) + echo $(shell id -u) #$(_INFO) Extracting Node.js $(_END) rm -rf $(NNI_NODE_FOLDER) mkdir $(NNI_NODE_FOLDER) From acf7befe63c0981a99e4de58ebd3b0ef31306d52 Mon Sep 17 00:00:00 2001 From: Crysple Date: Tue, 1 Jan 2019 12:46:42 +0800 Subject: [PATCH 12/23] support venv --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index edf3bdc913..ba0c2bad7b 100644 --- a/Makefile +++ b/Makefile @@ -151,7 +151,9 @@ $(NNI_YARN_TARBALL): .PHONY: install-dependencies install-dependencies: $(NNI_NODE_TARBALL) $(NNI_YARN_TARBALL) - echo $(shell python3 -c 'import site; print(site.getsitepackages())') + echo $(shell python3 -c 'import site; from pathlib import Path; print(Path(site.getsitepackages()[0]).parents[2])') + echo $(shell which python3) + echo $(shell python3 -c 'from distutils.sysconfig import get_python_lib; from pathlib import Path; print(Path(get_python_lib()).parents[2])') echo $(IS_SYS_PYTHON) echo $(shell id -u) #$(_INFO) Extracting Node.js $(_END) From 20bcd7f1a30999a42f8100f26cc67a46aa73da6e Mon Sep 17 00:00:00 2001 From: Crysple Date: Tue, 1 Jan 2019 12:50:27 +0800 Subject: [PATCH 13/23] support venv --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ba0c2bad7b..3e5fa0f9bf 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ endif ## Install directories ROOT_FOLDER ?= $(shell python3 -c 'import site; from pathlib import Path; print(Path(site.getsitepackages()[0]).parents[2])') -IS_SYS_PYTHON ?= $(shell [[ $ROOT_FOLDER == /usr* || $ROOT_FOLDER == /Library* ]] && echo TRUE || echo FALSE) +IS_SYS_PYTHON ?= $(shell [[ $$ROOT_FOLDER == /usr* || $$ROOT_FOLDER == /Library* ]] && echo TRUE || echo FALSE) ifeq ($(shell id -u), 0) # is root _ROOT := 1 From b38560d7d172fdc1536393e1570130dd5da5c9c7 Mon Sep 17 00:00:00 2001 From: Crysple Date: Tue, 1 Jan 2019 12:54:56 +0800 Subject: [PATCH 14/23] support venv --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3e5fa0f9bf..4b9d3f04c7 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ endif ## Install directories ROOT_FOLDER ?= $(shell python3 -c 'import site; from pathlib import Path; print(Path(site.getsitepackages()[0]).parents[2])') -IS_SYS_PYTHON ?= $(shell [[ $$ROOT_FOLDER == /usr* || $$ROOT_FOLDER == /Library* ]] && echo TRUE || echo FALSE) +IS_SYS_PYTHON ?= $(shell [[ $(ROOT_FOLDER) == /usr* || $(ROOT_FOLDER) == /Library* ]] && echo TRUE || echo FALSE) ifeq ($(shell id -u), 0) # is root _ROOT := 1 From 9d4bc8bc166c5d2d1143a35e133f27d75926f5f4 Mon Sep 17 00:00:00 2001 From: Crysple Date: Tue, 1 Jan 2019 13:00:43 +0800 Subject: [PATCH 15/23] support venv --- Makefile | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Makefile b/Makefile index 4b9d3f04c7..0eaa92c197 100644 --- a/Makefile +++ b/Makefile @@ -151,11 +151,6 @@ $(NNI_YARN_TARBALL): .PHONY: install-dependencies install-dependencies: $(NNI_NODE_TARBALL) $(NNI_YARN_TARBALL) - echo $(shell python3 -c 'import site; from pathlib import Path; print(Path(site.getsitepackages()[0]).parents[2])') - echo $(shell which python3) - echo $(shell python3 -c 'from distutils.sysconfig import get_python_lib; from pathlib import Path; print(Path(get_python_lib()).parents[2])') - echo $(IS_SYS_PYTHON) - echo $(shell id -u) #$(_INFO) Extracting Node.js $(_END) rm -rf $(NNI_NODE_FOLDER) mkdir $(NNI_NODE_FOLDER) From 1af7444653a5e4d0d5544f375ea94ce70e49357d Mon Sep 17 00:00:00 2001 From: Crysple Date: Tue, 1 Jan 2019 16:59:31 +0800 Subject: [PATCH 16/23] colorful output for mac --- Makefile | 20 +++++++++++++------- tools/nni_cmd/launcher.py | 5 ++--- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 0eaa92c197..ded9dab6b5 100644 --- a/Makefile +++ b/Makefile @@ -3,21 +3,27 @@ SHELL := /bin/bash PIP_INSTALL := python3 -m pip install --no-cache-dir PIP_UNINSTALL := python3 -m pip uninstall -## Colorful output -_INFO := $(shell echo -e '\e[1;36m') -_WARNING := $(shell echo -e '\e[1;33m') -_END := $(shell echo -e '\e[0m') - ## Detect OS UNAME_S := $(shell uname -s) ifeq ($(UNAME_S), Linux) - OS_SPEC := linux + OS_SPEC := linux else ifeq ($(UNAME_S), Darwin) - OS_SPEC := darwin + OS_SPEC := darwin else $(error platform $(UNAME_S) not supported) endif +## Colorful output +ifeq ($(OS_SPEC), linux) + _INFO := $(shell echo -e '\e[1;36m') + _WARNING := $(shell echo -e '\e[1;33m') + _END := $(shell echo -e '\e[0m') +else + _INFO := $(shell echo -e '\033[1;36m') + _WARNING := $(shell echo -e '\033[1;31m') + _END := $(shell echo -e '\033[0m') +endif + ## Install directories ROOT_FOLDER ?= $(shell python3 -c 'import site; from pathlib import Path; print(Path(site.getsitepackages()[0]).parents[2])') IS_SYS_PYTHON ?= $(shell [[ $(ROOT_FOLDER) == /usr* || $(ROOT_FOLDER) == /Library* ]] && echo TRUE || echo FALSE) diff --git a/tools/nni_cmd/launcher.py b/tools/nni_cmd/launcher.py index d2ec0d5539..8c076e88a6 100644 --- a/tools/nni_cmd/launcher.py +++ b/tools/nni_cmd/launcher.py @@ -32,11 +32,10 @@ from .config_utils import Config, Experiments from .common_utils import get_yml_content, get_json_content, print_error, print_normal, print_warning, detect_process, detect_port from .constants import * -import time import random -from pathlib import Path -from distutils.sysconfig import get_python_lib import site +import time +from pathlib import Path def get_log_path(config_file_name): '''generate stdout and stderr log path''' From c2255376b572c7535af9c47b4e21b6565f3a302c Mon Sep 17 00:00:00 2001 From: Crysple Date: Tue, 1 Jan 2019 17:38:44 +0800 Subject: [PATCH 17/23] colorful output for mac --- Makefile | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index ded9dab6b5..cf927188ce 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,11 @@ SHELL := /bin/bash PIP_INSTALL := python3 -m pip install --no-cache-dir PIP_UNINSTALL := python3 -m pip uninstall +## Colorful output +_INFO := $(shell echo -e '\033[1;36m') +_WARNING := $(shell echo -e '\033[1;33m') +_END := $(shell echo -e '\033[0m') + ## Detect OS UNAME_S := $(shell uname -s) ifeq ($(UNAME_S), Linux) @@ -13,17 +18,6 @@ else $(error platform $(UNAME_S) not supported) endif -## Colorful output -ifeq ($(OS_SPEC), linux) - _INFO := $(shell echo -e '\e[1;36m') - _WARNING := $(shell echo -e '\e[1;33m') - _END := $(shell echo -e '\e[0m') -else - _INFO := $(shell echo -e '\033[1;36m') - _WARNING := $(shell echo -e '\033[1;31m') - _END := $(shell echo -e '\033[0m') -endif - ## Install directories ROOT_FOLDER ?= $(shell python3 -c 'import site; from pathlib import Path; print(Path(site.getsitepackages()[0]).parents[2])') IS_SYS_PYTHON ?= $(shell [[ $(ROOT_FOLDER) == /usr* || $(ROOT_FOLDER) == /Library* ]] && echo TRUE || echo FALSE) From fc4f91ad6b0ea6aa04f47d55ddff0487cead182c Mon Sep 17 00:00:00 2001 From: Crysple Date: Thu, 3 Jan 2019 11:22:29 +0800 Subject: [PATCH 18/23] permission denied in /tmp --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index cf927188ce..925026022a 100644 --- a/Makefile +++ b/Makefile @@ -44,11 +44,11 @@ BIN_FOLDER ?= $(ROOT_FOLDER)/bin NNI_PKG_FOLDER ?= $(ROOT_FOLDER)/nni ## Dependency information -NNI_NODE_TARBALL ?= /tmp/nni-node-$(OS_SPEC)-x64.tar.xz -NNI_NODE_FOLDER = /tmp/nni-node-$(OS_SPEC)-x64 +NNI_NODE_TARBALL ?= /tmp/$(USER)/nni-node-$(OS_SPEC)-x64.tar.xz +NNI_NODE_FOLDER = /tmp/$(USER)/nni-node-$(OS_SPEC)-x64 NNI_NODE ?= $(BIN_FOLDER)/node -NNI_YARN_TARBALL ?= /tmp/nni-yarn.tar.gz -NNI_YARN_FOLDER ?= /tmp/nni-yarn +NNI_YARN_TARBALL ?= /tmp/$(USER)/nni-yarn.tar.gz +NNI_YARN_FOLDER ?= /tmp/$(USER)/nni-yarn NNI_YARN := PATH=$(BIN_FOLDER):$${PATH} $(NNI_YARN_FOLDER)/bin/yarn ## Version number From 2d670e27691b8a920a5d01a445f6dad1cf63ed01 Mon Sep 17 00:00:00 2001 From: Crysple Date: Thu, 3 Jan 2019 11:27:03 +0800 Subject: [PATCH 19/23] permission denied in /tmp --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 925026022a..f279b09218 100644 --- a/Makefile +++ b/Makefile @@ -143,10 +143,12 @@ clean: $(NNI_NODE_TARBALL): #$(_INFO) Downloading Node.js $(_END) + mkdir -p $(NNI_NODE_TARBALL) wget https://aka.ms/nni/nodejs-download/$(OS_SPEC) -O $(NNI_NODE_TARBALL) $(NNI_YARN_TARBALL): #$(_INFO) Downloading Yarn $(_END) + mkdir -p $(NNI_YARN_TARBALL) wget https://aka.ms/yarn-download -O $(NNI_YARN_TARBALL) .PHONY: install-dependencies From 49c9f8979d80c5c976709effa722391ba3abd345 Mon Sep 17 00:00:00 2001 From: Crysple Date: Thu, 3 Jan 2019 11:30:33 +0800 Subject: [PATCH 20/23] permission denied in /tmp --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index f279b09218..15ab96b3e3 100644 --- a/Makefile +++ b/Makefile @@ -44,11 +44,12 @@ BIN_FOLDER ?= $(ROOT_FOLDER)/bin NNI_PKG_FOLDER ?= $(ROOT_FOLDER)/nni ## Dependency information -NNI_NODE_TARBALL ?= /tmp/$(USER)/nni-node-$(OS_SPEC)-x64.tar.xz -NNI_NODE_FOLDER = /tmp/$(USER)/nni-node-$(OS_SPEC)-x64 +NNI_DEPENDENCY_FOLDER = /tmp/$(USER) +NNI_NODE_TARBALL ?= $(NNI_DEPENDENCY_FOLDER)/nni-node-$(OS_SPEC)-x64.tar.xz +NNI_NODE_FOLDER = $(NNI_DEPENDENCY_FOLDER)/nni-node-$(OS_SPEC)-x64 NNI_NODE ?= $(BIN_FOLDER)/node -NNI_YARN_TARBALL ?= /tmp/$(USER)/nni-yarn.tar.gz -NNI_YARN_FOLDER ?= /tmp/$(USER)/nni-yarn +NNI_YARN_TARBALL ?= $(NNI_DEPENDENCY_FOLDER)/nni-yarn.tar.gz +NNI_YARN_FOLDER ?= $(NNI_DEPENDENCY_FOLDER)/nni-yarn NNI_YARN := PATH=$(BIN_FOLDER):$${PATH} $(NNI_YARN_FOLDER)/bin/yarn ## Version number @@ -143,12 +144,11 @@ clean: $(NNI_NODE_TARBALL): #$(_INFO) Downloading Node.js $(_END) - mkdir -p $(NNI_NODE_TARBALL) + mkdir -p $(NNI_DEPENDENCY_FOLDER) wget https://aka.ms/nni/nodejs-download/$(OS_SPEC) -O $(NNI_NODE_TARBALL) $(NNI_YARN_TARBALL): #$(_INFO) Downloading Yarn $(_END) - mkdir -p $(NNI_YARN_TARBALL) wget https://aka.ms/yarn-download -O $(NNI_YARN_TARBALL) .PHONY: install-dependencies From 54c6db65cb51887130fa652632406067061bb0e5 Mon Sep 17 00:00:00 2001 From: Crysple Date: Fri, 4 Jan 2019 10:04:48 +0800 Subject: [PATCH 21/23] remove unused variable --- tools/nni_cmd/launcher.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/nni_cmd/launcher.py b/tools/nni_cmd/launcher.py index 8c076e88a6..c41d178b42 100644 --- a/tools/nni_cmd/launcher.py +++ b/tools/nni_cmd/launcher.py @@ -90,7 +90,6 @@ def start_rest_server(port, platform, mode, config_file_name, experiment_id=None entry_dir = os.path.join(python_dir, 'nni') # Nothing is found if not os.path.isfile(entry_file): - cannot_find_location = '" and "'.join([os.path.join(python_dir, 'nni') for python_dir in python_dirs]) raise Exception('Fail to find nni under both "%s" and "%s"' % (local_python_dir, python_dir)) cmds = ['node', entry_file, '--port', str(port), '--mode', platform, '--start_mode', mode] From 86fc93be6ae92f9c72fd50d750060f34ec00fd38 Mon Sep 17 00:00:00 2001 From: Crysple Date: Fri, 4 Jan 2019 11:18:23 +0800 Subject: [PATCH 22/23] final --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 15ab96b3e3..b8f06e3dff 100644 --- a/Makefile +++ b/Makefile @@ -45,6 +45,7 @@ NNI_PKG_FOLDER ?= $(ROOT_FOLDER)/nni ## Dependency information NNI_DEPENDENCY_FOLDER = /tmp/$(USER) +$(shell mkdir -p $(NNI_DEPENDENCY_FOLDER)) NNI_NODE_TARBALL ?= $(NNI_DEPENDENCY_FOLDER)/nni-node-$(OS_SPEC)-x64.tar.xz NNI_NODE_FOLDER = $(NNI_DEPENDENCY_FOLDER)/nni-node-$(OS_SPEC)-x64 NNI_NODE ?= $(BIN_FOLDER)/node @@ -144,7 +145,6 @@ clean: $(NNI_NODE_TARBALL): #$(_INFO) Downloading Node.js $(_END) - mkdir -p $(NNI_DEPENDENCY_FOLDER) wget https://aka.ms/nni/nodejs-download/$(OS_SPEC) -O $(NNI_NODE_TARBALL) $(NNI_YARN_TARBALL): From 9f0033b4f3bf8ab53e409632f581795bcd8263ab Mon Sep 17 00:00:00 2001 From: Crysple <871886504@qq.com> Date: Sun, 6 Jan 2019 12:18:32 +0800 Subject: [PATCH 23/23] remove build python --- Makefile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Makefile b/Makefile index b8f06e3dff..b26f2c95df 100644 --- a/Makefile +++ b/Makefile @@ -65,10 +65,6 @@ build: cd src/nni_manager && $(NNI_YARN) && $(NNI_YARN) build #$(_INFO) Building WebUI $(_END) cd src/webui && $(NNI_YARN) && $(NNI_YARN) build - #$(_INFO) Building Python SDK $(_END) - cd src/sdk/pynni && python3 setup.py build - #$(_INFO) Building nnictl $(_END) - cd tools && python3 setup.py build # All-in-one target for non-expert users # Installs NNI as well as its dependencies, and update bashrc to set PATH