Skip to content

Commit

Permalink
Merge pull request #4 from SparkSnail/dev-windows
Browse files Browse the repository at this point in the history
fix nnictl
  • Loading branch information
SparkSnail authored Mar 28, 2019
2 parents 7f69eea + 16bc964 commit 285bfa9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
19 changes: 19 additions & 0 deletions tools/nni_cmd/command_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,22 @@ def kill_command(pid):
else:
cmds = ['kill', str(pid)]
call(cmds)

def install_package_command(package_name):
'''install python package from pip'''
#TODO refactor python logic
if sys.platform == "win32":
cmds = 'python -m pip install --user {0}'.format(package_name)
else:
cmds = 'python3 -m pip install --user {0}'.format(package_name)
call(cmds, shell=True)

def install_requirements_command(requirements_path):
'''install requirements.txt'''
cmds = 'cd ' + requirements_path + ' && {0} -m pip install --user -r requirements.txt'
#TODO refactor python logic
if sys.platform == "win32":
cmds = cmds.format('python')
else:
cmds = cmds.format('python3')
call(cmds, shell=True)
7 changes: 2 additions & 5 deletions tools/nni_cmd/package_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,14 @@
from subprocess import call
from .constants import PACKAGE_REQUIREMENTS
from .common_utils import print_normal, print_error
from .command_utils import install_requirements_command

def process_install(package_name):
if PACKAGE_REQUIREMENTS.get(package_name) is None:
print_error('{0} is not supported!' % package_name)
else:
requirements_path = os.path.join(nni.__path__[0], PACKAGE_REQUIREMENTS[package_name])
if sys.platform == "win32":
cmds = 'cd ' + requirements_path + ' && python -m pip install --user -r requirements.txt'
else:
cmds = 'cd ' + requirements_path + ' && python3 -m pip install --user -r requirements.txt'
call(cmds, shell=True)
install_requirements_command(requirements_path)

def package_install(args):
'''install packages'''
Expand Down
7 changes: 2 additions & 5 deletions tools/nni_cmd/ssh_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@
import os
from .common_utils import print_error
from subprocess import call
from .command_utils import install_package_command

def check_environment():
'''check if paramiko is installed'''
try:
import paramiko
except:
if sys.platform == "win32":
cmds = 'python -m pip install --user paramiko'
else:
cmds = 'python3 -m pip install --user paramiko'
call(cmds, shell=True)
install_package_command('paramiko')

def copy_remote_directory_to_local(sftp, remote_path, local_path):
'''copy remote directory to local machine'''
Expand Down

0 comments on commit 285bfa9

Please sign in to comment.