From db004cd231a5a25d8bef921a8a2428424f3fe6c2 Mon Sep 17 00:00:00 2001 From: Marcin Salnik Date: Mon, 17 Apr 2023 08:52:04 +0200 Subject: [PATCH] Move automaded-test.sh content out of this repo --- .gradient/automated-test.sh | 78 ----------------------------------- .gradient/prepare-datasets.sh | 27 +++++++++--- 2 files changed, 22 insertions(+), 83 deletions(-) delete mode 100755 .gradient/automated-test.sh diff --git a/.gradient/automated-test.sh b/.gradient/automated-test.sh deleted file mode 100755 index 5630dc3..0000000 --- a/.gradient/automated-test.sh +++ /dev/null @@ -1,78 +0,0 @@ -#! /usr/bin/env bash -# Copyright (c) 2022 Graphcore Ltd. All rights reserved. -# -# The entry point for the automated testing on the Paperspace platform -# this script is meant to be launched in the docker image as the entry point. -# -# Arguments: -# 1: Gradient API key -# 2: Dataset ID -# 3: Version ID -# 4: Either the runtime in which we are running or 'upload-reports' -# 5: Folder in which to save/look for tar.gz report archives -# 6: Examples utils spec file to process and benchmark -# 7: Huggingface token -# 8: examples-utils revision -# @:9 other arguments are passed to the `examples_utils platform_assesment` command - -set -x - -upload_report() { - # Uploads files to a gradient dataset - python -m pip install gradient - - gradient apiKey ${1} - - for file in `find ${5} -name "*.tar.gz"` - do - echo uploading $file - gradient datasets files put --id ${2}:${3} --source-path $file - done - gradient datasets versions commit --id ${2}:${3} - - echo Committed version: ${2}:${3} -} - -run_tests(){ - git submodule update -j 5 --init - # set variable matching the standard Paperspace entry point - export PIP_DISABLE_PIP_VERSION_CHECK=1 - - export VIRTUAL_ENV="/some/fake/venv/GC-automated-paperspace-test-${4}" - LOG_FOLDER="${5}/log_${4}_$(date +'%Y-%m-%d-%H_%M_%S')" - TEST_CONFIG_FILE="${6}" - mkdir -p ${LOG_FOLDER} - cd /notebooks/ - python -m examples_utils platform_assessment --spec ${TEST_CONFIG_FILE} "${@:9}" \ - --log-dir $LOG_FOLDER \ - --gc-monitor \ - --cloning-directory /tmp/clones \ - --additional-metrics - - tar -czvf "${LOG_FOLDER}.tar.gz" ${LOG_FOLDER} - echo "PAPERSPACE-AUTOMATED-TESTING: Testing complete" -} -# Prep the huggingface token -export HUGGING_FACE_HUB_TOKEN=${7} -if [ "${8}" == "unset" ]; then - EXAMPLES_UTILS_REV=latest_stable -else - EXAMPLES_UTILS_REV=${8} -fi - -python -m pip install "examples-utils[jupyter] @ git+https://github.com/graphcore/examples-utils@${EXAMPLES_UTILS_REV}" -python -m pip install gradient -# In sh single equal is needed for string compare. -if [ "${4}" = "upload-reports" ] -then - echo "Uploading report" - upload_report ${@} -else - echo "Running tests" - run_tests ${@} -fi -# Make the notebook stop itself -echo "Test finished shutting down notebook" -sleep 5 -gradient apiKey ${1} -gradient notebooks stop --id ${PAPERSPACE_METRIC_WORKLOAD_ID} diff --git a/.gradient/prepare-datasets.sh b/.gradient/prepare-datasets.sh index 3cd8b60..d0553a3 100755 --- a/.gradient/prepare-datasets.sh +++ b/.gradient/prepare-datasets.sh @@ -1,22 +1,39 @@ #! /usr/bin/env bash set -uxo pipefail -if [ ! "$(command -v fuse-overlayfs)" ] -then +run-tests() { + [ "${8}" == "unset" ] && EXAMPLES_UTILS_REV=latest_stable || EXAMPLES_UTILS_REV=${8} + export VIRTUAL_ENV="/some/fake/venv/GC-automated-paperspace-test-${4}" + python -m pip install "examples-utils[jupyter] @ git+https://github.com/graphcore/examples-utils@${EXAMPLES_UTILS_REV}" + python -m pip install gradient + python -m examples_utils run_paperspace_tests \ + --api_key ${1} \ + --dataset ${2} \ + --version ${3} \ + --upload_report ${4} \ + --reports_folder ${5} \ + --spec ${6} \ + --token ${7} \ + ${@:9} +} + +if [ ! "$(command -v fuse-overlayfs)" ]; then echo "fuse-overlayfs not found installing - please update to our latest image" apt update -y apt install -o DPkg::Lock::Timeout=120 -y psmisc libfuse3-dev fuse-overlayfs fi - echo "Starting preparation of datasets" /notebooks/.gradient/symlink_datasets_and_caches.py +# pre-install the correct version of optimum for this release +python3 -m pip install "optimum-graphcore>=0.5, <0.6" echo "Finished running setup.sh." + # Run automated test if specified if [[ "${1:-}" == 'test' ]]; then - /notebooks/.gradient/automated-test.sh "${@:2}" + run-tests "${@:2}" elif [[ "${2:-}" == 'test' ]]; then - /notebooks/.gradient/automated-test.sh "${@:3}" + run-tests "${@:3}" fi