diff --git a/ci/test_notebooks.sh b/ci/test_notebooks.sh index 7f5f35219b0..0ea188ff194 100755 --- a/ci/test_notebooks.sh +++ b/ci/test_notebooks.sh @@ -29,33 +29,5 @@ rapids-mamba-retry install \ --channel "${PYTHON_CHANNEL}" \ cudf libcudf -NBTEST="$(realpath "$(dirname "$0")/utils/nbtest.sh")" -pushd notebooks - -# Add notebooks that should be skipped here -# (space-separated list of filenames without paths) -SKIPNBS="" - -EXITCODE=0 -trap "EXITCODE=1" ERR -set +e -for nb in $(find . -name "*.ipynb"); do - nbBasename=$(basename ${nb}) - # Skip all notebooks that use dask (in the code or even in their name) - if ((echo ${nb} | grep -qi dask) || \ - (grep -q dask ${nb})); then - echo "--------------------------------------------------------------------------------" - echo "SKIPPING: ${nb} (suspected Dask usage, not currently automatable)" - echo "--------------------------------------------------------------------------------" - elif (echo " ${SKIPNBS} " | grep -q " ${nbBasename} "); then - echo "--------------------------------------------------------------------------------" - echo "SKIPPING: ${nb} (listed in skip list)" - echo "--------------------------------------------------------------------------------" - else - nvidia-smi - ${NBTEST} ${nbBasename} - fi -done - -rapids-logger "Test script exiting with value: $EXITCODE" -exit ${EXITCODE} +# Run all notebooks with nbval +python -m pytest -v --nbval --nbval-lax notebooks/ diff --git a/ci/utils/nbtest.sh b/ci/utils/nbtest.sh deleted file mode 100755 index 2a94e2d0695..00000000000 --- a/ci/utils/nbtest.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -# Copyright (c) 2020-2022, NVIDIA CORPORATION. - -MAGIC_OVERRIDE_CODE=" -def my_run_line_magic(*args, **kwargs): - g=globals() - l={} - for a in args: - try: - exec(str(a),g,l) - except Exception as e: - print('WARNING: %s\n While executing this magic function code:\n%s\n continuing...\n' % (e, a)) - else: - g.update(l) - -def my_run_cell_magic(*args, **kwargs): - my_run_line_magic(*args, **kwargs) - -get_ipython().run_line_magic=my_run_line_magic -get_ipython().run_cell_magic=my_run_cell_magic - -" - -NO_COLORS=--colors=NoColor -EXITCODE=0 -NBTMPDIR="$WORKSPACE/tmp" -mkdir -p ${NBTMPDIR} - -for nb in $*; do - NBFILENAME=$1 - NBNAME=${NBFILENAME%.*} - NBNAME=${NBNAME##*/} - NBTESTSCRIPT=${NBTMPDIR}/${NBNAME}-test.py - shift - - echo -------------------------------------------------------------------------------- - echo STARTING: ${NBNAME} - echo -------------------------------------------------------------------------------- - jupyter nbconvert --to script ${NBFILENAME} --output ${NBTMPDIR}/${NBNAME}-test - echo "${MAGIC_OVERRIDE_CODE}" > ${NBTMPDIR}/tmpfile - cat ${NBTESTSCRIPT} >> ${NBTMPDIR}/tmpfile - mv ${NBTMPDIR}/tmpfile ${NBTESTSCRIPT} - - echo "Running \"ipython ${NO_COLORS} ${NBTESTSCRIPT}\" on $(date)" - echo - time bash -c "ipython ${NO_COLORS} ${NBTESTSCRIPT}; EC=\$?; echo -------------------------------------------------------------------------------- ; echo DONE: ${NBNAME}; exit \$EC" - NBEXITCODE=$? - echo EXIT CODE: ${NBEXITCODE} - echo - EXITCODE=$((EXITCODE | ${NBEXITCODE})) -done - -exit ${EXITCODE} diff --git a/ci/utils/nbtestlog2junitxml.py b/ci/utils/nbtestlog2junitxml.py deleted file mode 100644 index 14384af3225..00000000000 --- a/ci/utils/nbtestlog2junitxml.py +++ /dev/null @@ -1,163 +0,0 @@ -# Copyright (c) 2020-2022, NVIDIA CORPORATION. -# Generate a junit-xml file from parsing a nbtest log - -import re -from xml.etree.ElementTree import Element, ElementTree -from os import path -import string -from enum import Enum - - -startingPatt = re.compile(r"^STARTING: ([\w\.\-]+)$") -skippingPatt = re.compile(r"^SKIPPING: ([\w\.\-]+)\s*(\(([\w\.\-\ \,]+)\))?\s*$") -exitCodePatt = re.compile(r"^EXIT CODE: (\d+)$") -folderPatt = re.compile(r"^FOLDER: ([\w\.\-]+)$") -timePatt = re.compile(r"^real\s+([\d\.ms]+)$") -linePatt = re.compile("^" + ("-" * 80) + "$") - - -def getFileBaseName(filePathName): - return path.splitext(path.basename(filePathName))[0] - - -def makeTestCaseElement(attrDict): - return Element("testcase", attrib=attrDict) - - -def makeSystemOutElement(outputLines): - e = Element("system-out") - e.text = "".join(filter(lambda c: c in string.printable, outputLines)) - return e - - -def makeFailureElement(outputLines): - e = Element("failure", message="failed") - e.text = "".join(filter(lambda c: c in string.printable, outputLines)) - return e - - -def setFileNameAttr(attrDict, fileName): - attrDict.update(file=fileName, - classname="", - line="", - name="", - time="" - ) - -def setClassNameAttr(attrDict, className): - attrDict["classname"] = className - - -def setTestNameAttr(attrDict, testName): - attrDict["name"] = testName - - -def setTimeAttr(attrDict, timeVal): - (mins, seconds) = timeVal.split("m") - seconds = float(seconds.strip("s")) + (60 * int(mins)) - attrDict["time"] = str(seconds) - - -def incrNumAttr(element, attr): - newVal = int(element.attrib.get(attr)) + 1 - element.attrib[attr] = str(newVal) - - -def parseLog(logFile, testSuiteElement): - # Example attrs: - # errors="0" failures="0" hostname="a437d6835edf" name="pytest" skipped="2" tests="6" time="6.174" timestamp="2019-11-18T19:49:47.946307" - - with open(logFile) as lf: - testSuiteElement.attrib["tests"] = "0" - testSuiteElement.attrib["errors"] = "0" - testSuiteElement.attrib["failures"] = "0" - testSuiteElement.attrib["skipped"] = "0" - testSuiteElement.attrib["time"] = "0" - testSuiteElement.attrib["timestamp"] = "" - - attrDict = {} - #setFileNameAttr(attrDict, logFile) - setFileNameAttr(attrDict, "nbtest") - - parserStateEnum = Enum("parserStateEnum", - "newTest startingLine finishLine exitCode") - parserState = parserStateEnum.newTest - - testOutput = "" - - for line in lf.readlines(): - if parserState == parserStateEnum.newTest: - m = folderPatt.match(line) - if m: - setClassNameAttr(attrDict, m.group(1)) - continue - - m = skippingPatt.match(line) - if m: - setTestNameAttr(attrDict, getFileBaseName(m.group(1))) - setTimeAttr(attrDict, "0m0s") - skippedElement = makeTestCaseElement(attrDict) - message = m.group(3) or "" - skippedElement.append(Element("skipped", message=message, type="")) - testSuiteElement.append(skippedElement) - incrNumAttr(testSuiteElement, "skipped") - incrNumAttr(testSuiteElement, "tests") - continue - - m = startingPatt.match(line) - if m: - parserState = parserStateEnum.startingLine - testOutput = "" - setTestNameAttr(attrDict, m.group(1)) - setTimeAttr(attrDict, "0m0s") - continue - - continue - - elif parserState == parserStateEnum.startingLine: - if linePatt.match(line): - parserState = parserStateEnum.finishLine - testOutput = "" - continue - - elif parserState == parserStateEnum.finishLine: - if linePatt.match(line): - parserState = parserStateEnum.exitCode - else: - testOutput += line - continue - - elif parserState == parserStateEnum.exitCode: - m = exitCodePatt.match(line) - if m: - testCaseElement = makeTestCaseElement(attrDict) - if m.group(1) != "0": - failureElement = makeFailureElement(testOutput) - testCaseElement.append(failureElement) - incrNumAttr(testSuiteElement, "failures") - else: - systemOutElement = makeSystemOutElement(testOutput) - testCaseElement.append(systemOutElement) - - testSuiteElement.append(testCaseElement) - parserState = parserStateEnum.newTest - testOutput = "" - incrNumAttr(testSuiteElement, "tests") - continue - - m = timePatt.match(line) - if m: - setTimeAttr(attrDict, m.group(1)) - continue - - continue - - -if __name__ == "__main__": - import sys - - testSuitesElement = Element("testsuites") - testSuiteElement = Element("testsuite", name="nbtest", hostname="") - parseLog(sys.argv[1], testSuiteElement) - testSuitesElement.append(testSuiteElement) - ElementTree(testSuitesElement).write(sys.argv[1]+".xml", xml_declaration=True) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index 44d6be65574..61e9bc737d8 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -37,6 +37,7 @@ dependencies: - moto>=4.0.8 - myst-nb - nbsphinx +- nbval - ninja - notebook - numba>=0.56.2 diff --git a/dependencies.yaml b/dependencies.yaml index ba6d240e069..f73910fe918 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -209,7 +209,10 @@ dependencies: - output_types: [conda, requirements] packages: - ipython + - nbval - notebook + - pytest + - pytest-xdist - scipy py_version: specific: