Commit 9210fd6b authored by Gems Guo's avatar Gems Guo Committed by goooxu
Browse files

Integrate version number of NNI

parent 9397b6f6
...@@ -3,22 +3,21 @@ ...@@ -3,22 +3,21 @@
PIP_INSTALL := python3 -m pip install PIP_INSTALL := python3 -m pip install
PIP_UNINSTALL := python3 -m pip uninstall PIP_UNINSTALL := python3 -m pip uninstall
# detect OS ## 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) UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S), Linux) ifeq ($(UNAME_S), Linux)
OS_SPEC := linux OS_SPEC := linux
## Colorful output
_INFO := $(shell echo -e '\e[1;36m')
_WARNING := $(shell echo -e '\e[1;33m')
_END := $(shell echo -e '\e[0m')
else ifeq ($(UNAME_S), Darwin) else ifeq ($(UNAME_S), Darwin)
OS_SPEC := darwin OS_SPEC := darwin
else else
$(error platform $(UNAME_S) not supported) $(error platform $(UNAME_S) not supported)
endif endif
## Install directories ## Install directories
ifeq ($(shell id -u), 0) # is root ifeq ($(shell id -u), 0) # is root
_ROOT := 1 _ROOT := 1
...@@ -34,7 +33,6 @@ endif ...@@ -34,7 +33,6 @@ endif
BASH_COMP_SCRIPT := $(BASH_COMP_PREFIX)/nnictl BASH_COMP_SCRIPT := $(BASH_COMP_PREFIX)/nnictl
NNI_INSTALL_PATH ?= $(INSTALL_PREFIX)/nni NNI_INSTALL_PATH ?= $(INSTALL_PREFIX)/nni
NNI_TMP_PATH ?= /tmp
BIN_FOLDER ?= $(ROOT_FOLDER)/bin BIN_FOLDER ?= $(ROOT_FOLDER)/bin
NNI_PKG_FOLDER ?= $(ROOT_FOLDER)/nni NNI_PKG_FOLDER ?= $(ROOT_FOLDER)/nni
...@@ -47,6 +45,9 @@ NNI_YARN_TARBALL ?= /tmp/nni-yarn.tar.gz ...@@ -47,6 +45,9 @@ NNI_YARN_TARBALL ?= /tmp/nni-yarn.tar.gz
NNI_YARN_FOLDER ?= /tmp/nni-yarn NNI_YARN_FOLDER ?= /tmp/nni-yarn
NNI_YARN := PATH=$(BIN_FOLDER):$${PATH} $(NNI_YARN_FOLDER)/bin/yarn NNI_YARN := PATH=$(BIN_FOLDER):$${PATH} $(NNI_YARN_FOLDER)/bin/yarn
## Version number
NNI_VERSION = $(shell git describe --tags)
# Main targets # Main targets
.PHONY: build .PHONY: build
...@@ -159,18 +160,18 @@ install-dependencies: $(NNI_NODE_TARBALL) $(NNI_YARN_TARBALL) ...@@ -159,18 +160,18 @@ install-dependencies: $(NNI_NODE_TARBALL) $(NNI_YARN_TARBALL)
.PHONY: install-python-modules .PHONY: install-python-modules
install-python-modules: install-python-modules:
#$(_INFO) Installing Python SDK $(_END) #$(_INFO) Installing Python SDK $(_END)
cd src/sdk/pynni && $(PIP_INSTALL) $(PIP_MODE) . cd src/sdk/pynni && sed -ie 's/NNI_VERSION/$(NNI_VERSION)/' setup.py && $(PIP_INSTALL) $(PIP_MODE) .
#$(_INFO) Installing nnictl $(_END) #$(_INFO) Installing nnictl $(_END)
cd tools && $(PIP_INSTALL) $(PIP_MODE) . cd tools && sed -ie 's/NNI_VERSION/$(NNI_VERSION)/' setup.py && $(PIP_INSTALL) $(PIP_MODE) .
.PHONY: dev-install-python-modules .PHONY: dev-install-python-modules
dev-install-python-modules: dev-install-python-modules:
#$(_INFO) Installing Python SDK $(_END) #$(_INFO) Installing Python SDK $(_END)
cd src/sdk/pynni && $(PIP_INSTALL) $(PIP_MODE) -e . cd src/sdk/pynni && sed -ie 's/NNI_VERSION/$(NNI_VERSION)/' setup.py && $(PIP_INSTALL) $(PIP_MODE) -e .
#$(_INFO) Installing nnictl $(_END) #$(_INFO) Installing nnictl $(_END)
cd tools && $(PIP_INSTALL) $(PIP_MODE) -e . cd tools && sed -ie 's/NNI_VERSION/$(NNI_VERSION)/' setup.py && $(PIP_INSTALL) $(PIP_MODE) -e .
.PHONY: install-node-modules .PHONY: install-node-modules
install-node-modules: install-node-modules:
...@@ -178,6 +179,7 @@ install-node-modules: ...@@ -178,6 +179,7 @@ install-node-modules:
rm -rf $(NNI_PKG_FOLDER) rm -rf $(NNI_PKG_FOLDER)
cp -r src/nni_manager/dist $(NNI_PKG_FOLDER) cp -r src/nni_manager/dist $(NNI_PKG_FOLDER)
cp src/nni_manager/package.json $(NNI_PKG_FOLDER) cp src/nni_manager/package.json $(NNI_PKG_FOLDER)
sed -ie 's/NNI_VERSION/$(NNI_VERSION)/' $(NNI_PKG_FOLDER)/package.json
$(NNI_YARN) --prod --cwd $(NNI_PKG_FOLDER) $(NNI_YARN) --prod --cwd $(NNI_PKG_FOLDER)
cp -r src/webui/build $(NNI_PKG_FOLDER)/static cp -r src/webui/build $(NNI_PKG_FOLDER)/static
......
...@@ -11,6 +11,8 @@ else ...@@ -11,6 +11,8 @@ else
$(error platform $(UNAME_S) not supported) $(error platform $(UNAME_S) not supported)
endif endif
NNI_VERSION = $(shell git describe --tags)
.PHONY: build .PHONY: build
build: build:
python3 -m pip install --user --upgrade setuptools wheel python3 -m pip install --user --upgrade setuptools wheel
...@@ -24,9 +26,10 @@ build: ...@@ -24,9 +26,10 @@ build:
cp -r $(CWD)../../src/nni_manager/dist $(CWD)nni cp -r $(CWD)../../src/nni_manager/dist $(CWD)nni
cp -r $(CWD)../../src/webui/build $(CWD)nni/static cp -r $(CWD)../../src/webui/build $(CWD)nni/static
cp $(CWD)../../src/nni_manager/package.json $(CWD)nni cp $(CWD)../../src/nni_manager/package.json $(CWD)nni
sed -ie 's/NNI_VERSION/$(NNI_VERSION)/' $(CWD)nni/package.json
cd $(CWD)nni && yarn --prod cd $(CWD)nni && yarn --prod
cd $(CWD) && python3 setup.py bdist_wheel -p $(WHEEL_SPEC) cd $(CWD) && sed -ie 's/NNI_VERSION/$(NNI_VERSION)/' setup.py && python3 setup.py bdist_wheel -p $(WHEEL_SPEC)
cd $(CWD)../../src/sdk/pynni && python3 setup.py bdist_wheel cd $(CWD)../../src/sdk/pynni && sed -ie 's/NNI_VERSION/$(NNI_VERSION)/' setup.py && python3 setup.py bdist_wheel
cp -r $(CWD)../../src/sdk/pynni/dist/*.whl $(CWD)dist cp -r $(CWD)../../src/sdk/pynni/dist/*.whl $(CWD)dist
cd $(CWD) cd $(CWD)
...@@ -37,9 +40,9 @@ upload: ...@@ -37,9 +40,9 @@ upload:
.PHONY: clean .PHONY: clean
clean: clean:
-rm -rf $(CWD)../../src/sdk/pynni/dist/*.whl rm -rf $(CWD)../../src/sdk/pynni/dist
-rm -rf $(CWD)build rm -rf $(CWD)build
-rm -rf $(CWD)dist rm -rf $(CWD)dist
-rm -rf $(CWD)nni rm -rf $(CWD)nni
-rm -rf $(CWD)nni.egg-info rm -rf $(CWD)nni.egg-info
-rm -rf $(CWD)node-$(OS_SPEC)-x64 rm -rf $(CWD)node-$(OS_SPEC)-x64
\ No newline at end of file \ No newline at end of file
...@@ -20,7 +20,7 @@ with open('../../README.md', 'r') as fh: ...@@ -20,7 +20,7 @@ with open('../../README.md', 'r') as fh:
setuptools.setup( setuptools.setup(
name = 'nni', name = 'nni',
version = '0.4', version = 'NNI_VERSION',
author = 'Microsoft NNI team', author = 'Microsoft NNI team',
author_email = 'nni@microsoft.com', author_email = 'nni@microsoft.com',
description = 'Neural Network Intelligence package', description = 'Neural Network Intelligence package',
......
...@@ -35,7 +35,7 @@ class CustomInstallCommand(install): ...@@ -35,7 +35,7 @@ class CustomInstallCommand(install):
setup( setup(
name = 'nni', name = 'nni',
version = '0.4', version = 'NNI_VERSION',
author = 'Microsoft NNI Team', author = 'Microsoft NNI Team',
author_email = 'nni@microsoft.com', author_email = 'nni@microsoft.com',
description = 'Neural Network Intelligence project', description = 'Neural Network Intelligence project',
......
{ {
"name": "nni", "name": "nni",
"version": "1.0.0", "version": "NNI_VERSION",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"postbuild": "cp -rf scripts ./dist/ && cp -rf config ./dist/", "postbuild": "cp -rf scripts ./dist/ && cp -rf config ./dist/",
......
...@@ -61,6 +61,7 @@ class NNIRestHandler { ...@@ -61,6 +61,7 @@ class NNIRestHandler {
next(); next();
}); });
this.version(router);
this.checkStatus(router); this.checkStatus(router);
this.getExperimentProfile(router); this.getExperimentProfile(router);
this.updateExperimentProfile(router); this.updateExperimentProfile(router);
...@@ -108,6 +109,13 @@ class NNIRestHandler { ...@@ -108,6 +109,13 @@ class NNIRestHandler {
this.log.error(err); this.log.error(err);
} }
private version(router: Router): void {
router.get('/version', async (req: Request, res: Response) => {
const pkg = await import(path.join(__dirname, '..', 'package.json'));
res.send(pkg.version);
});
}
// TODO add validators for request params, query, body // TODO add validators for request params, query, body
private checkStatus(router: Router): void { private checkStatus(router: Router): void {
router.get('/check-status', (req: Request, res: Response) => { router.get('/check-status', (req: Request, res: Response) => {
......
...@@ -27,7 +27,7 @@ def read(fname): ...@@ -27,7 +27,7 @@ def read(fname):
setuptools.setup( setuptools.setup(
name = 'nni-sdk', name = 'nni-sdk',
version = '0.4', version = 'NNI_VERSION',
packages = setuptools.find_packages(exclude=['tests']), packages = setuptools.find_packages(exclude=['tests']),
python_requires = '>=3.5', python_requires = '>=3.5',
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
import argparse import argparse
import pkg_resources
from .launcher import create_experiment, resume_experiment from .launcher import create_experiment, resume_experiment
from .updater import update_searchspace, update_concurrency, update_duration, update_trialnum from .updater import update_searchspace, update_concurrency, update_duration, update_trialnum
from .nnictl_utils import * from .nnictl_utils import *
...@@ -27,13 +28,17 @@ from .package_management import * ...@@ -27,13 +28,17 @@ from .package_management import *
from .constants import * from .constants import *
from .tensorboard_utils import * from .tensorboard_utils import *
def nni_help_info(*args): def nni_info(*args):
print('please run "nnictl {positional argument} --help" to see nnictl guidance') if args[0].version:
print(pkg_resources.get_distribution('nnictl').version)
else:
print('please run "nnictl {positional argument} --help" to see nnictl guidance')
def parse_args(): def parse_args():
'''Definite the arguments users need to follow and input''' '''Definite the arguments users need to follow and input'''
parser = argparse.ArgumentParser(prog='nnictl', description='use nnictl command to control nni experiments') parser = argparse.ArgumentParser(prog='nnictl', description='use nnictl command to control nni experiments')
parser.set_defaults(func=nni_help_info) parser.add_argument('--version', '-v', action='store_true')
parser.set_defaults(func=nni_info)
# create subparsers for args with sub values # create subparsers for args with sub values
subparsers = parser.add_subparsers() subparsers = parser.add_subparsers()
......
...@@ -2,7 +2,7 @@ import setuptools ...@@ -2,7 +2,7 @@ import setuptools
setuptools.setup( setuptools.setup(
name = 'nnictl', name = 'nnictl',
version = '0.4', version = 'NNI_VERSION',
packages = setuptools.find_packages(exclude=['*test*']), packages = setuptools.find_packages(exclude=['*test*']),
python_requires = '>=3.5', python_requires = '>=3.5',
......
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