Skip to content

Commit

Permalink
Add post cell execute docs (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-treebeard authored Feb 21, 2023
1 parent f92e6a0 commit 3e4ae42
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ pytest \
--nbmake-timeout=20 # Skip past cells longer than 20s
```

## Mock out variables to simplify testing (experimental 🧪)
## Mock out variables to simplify testing

If your notebook runs a training process that takes a long time to run, you can use nbmake's
mocking feature to overwrite variables after a cell runs:
Expand Down Expand Up @@ -177,6 +177,33 @@ mocking feature to overwrite variables after a cell runs:
}
```

## Run test logic after a cell executes

You can fetch CI secrets and run assertions after any cell by putting scripts in the cell metadata under `nbmake.post_cell_execute`:

```json
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"nbmake": {
"post_cell_execute": [
"y = 3",
"z = x+y"
]
}
},
"outputs": [],
"source": [
"x = 1\n",
"y = 2\n",
"z = 0\n",
"# this cell has a post_cell_execute that assigns y and z"
]
},
```

## Advice on Usage

Expand Down

0 comments on commit 3e4ae42

Please sign in to comment.