offload scripts from win-test.sh
authorKarl Ostmo <kostmo@gmail.com>
Mon, 1 Apr 2019 20:01:29 +0000 (13:01 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Mon, 1 Apr 2019 20:04:30 +0000 (13:04 -0700)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/18601

Differential Revision: D14711856

Pulled By: kostmo

fbshipit-source-id: 75fe620541fe2903f69a53dbd1b6d51a0d718113

.jenkins/pytorch/win-test-helpers/download_image.py [new file with mode: 0755]
.jenkins/pytorch/win-test.sh

diff --git a/.jenkins/pytorch/win-test-helpers/download_image.py b/.jenkins/pytorch/win-test-helpers/download_image.py
new file mode 100755 (executable)
index 0000000..1356ee4
--- /dev/null
@@ -0,0 +1,19 @@
+import os
+import sys
+import boto3
+import botocore
+
+IMAGE_COMMIT_TAG = os.getenv('IMAGE_COMMIT_TAG')
+
+session = boto3.session.Session()
+s3 = session.resource('s3')
+BUCKET_NAME = 'ossci-windows-build'
+KEY = 'pytorch/' + IMAGE_COMMIT_TAG + '.7z'
+LOCAL_FILE_PATH = sys.argv[1]
+try:
+    s3.Bucket(BUCKET_NAME).download_file(KEY, LOCAL_FILE_PATH)
+except botocore.exceptions.ClientError as e:
+    if e.response['Error']['Code'] == "404":
+        print("The object does not exist.")
+    else:
+        raise
index 330a956..70c0182 100755 (executable)
@@ -1,7 +1,9 @@
 #!/bin/bash -e
 
 COMPACT_JOB_NAME=pytorch-win-ws2016-cuda9-cudnn7-py3-test
-source "$(dirname "${BASH_SOURCE[0]}")/common.sh"
+
+SCRIPT_PARENT_DIR=$(dirname "${BASH_SOURCE[0]}")
+source "$SCRIPT_PARENT_DIR/common.sh"
 
 export IMAGE_COMMIT_TAG=${BUILD_ENVIRONMENT}-${IMAGE_COMMIT_ID}
 if [[ ${JOB_NAME} == *"develop"* ]]; then
@@ -17,29 +19,6 @@ if [ ! -z "$(ls $TMP_DIR/ci_scripts/*)" ]; then
     rm $TMP_DIR/ci_scripts/*
 fi
 
-cat >$TMP_DIR/ci_scripts/download_image.py << EOL
-
-import os
-import sys
-import boto3
-import botocore
-
-IMAGE_COMMIT_TAG = os.getenv('IMAGE_COMMIT_TAG')
-
-session = boto3.session.Session()
-s3 = session.resource('s3')
-BUCKET_NAME = 'ossci-windows-build'
-KEY = 'pytorch/'+IMAGE_COMMIT_TAG+'.7z'
-LOCAL_FILE_PATH = sys.argv[1]
-try:
-    s3.Bucket(BUCKET_NAME).download_file(KEY, LOCAL_FILE_PATH)
-except botocore.exceptions.ClientError as e:
-    if e.response['Error']['Code'] == "404":
-        print("The object does not exist.")
-    else:
-        raise
-
-EOL
 
 cat >$TMP_DIR/ci_scripts/setup_pytorch_env.bat <<EOL
 
@@ -161,6 +140,15 @@ set PATH=C:\\Program Files\\NVIDIA Corporation\\NvToolsExt/bin/x64;%TMP_DIR_WIN%
 test_api.exe --gtest_filter="-IntegrationTest.MNIST*"
 EOL
 
+
+
+SCRIPT_HELPERS_DIR=$SCRIPT_PARENT_DIR/win-test-helpers
+CI_SCRIPTS_DIR=$TMP_DIR/ci_scripts
+
+# Used by setup_pytorch_env.bat:
+cp $SCRIPT_HELPERS_DIR/download_image.py $CI_SCRIPTS_DIR
+
+
 run_tests() {
     if [ -z "${JOB_BASE_NAME}" ] || [[ "${JOB_BASE_NAME}" == *-test ]]; then
         $TMP_DIR/ci_scripts/test_python_nn.bat && \