Merged PR 440: #2620: add nbmake and pytest xdist to run the notebooks as part of pieline
  ## Summary Added nbmake so that the pytest can be used to run the notebooks in primaite as part of the pipeline ## Test process n/a ## Checklist - [X] PR is linked to a **work item** - [X] **acceptance criteria** of linked ticket are met - [X] performed **self-review** of the code - [ ] written **tests** for any new functionality added with this PR - [ ] updated the **documentation** if this PR changes or adds functionality - [ ] written/updated **design docs** if this PR implements new functionality - [ ] updated the **change log** - [X] ran **pre-commit** checks for code style - [ ] attended to any **TO-DOs** left in the code #2620: add nbmake and pytest xdist to run the notebooks as part of pieline Related work items: #2620
This commit is contained in:
@@ -107,11 +107,39 @@ stages:
|
|||||||
coverage html -d htmlcov -i
|
coverage html -d htmlcov -i
|
||||||
displayName: 'Run tests and code coverage'
|
displayName: 'Run tests and code coverage'
|
||||||
|
|
||||||
|
# Run the notebooks
|
||||||
|
- script: |
|
||||||
|
pytest --nbmake -n=auto src/primaite/notebooks --junit-xml=./notebook-tests/notebooks.xml
|
||||||
|
notebooks_exit_code=$?
|
||||||
|
pytest --nbmake -n=auto src/primaite/simulator/_package_data --junit-xml=./notebook-tests/package-notebooks.xml
|
||||||
|
package_notebooks_exit_code=$?
|
||||||
|
# Fail step if either of these do not have exit code 0
|
||||||
|
if [ $notebooks_exit_code -ne 0 ] || [ $package_notebooks_exit_code -ne 0 ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
displayName: 'Run notebooks on Linux and macOS'
|
||||||
|
condition: or(eq(variables['Agent.OS'], 'Linux'), eq(variables['Agent.OS'], 'Darwin'))
|
||||||
|
|
||||||
|
# Run notebooks
|
||||||
|
- script: |
|
||||||
|
pytest --nbmake -n=auto src/primaite/notebooks --junit-xml=./notebook-tests/notebooks.xml
|
||||||
|
set notebooks_exit_code=%ERRORLEVEL%
|
||||||
|
pytest --nbmake -n=auto src/primaite/simulator/_package_data --junit-xml=./notebook-tests/package-notebooks.xml
|
||||||
|
set package_notebooks_exit_code=%ERRORLEVEL%
|
||||||
|
rem Fail step if either of these do not have exit code 0
|
||||||
|
if %notebooks_exit_code% NEQ 0 exit /b 1
|
||||||
|
if %package_notebooks_exit_code% NEQ 0 exit /b 1
|
||||||
|
displayName: 'Run notebooks on Windows'
|
||||||
|
condition: eq(variables['Agent.OS'], 'Windows_NT')
|
||||||
|
|
||||||
- task: PublishTestResults@2
|
- task: PublishTestResults@2
|
||||||
condition: succeededOrFailed()
|
condition: succeededOrFailed()
|
||||||
|
displayName: 'Publish Test Results'
|
||||||
inputs:
|
inputs:
|
||||||
testRunner: JUnit
|
testRunner: JUnit
|
||||||
testResultsFiles: 'junit/**.xml'
|
testResultsFiles: |
|
||||||
|
'junit/**.xml'
|
||||||
|
'notebook-tests/**.xml'
|
||||||
testRunTitle: 'Publish test results'
|
testRunTitle: 'Publish test results'
|
||||||
failTaskOnFailedTests: true
|
failTaskOnFailedTests: true
|
||||||
|
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -54,6 +54,7 @@ cover/
|
|||||||
tests/assets/**/*.png
|
tests/assets/**/*.png
|
||||||
tests/assets/**/tensorboard_logs/
|
tests/assets/**/tensorboard_logs/
|
||||||
tests/assets/**/checkpoints/
|
tests/assets/**/checkpoints/
|
||||||
|
notebook-tests/*.xml
|
||||||
|
|
||||||
# Translations
|
# Translations
|
||||||
*.mo
|
*.mo
|
||||||
|
|||||||
@@ -72,7 +72,9 @@ dev = [
|
|||||||
"Sphinx==7.1.2",
|
"Sphinx==7.1.2",
|
||||||
"sphinx-copybutton==0.5.2",
|
"sphinx-copybutton==0.5.2",
|
||||||
"wheel==0.38.4",
|
"wheel==0.38.4",
|
||||||
"nbsphinx==0.9.4"
|
"nbsphinx==0.9.4",
|
||||||
|
"nbmake==1.5.4",
|
||||||
|
"pytest-xdist==3.3.1"
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.scripts]
|
[project.scripts]
|
||||||
|
|||||||
@@ -143,7 +143,7 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.10.12"
|
"version": "3.10.11"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|||||||
Reference in New Issue
Block a user