Unverified Commit 74e5ea90 authored by Chi Song's avatar Chi Song Committed by GitHub
Browse files

improve windows install scripts (#2470)

1. Reduce error message if deleted folder not exists.
2. Reduce unneccessary messages.
3. Organize logic better for reinstall scenario.
parent 345684d5
...@@ -51,7 +51,7 @@ else { ...@@ -51,7 +51,7 @@ else {
$PIP_INSTALL = """$NNI_PYTHON3\python"" -m pip install " $PIP_INSTALL = """$NNI_PYTHON3\python"" -m pip install "
if (!(Test-Path $NNI_DEPENDENCY_FOLDER)) { if (!(Test-Path $NNI_DEPENDENCY_FOLDER)) {
New-Item $NNI_DEPENDENCY_FOLDER -ItemType Directory $null = New-Item $NNI_DEPENDENCY_FOLDER -ItemType Directory
} }
$NNI_NODE_ZIP = $NNI_DEPENDENCY_FOLDER + "\nni-node.zip" $NNI_NODE_ZIP = $NNI_DEPENDENCY_FOLDER + "\nni-node.zip"
$NNI_NODE_FOLDER = $NNI_DEPENDENCY_FOLDER + "\nni-node" $NNI_NODE_FOLDER = $NNI_DEPENDENCY_FOLDER + "\nni-node"
...@@ -112,17 +112,16 @@ if ($install_yarn) { ...@@ -112,17 +112,16 @@ if ($install_yarn) {
if ($Development) { if ($Development) {
$PYTHON_BUILD = "build" $PYTHON_BUILD = "build"
if (Test-Path $PYTHON_BUILD) { # To compat with file and links.
# To compat with file and links. cmd /c if exist "$PYTHON_BUILD" rmdir /s /q $PYTHON_BUILD
cmd /c rmdir /s /q $PYTHON_BUILD
} $null = New-Item $PYTHON_BUILD -ItemType Directory
New-Item $PYTHON_BUILD -ItemType Directory $null = New-Item -ItemType Junction -Path "$($PYTHON_BUILD)\nni" -Target "src\sdk\pynni\nni"
New-Item -ItemType Junction -Path "$($PYTHON_BUILD)\nni" -Target "src\sdk\pynni\nni" $null = New-Item -ItemType Junction -Path "$($PYTHON_BUILD)\nnicli" -Target "src\sdk\pycli\nnicli"
New-Item -ItemType Junction -Path "$($PYTHON_BUILD)\nnicli" -Target "src\sdk\pycli\nnicli" $null = New-Item -ItemType Junction -Path "$($PYTHON_BUILD)\nni_annotation" -Target "tools\nni_annotation"
New-Item -ItemType Junction -Path "$($PYTHON_BUILD)\nni_annotation" -Target "tools\nni_annotation" $null = New-Item -ItemType Junction -Path "$($PYTHON_BUILD)\nni_cmd" -Target "tools\nni_cmd"
New-Item -ItemType Junction -Path "$($PYTHON_BUILD)\nni_cmd" -Target "tools\nni_cmd" $null = New-Item -ItemType Junction -Path "$($PYTHON_BUILD)\nni_trial_tool" -Target "tools\nni_trial_tool"
New-Item -ItemType Junction -Path "$($PYTHON_BUILD)\nni_trial_tool" -Target "tools\nni_trial_tool" $null = New-Item -ItemType Junction -Path "$($PYTHON_BUILD)\nni_gpu_tool" -Target "tools\nni_gpu_tool"
New-Item -ItemType Junction -Path "$($PYTHON_BUILD)\nni_gpu_tool" -Target "tools\nni_gpu_tool"
Copy-Item setup.py $PYTHON_BUILD Copy-Item setup.py $PYTHON_BUILD
Copy-Item README.md $PYTHON_BUILD Copy-Item README.md $PYTHON_BUILD
...@@ -160,31 +159,34 @@ cmd /c $NNI_YARN build ...@@ -160,31 +159,34 @@ cmd /c $NNI_YARN build
cd ..\.. cd ..\..
## install-node-modules ## install-node-modules
if (Test-Path $NNI_PKG_FOLDER) {
# it needs to remove the whole folder for following copy. # it needs to remove the whole folder for following copy.
cmd /c rmdir /s /q $NNI_PKG_FOLDER cmd /c if exist "$NNI_PKG_FOLDER" rmdir /s /q $NNI_PKG_FOLDER
}
$NNI_PKG_FOLDER_STATIC = $NNI_PKG_FOLDER + "\static" $NNI_PKG_FOLDER_STATIC = $NNI_PKG_FOLDER + "\static"
$NASUI_PKG_FOLDER = $NNI_PKG_FOLDER + "\nasui" $NASUI_PKG_FOLDER = $NNI_PKG_FOLDER + "\nasui"
cmd /c if exist "src\nni_manager\dist\node_modules" rmdir /s /q src\nni_manager\dist\node_modules
cmd /c if exist "src\nni_manager\dist\static" rmdir /s /q src\nni_manager\dist\static
cmd /c if exist "src\nni_manager\dist\nasui" rmdir /s /q src\nni_manager\dist\nasui
if ($Development) { if ($Development) {
New-Item -ItemType Junction -Path $($NNI_PKG_FOLDER) -Target "src\nni_manager\dist" $null = New-Item -ItemType Junction -Path $NNI_PKG_FOLDER -Target "src\nni_manager\dist"
New-Item -ItemType Junction -Path "$($NNI_PKG_FOLDER)\node_modules" -Target "src\nni_manager\node_modules"
New-Item -ItemType Junction -Path $($NNI_PKG_FOLDER_STATIC) -Target "src\webui\build" $null = New-Item -ItemType Junction -Path "$($NNI_PKG_FOLDER)\node_modules" -Target "src\nni_manager\node_modules"
New-Item -ItemType Junction -Path $($NASUI_PKG_FOLDER) -Target "src\nasui\build" $null = New-Item -ItemType Junction -Path $NNI_PKG_FOLDER_STATIC -Target "src\webui\build"
$null = New-Item -ItemType Junction -Path $NASUI_PKG_FOLDER -Target "src\nasui\build"
} }
else { else {
Copy-Item "src\nni_manager\dist" $NNI_PKG_FOLDER -Recurse Copy-Item "src\nni_manager\dist" $NNI_PKG_FOLDER -Recurse
Copy-Item "src\webui\build" $NNI_PKG_FOLDER_STATIC -Recurse Copy-Item "src\webui\build" $NNI_PKG_FOLDER_STATIC -Recurse
Copy-Item "src\nasui\build" $NASUI_PKG_FOLDER -Recurse Copy-Item "src\nasui\build" $NASUI_PKG_FOLDER -Recurse
}
Copy-Item "src\nni_manager\package.json" $NNI_PKG_FOLDER Copy-Item "src\nni_manager\package.json" $NNI_PKG_FOLDER
$PKG_JSON = $NNI_PKG_FOLDER + "\package.json" $PKG_JSON = $NNI_PKG_FOLDER + "\package.json"
(Get-Content $PKG_JSON).replace($NNI_VERSION_TEMPLATE, $NNI_VERSION_VALUE) | Set-Content $PKG_JSON (Get-Content $PKG_JSON).replace($NNI_VERSION_TEMPLATE, $NNI_VERSION_VALUE) | Set-Content $PKG_JSON
Copy-Item "src\nasui\server.js" $NASUI_PKG_FOLDER -Recurse
if (!$Development) {
cmd /c $NNI_YARN --prod --cwd $NNI_PKG_FOLDER cmd /c $NNI_YARN --prod --cwd $NNI_PKG_FOLDER
} }
Copy-Item "src\nasui\server.js" $NASUI_PKG_FOLDER
...@@ -4,12 +4,12 @@ $env:PYTHONIOENCODING = "UTF-8" ...@@ -4,12 +4,12 @@ $env:PYTHONIOENCODING = "UTF-8"
if($env:VIRTUAL_ENV){ if($env:VIRTUAL_ENV){
$NNI_PYTHON3 = $env:VIRTUAL_ENV + "\Scripts" $NNI_PYTHON3 = $env:VIRTUAL_ENV + "\Scripts"
$NNI_PKG_FOLDER = $env:VIRTUAL_ENV + "\nni" $NNI_PKG_FOLDER = $env:VIRTUAL_ENV + "\nni"
cmd /c del "$NNI_PYTHON3\node.exe" cmd /c if exist "$NNI_PYTHON3\node.exe" del "$NNI_PYTHON3\node.exe"
} }
else{ else{
$NNI_PYTHON3 = $(python -c 'import site; from pathlib import Path; print(Path(site.getsitepackages()[0]))') $NNI_PYTHON3 = $(python -c 'import site; from pathlib import Path; print(Path(site.getsitepackages()[0]))')
$NNI_PKG_FOLDER = $NNI_PYTHON3 + "\nni" $NNI_PKG_FOLDER = $NNI_PYTHON3 + "\nni"
cmd /c del "$NNI_PYTHON3\Scripts\node.exe" cmd /c if exist "$NNI_PYTHON3\Scripts\node.exe" del "$NNI_PYTHON3\Scripts\node.exe"
} }
$PIP_UNINSTALL = """$NNI_PYTHON3\python"" -m pip uninstall -y " $PIP_UNINSTALL = """$NNI_PYTHON3\python"" -m pip uninstall -y "
...@@ -17,16 +17,16 @@ $NNI_NODE_FOLDER = $NNI_DEPENDENCY_FOLDER+"\nni-node" ...@@ -17,16 +17,16 @@ $NNI_NODE_FOLDER = $NNI_DEPENDENCY_FOLDER+"\nni-node"
$NNI_YARN_FOLDER = $NNI_DEPENDENCY_FOLDER+"\nni-yarn" $NNI_YARN_FOLDER = $NNI_DEPENDENCY_FOLDER+"\nni-yarn"
# uninstall # uninstall
cmd /c rmdir /s /q $NNI_PKG_FOLDER cmd /c if exist "$NNI_PKG_FOLDER" rmdir /s /q $NNI_PKG_FOLDER
cmd /c $PIP_UNINSTALL "nni" cmd /c $PIP_UNINSTALL "nni"
# clean up # clean up
cmd /c rmdir /s /q "build" cmd /c if exist "build" rmdir /s /q "build"
cmd /c rmdir /s /q "src\nni_manager\dist" cmd /c if exist "src\nni_manager\dist" rmdir /s /q "src\nni_manager\dist"
cmd /c rmdir /s /q "src\nni_manager\node_modules" cmd /c if exist "src\nni_manager\node_modules" rmdir /s /q "src\nni_manager\node_modules"
cmd /c rmdir /s /q "src\webui\build" cmd /c if exist "src\webui\build" rmdir /s /q "src\webui\build"
cmd /c rmdir /s /q "src\webui\node_modules" cmd /c if exist "src\webui\node_modules" rmdir /s /q "src\webui\node_modules"
cmd /c rmdir /s /q "src\nasui\build" cmd /c if exist "src\nasui\build" rmdir /s /q "src\nasui\build"
cmd /c rmdir /s /q "src\nasui\node_modules" cmd /c if exist "src\nasui\node_modules" rmdir /s /q "src\nasui\node_modules"
cmd /c rmdir /s /q $NNI_YARN_FOLDER cmd /c if exist "$NNI_YARN_FOLDER" rmdir /s /q $NNI_YARN_FOLDER
cmd /c rmdir /s /q $NNI_NODE_FOLDER cmd /c if exist "$NNI_NODE_FOLDER" rmdir /s /q $NNI_NODE_FOLDER
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