Skip to content

Commit f39914a

Browse files
committed
simple testing pipeline
1 parent 6c93d36 commit f39914a

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed

.github/scripts/run_one.py

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
from pathlib import Path
2+
import simple_parsing, logging, os
3+
from dataclasses import dataclass
4+
5+
from nb_helpers.run import run_one as _run_one
6+
7+
# logger.logger.setLevel(logging.DEBUG)
8+
9+
import weave
10+
11+
@weave.op
12+
def run_one(
13+
fname: str,
14+
pip_install: bool = False,
15+
create_github_issue: bool = False,
16+
repo: str = None,
17+
owner: str = None,
18+
) -> dict:
19+
"Run one nb and store the tb if it fails"
20+
run_status, runtime, tb = _run_one(
21+
fname=Path(fname),
22+
pip_install=pip_install,
23+
github_issue=create_github_issue,
24+
repo=repo,
25+
owner=owner,
26+
)
27+
return {"status": run_status == "ok", "runtime": runtime, "traceback": tb}
28+
29+
@dataclass
30+
class Args:
31+
nb_name: str = "Chapter00.ipynb"
32+
project_name: str = "edu"
33+
entity: str = "examples_repo_test"
34+
pip_install: bool = True
35+
create_github_issue: bool = False
36+
issue_repo: str = None
37+
issue_owner: str = None
38+
39+
if __name__ == "__main__":
40+
args = simple_parsing.parse(Args, config_path="./test_config.yml")
41+
# let's set some env variables:
42+
os.environ["WANDB_PROJECT"] = args.project_name
43+
os.environ["WANDB_ENTITY"] = args.entity
44+
os.environ["WANDB_NAME"] = args.nb_name.split("/")[-1]
45+
46+
weave.init(f"{args.entity}/{args.project_name}")
47+
48+
(run_status, runtime, tb) = run_one(
49+
fname=args.nb_name,
50+
pip_install=args.pip_install,
51+
create_github_issue=args.create_github_issue,
52+
repo=args.issue_repo,
53+
owner=args.issue_owner,
54+
)

.github/workflows/test_nbs.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Build and Test Locally
2+
on:
3+
workflow_dispatch: #allows repo admins to trigger this workflow from the Actions tab
4+
inputs:
5+
create_github_issue:
6+
type: boolean
7+
description: 'Create issues on failing notebooks'
8+
default: false
9+
notebooks_folder:
10+
type: choice
11+
description: 'folder of notebooks to test'
12+
options:
13+
- './rag-advanced/notebooks'
14+
default: './rag-advanced/notebooks'
15+
16+
defaults:
17+
run:
18+
shell: bash # default shell is sh
19+
20+
21+
jobs:
22+
run-tests:
23+
container:
24+
image: us-docker.pkg.dev/colab-images/public/runtime:latest
25+
options: --shm-size "16gb" --entrypoint /bin/bash
26+
env:
27+
WANDB_API_KEY: ${{ secrets.WANDB_API_KEY }}
28+
TF_CPP_MIN_LOG_LEVEL: 3
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: setup
32+
run: |
33+
echo "Installing dependencies"
34+
python3 -m pip install -U requests wandb ghapi simple_parsing weave
35+
python3 -m pip install git+https://github.com/wandb/nb_helpers
36+
echo "Add current folder to git safe"
37+
git config --global --add safe.directory $(pwd)
38+
- name: log-to-wandb
39+
run: |
40+
wandb login
41+
- name: checkout
42+
uses: actions/checkout@v2
43+
- name: run-tests
44+
env:
45+
CONTEXT_GITHUB: ${{ toJson(github) }}
46+
run: |
47+
cp .github/workflows/run_one.py ${{ github.event.inputs.notebooks_folder }}/run_one.py
48+
cd ${{ github.event.inputs.notebooks_folder }}
49+
for nb_name in $(ls *.ipynb); do
50+
python3 run_one.py --nb_name="/$nb_name" --create_github_issue=${{ github.event.inputs.create_github_issue }}
51+
done

0 commit comments

Comments
 (0)