Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve notebook handling #2860

Merged
merged 1 commit into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install standalone dependencies only
run: |
pip install .
pip install -e .
- name: Test importing Flax
run: |
python -c "import flax"
Expand Down
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,13 @@ repos:
hooks:
- id: trailing-whitespace
exclude: ^docs/.*\.md$
- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
hooks:
- id: nbstripout
args: [
--keep-output,
--keep-count,
--extra-keys,
"metadata.kernelspec metadata.vscode metadata.colab cell.metadata.executionInfo.user cell.metadata.executionInfo.user_tz cell.metadata.colab",
]
9 changes: 8 additions & 1 deletion docs/advanced_topics/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ Follow these steps to contribute code:
```bash
git clone https://github.com/YOUR_USERNAME/flax
cd flax
pip install ".[testing]"
pip install -e .
pip install ".[testing]"
pip install -r docs/requirements.txt
# install in editable mode again because docs/requirements.txt
# reinstalls project in non-editable mode
pip install -e .
```

5. Set up pre-commit hooks, this will run some automated checks during each `git` commit and
Expand Down Expand Up @@ -127,6 +130,10 @@ The former can be opened and executed directly in [Google Colab](https://colab.r
Markdown makes it easier to track changes/diffs within version control and, for example, GitHub
web UI, since `.ipynb` files are based on JSON.

**NOTE**: If your notebook contains a cell that uses `pip` to install a package
you must add a `skip-execution` tag to that cell so `myst-nb` will skip the cell
when testing the notebooks.

#### Editing Jupyter Notebooks (`.ipynb`)

For making large changes that substantially modify code and outputs, it's recommended to edit
Expand Down
163 changes: 20 additions & 143 deletions docs/getting_started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,7 @@
"executionInfo": {
"elapsed": 54,
"status": "ok",
"timestamp": 1673483483044,
"user": {
"displayName": "Marcus Chiam",
"userId": "17531616275590396120"
},
"user_tz": 480
"timestamp": 1673483483044
},
"id": "bRlrHqZVXZvk"
},
Expand Down Expand Up @@ -126,12 +121,7 @@
"executionInfo": {
"elapsed": 53,
"status": "ok",
"timestamp": 1673483483208,
"user": {
"displayName": "Marcus Chiam",
"userId": "17531616275590396120"
},
"user_tz": 480
"timestamp": 1673483483208
},
"id": "cbc079cd"
},
Expand Down Expand Up @@ -177,12 +167,7 @@
"executionInfo": {
"elapsed": 103,
"status": "ok",
"timestamp": 1673483483427,
"user": {
"displayName": "Marcus Chiam",
"userId": "17531616275590396120"
},
"user_tz": 480
"timestamp": 1673483483427
},
"id": "lDHfog81zLQa",
"outputId": "2c580f41-bf5d-40ec-f1cf-ab7f319a84da"
Expand Down Expand Up @@ -266,12 +251,7 @@
"executionInfo": {
"elapsed": 52,
"status": "ok",
"timestamp": 1673483483631,
"user": {
"displayName": "Marcus Chiam",
"userId": "17531616275590396120"
},
"user_tz": 480
"timestamp": 1673483483631
},
"id": "qXr7JDpIxGNZ",
"outputId": "1249b7fb-6787-41eb-b34c-61d736300844"
Expand All @@ -289,12 +269,7 @@
"executionInfo": {
"elapsed": 1,
"status": "ok",
"timestamp": 1673483483754,
"user": {
"displayName": "Marcus Chiam",
"userId": "17531616275590396120"
},
"user_tz": 480
"timestamp": 1673483483754
},
"id": "CJDaJNijyOji"
},
Expand Down Expand Up @@ -324,12 +299,7 @@
"executionInfo": {
"elapsed": 55,
"status": "ok",
"timestamp": 1673483483958,
"user": {
"displayName": "Marcus Chiam",
"userId": "17531616275590396120"
},
"user_tz": 480
"timestamp": 1673483483958
},
"id": "7W0qf7FC9uG5"
},
Expand Down Expand Up @@ -360,12 +330,7 @@
"executionInfo": {
"elapsed": 54,
"status": "ok",
"timestamp": 1673483484125,
"user": {
"displayName": "Marcus Chiam",
"userId": "17531616275590396120"
},
"user_tz": 480
"timestamp": 1673483484125
},
"id": "e0102447"
},
Expand Down Expand Up @@ -418,12 +383,7 @@
"executionInfo": {
"elapsed": 52,
"status": "ok",
"timestamp": 1673483484293,
"user": {
"displayName": "Marcus Chiam",
"userId": "17531616275590396120"
},
"user_tz": 480
"timestamp": 1673483484293
},
"id": "9b0af486"
},
Expand Down Expand Up @@ -463,12 +423,7 @@
"executionInfo": {
"elapsed": 53,
"status": "ok",
"timestamp": 1673483484460,
"user": {
"displayName": "Marcus Chiam",
"userId": "17531616275590396120"
},
"user_tz": 480
"timestamp": 1673483484460
},
"id": "961bf70b"
},
Expand Down Expand Up @@ -504,12 +459,7 @@
"executionInfo": {
"elapsed": 515,
"status": "ok",
"timestamp": 1673483485090,
"user": {
"displayName": "Marcus Chiam",
"userId": "17531616275590396120"
},
"user_tz": 480
"timestamp": 1673483485090
},
"id": "bff5393e"
},
Expand Down Expand Up @@ -547,12 +497,7 @@
"executionInfo": {
"elapsed": 59,
"status": "ok",
"timestamp": 1673483485268,
"user": {
"displayName": "Marcus Chiam",
"userId": "17531616275590396120"
},
"user_tz": 480
"timestamp": 1673483485268
},
"id": "xC4MFyBsfT-U"
},
Expand All @@ -569,12 +514,7 @@
"executionInfo": {
"elapsed": 52,
"status": "ok",
"timestamp": 1673483485436,
"user": {
"displayName": "Marcus Chiam",
"userId": "17531616275590396120"
},
"user_tz": 480
"timestamp": 1673483485436
},
"id": "e4f6f4d3"
},
Expand Down Expand Up @@ -604,12 +544,7 @@
"executionInfo": {
"elapsed": 56,
"status": "ok",
"timestamp": 1673483485606,
"user": {
"displayName": "Marcus Chiam",
"userId": "17531616275590396120"
},
"user_tz": 480
"timestamp": 1673483485606
},
"id": "445fcab0"
},
Expand All @@ -627,12 +562,7 @@
"executionInfo": {
"elapsed": 52,
"status": "ok",
"timestamp": 1673483485777,
"user": {
"displayName": "Marcus Chiam",
"userId": "17531616275590396120"
},
"user_tz": 480
"timestamp": 1673483485777
},
"id": "5221eafd"
},
Expand Down Expand Up @@ -674,12 +604,7 @@
"executionInfo": {
"elapsed": 55,
"status": "ok",
"timestamp": 1673483485947,
"user": {
"displayName": "Marcus Chiam",
"userId": "17531616275590396120"
},
"user_tz": 480
"timestamp": 1673483485947
},
"id": "74295360"
},
Expand All @@ -697,12 +622,7 @@
"executionInfo": {
"elapsed": 1,
"status": "ok",
"timestamp": 1673483486076,
"user": {
"displayName": "Marcus Chiam",
"userId": "17531616275590396120"
},
"user_tz": 480
"timestamp": 1673483486076
},
"id": "cRtnMZuQFlKl"
},
Expand All @@ -722,12 +642,7 @@
"executionInfo": {
"elapsed": 17908,
"status": "ok",
"timestamp": 1673483504133,
"user": {
"displayName": "Marcus Chiam",
"userId": "17531616275590396120"
},
"user_tz": 480
"timestamp": 1673483504133
},
"id": "2c40ce90",
"outputId": "258a2c76-2c8f-4a9e-d48b-dde57c342a87"
Expand Down Expand Up @@ -803,18 +718,10 @@
"execution_count": 65,
"id": "Zs5atiqIG9Kz",
"metadata": {
"colab": {
"height": 353
},
"executionInfo": {
"elapsed": 358,
"status": "ok",
"timestamp": 1673483504621,
"user": {
"displayName": "Marcus Chiam",
"userId": "17531616275590396120"
},
"user_tz": 480
"timestamp": 1673483504621
},
"id": "Zs5atiqIG9Kz",
"outputId": "431a2fcd-44fa-4202-f55a-906555f060ac"
Expand Down Expand Up @@ -876,12 +783,7 @@
"executionInfo": {
"elapsed": 580,
"status": "ok",
"timestamp": 1673483505350,
"user": {
"displayName": "Marcus Chiam",
"userId": "17531616275590396120"
},
"user_tz": 480
"timestamp": 1673483505350
},
"id": "DFwxgBQf44ks"
},
Expand All @@ -901,18 +803,10 @@
"execution_count": 67,
"id": "5d5nF3u44JFI",
"metadata": {
"colab": {
"height": 699
},
"executionInfo": {
"elapsed": 1250,
"status": "ok",
"timestamp": 1673483506723,
"user": {
"displayName": "Marcus Chiam",
"userId": "17531616275590396120"
},
"user_tz": 480
"timestamp": 1673483506723
},
"id": "5d5nF3u44JFI",
"outputId": "1db5a01c-9d70-4f7d-8c0d-0a3ad8252d3e"
Expand Down Expand Up @@ -953,29 +847,12 @@
}
],
"metadata": {
"colab": {
"last_runtime": {
"build_target": "//learning/deepmind/public/tools/ml_python:ml_notebook",
"kind": "private"
},
"provenance": []
},
"jupytext": {
"formats": "ipynb,md:myst",
"main_language": "python"
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python"
},
"vscode": {
"interpreter": {
"hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
}
}
},
"nbformat": 4,
Expand Down
Loading