Skip to content

Commit

Permalink
Merge pull request #17 from tmckayus/addchecks
Browse files Browse the repository at this point in the history
Add a check for Python3 and validate NGC api key (with helm)
  • Loading branch information
SchultzC authored Dec 1, 2022
2 parents 89de9d3 + 8003a2d commit ed5ab08
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
22 changes: 21 additions & 1 deletion cloud-scripts/build-cuopt-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,37 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

if ! command -v python3 &> /dev/null; then
echo Python3 must be installed and on your path
exit 1
fi

DIR=$(dirname $(realpath "$0"))
if [ "$API_KEY" == "" ]; then
read -sp 'Enter a NGC api-key to access cuOpt resources: ' API_KEY
fi

if command -v helm &> /dev/null; then
echo helm installed, checking API_KEY
rm -f /tmp/cuopt-22.10.1.tgz
helm fetch https://helm.ngc.nvidia.com/nvidia/cuopt/charts/cuopt-22.10.1.tgz --username='$oauthtoken' --password=$API_KEY -d /tmp
if [ "$?" -eq 0 ]; then
rm -f /tmp/cuopt-22.10.1.tgz
echo API_KEY is valid
else
echo Failed to download cuopt helm chart, API_KEY is invalid. Please try again with a valid NGC api key.
exit 1
fi
else
echo helm is not installed, skipping API_KEY check
fi

TF_VAR_api_key=$API_KEY terraform apply --auto-approve
if [ "$?" -ne 0 ]; then
exit -1
fi
terraform output --json outputs > values.json
$DIR/utilities/parse.py values.json values.sh
python3 $DIR/utilities/parse.py values.json values.sh
source values.sh

nmsg="The address of the cuOpt notebook server is $ip:30001"
Expand Down
2 changes: 1 addition & 1 deletion cloud-scripts/utilities/parse.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3

# SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: MIT
Expand Down

0 comments on commit ed5ab08

Please sign in to comment.