nbdevAuto 0.3.93__tar.gz → 0.3.96__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nbdevauto-0.3.93/nbdevAuto.egg-info → nbdevauto-0.3.96}/PKG-INFO +38 -43
- {nbdevauto-0.3.93 → nbdevauto-0.3.96}/README.md +37 -42
- nbdevauto-0.3.96/nbdevAuto/__init__.py +1 -0
- {nbdevauto-0.3.93 → nbdevauto-0.3.96}/nbdevAuto/_modidx.py +4 -24
- {nbdevauto-0.3.93 → nbdevauto-0.3.96}/nbdevAuto/automate.py +3 -104
- {nbdevauto-0.3.93 → nbdevauto-0.3.96}/nbdevAuto/fleet.py +11 -25
- {nbdevauto-0.3.93 → nbdevauto-0.3.96}/nbdevAuto/functions.py +2 -19
- {nbdevauto-0.3.93 → nbdevauto-0.3.96}/nbdevAuto/github.py +74 -65
- {nbdevauto-0.3.93 → nbdevauto-0.3.96/nbdevAuto.egg-info}/PKG-INFO +38 -43
- {nbdevauto-0.3.93 → nbdevauto-0.3.96}/nbdevAuto.egg-info/SOURCES.txt +0 -2
- {nbdevauto-0.3.93 → nbdevauto-0.3.96}/nbdevAuto.egg-info/entry_points.txt +0 -5
- {nbdevauto-0.3.93 → nbdevauto-0.3.96}/pyproject.toml +0 -5
- nbdevauto-0.3.93/nbdevAuto/__init__.py +0 -1
- nbdevauto-0.3.93/nbdevAuto/core.py +0 -7
- nbdevauto-0.3.93/nbdevAuto/pdf.py +0 -92
- {nbdevauto-0.3.93 → nbdevauto-0.3.96}/LICENSE +0 -0
- {nbdevauto-0.3.93 → nbdevauto-0.3.96}/MANIFEST.in +0 -0
- {nbdevauto-0.3.93 → nbdevauto-0.3.96}/nbdevAuto.egg-info/dependency_links.txt +0 -0
- {nbdevauto-0.3.93 → nbdevauto-0.3.96}/nbdevAuto.egg-info/requires.txt +0 -0
- {nbdevauto-0.3.93 → nbdevauto-0.3.96}/nbdevAuto.egg-info/top_level.txt +0 -0
- {nbdevauto-0.3.93 → nbdevauto-0.3.96}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nbdevAuto
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.96
|
|
4
4
|
Summary: automating nbdev
|
|
5
5
|
Author-email: Benedict Thekkel <bthekkel1@gmail.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -30,121 +30,116 @@ Dynamic: license-file
|
|
|
30
30
|
|
|
31
31
|
# nbdevAuto
|
|
32
32
|
|
|
33
|
+
Command line automation for the nbdev publish cycle, plus the dataset and image helpers the notebooks in this collection reuse.
|
|
33
34
|
|
|
34
35
|
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
|
|
35
36
|
|
|
36
37
|
Unlike most sites in this collection, this one documents an **installable library** rather than a topic. `nbdevAuto` exists because the nbdev release cycle is a fixed sequence of commands typed in the same order every time: export the notebooks, run the tests, clean them, bump the version, commit, push, build the docs. Each step is one nbdev call, and forgetting one produces a confusing failure two steps later.
|
|
37
38
|
|
|
38
|
-
The library collapses that sequence into single-word shell commands. It is what `just upload` and `just
|
|
39
|
+
The library collapses that sequence into single-word shell commands. It is what `just upload` and `just upload --all` invoke under the hood for every submodule in the parent Knowledge repo.
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
---
|
|
41
42
|
|
|
42
43
|
## Install
|
|
43
44
|
|
|
44
|
-
```
|
|
45
|
+
```sh
|
|
45
46
|
pip install nbdevAuto # the publish-cycle commands and the helpers
|
|
46
47
|
pip install 'nbdevAuto[gh]' # also installs githubkit, which `ghstatus` needs
|
|
47
48
|
```
|
|
48
49
|
|
|
49
50
|
Requires Python 3.10 or newer.
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
---
|
|
52
53
|
|
|
53
54
|
## Use
|
|
54
55
|
|
|
55
|
-
|
|
56
|
+
The commands are console scripts, so the common case is a bare word in the terminal at the root of an nbdev project:
|
|
56
57
|
|
|
57
|
-
```
|
|
58
|
+
```sh
|
|
58
59
|
upload -m "commit message" # export, test, clean, then add/commit/push
|
|
59
60
|
```
|
|
60
61
|
|
|
61
62
|
Or import the helpers into a notebook:
|
|
62
63
|
|
|
63
|
-
```
|
|
64
|
+
```python
|
|
64
65
|
from nbdevAuto.functions import download_search_images, classify_images
|
|
65
|
-
from nbdevAuto.pdf import PDFreader
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
---
|
|
69
69
|
|
|
70
70
|
## Contents
|
|
71
71
|
|
|
72
72
|
| Page | Covers |
|
|
73
|
-
|
|
74
|
-
| [Functions](
|
|
75
|
-
| [Automate](
|
|
76
|
-
| [
|
|
77
|
-
| [
|
|
78
|
-
| [Fleet](04_Fleet.ipynb) | [`fleet`](https://bthek1.github.io/nbdevAuto/fleet.html#fleet): running one command across every submodule of a superproject. A walker that reports only what did work and counts the rest, plus the verbs built on it - upload, push, copy, status, update and sync |
|
|
73
|
+
|--- |--- |
|
|
74
|
+
| [Functions](https://bthek1.github.io/nbdevAuto/functions.html) | Dataset and image helpers: downloading single images or whole search-driven datasets, verifying and resizing what came back, building the folder layout a classifier expects, running a fastai learner over one image, Kaggle competition and dataset shortcuts, and [`graph`](https://bthek1.github.io/nbdevAuto/functions.html#graph), a `graphviz.Digraph` subclass preloaded with a rounded, filled style |
|
|
75
|
+
| [Automate](https://bthek1.github.io/nbdevAuto/automate.html) | The command line surface: the prep/commit/push pipeline and the one-line-per-stage console grid every command reports through |
|
|
76
|
+
| [GitHub](https://bthek1.github.io/nbdevAuto/github.html) | [`ghstatus`](https://bthek1.github.io/nbdevAuto/github.html#ghstatus): reading `.gitmodules`, resolving a token, and asking the GitHub API about every submodule at once - CI runs, Pages deploys, Pages builds, remote `main` shas - plus the `--report` and `--audit` views, the exit codes that keep "absent" apart from "cannot ask", and [`newest_run`](https://bthek1.github.io/nbdevAuto/github.html#newest_run), which picks a run by `run_number` because the API's page order is not a contract |
|
|
77
|
+
| [Fleet](https://bthek1.github.io/nbdevAuto/fleet.html) | [`fleet`](https://bthek1.github.io/nbdevAuto/fleet.html#fleet): running one command across every submodule of a superproject. A walker that reports only what did work and counts the rest, plus the verbs built on it - upload, push, template, status, update, sync, scan and nblint |
|
|
79
78
|
|
|
80
|
-
|
|
79
|
+
---
|
|
81
80
|
|
|
82
81
|
## The Command Line Surface
|
|
83
82
|
|
|
84
|
-
Installing the package puts these on your `PATH`. Most are ordinary functions in [Automate](
|
|
83
|
+
Installing the package puts these on your `PATH`. Most are ordinary functions in [Automate](https://bthek1.github.io/nbdevAuto/automate.html), exposed as scripts through `[project.scripts]`; [`ghstatus`](https://bthek1.github.io/nbdevAuto/github.html#ghstatus) comes from [GitHub](https://bthek1.github.io/nbdevAuto/github.html) and [`fleet`](https://bthek1.github.io/nbdevAuto/fleet.html#fleet) from [Fleet](https://bthek1.github.io/nbdevAuto/fleet.html).
|
|
85
84
|
|
|
86
85
|
| Command | Does |
|
|
87
|
-
|
|
86
|
+
|--- |--- |
|
|
88
87
|
| [`prep`](https://bthek1.github.io/nbdevAuto/automate.html#prep) | Bump the version, then export, test and clean the notebooks, refreshing `_quarto.yml` and the README |
|
|
89
88
|
| [`gacp`](https://bthek1.github.io/nbdevAuto/automate.html#gacp) | git add, commit, and push. Without `-m` the message is built from the staged paths |
|
|
90
|
-
| [`status`](https://bthek1.github.io/nbdevAuto/automate.html#status) | Show the working tree state |
|
|
91
89
|
| [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload) | [`prep`](https://bthek1.github.io/nbdevAuto/automate.html#prep) then [`gacp`](https://bthek1.github.io/nbdevAuto/automate.html#gacp), the one you actually type |
|
|
92
|
-
| `gitrelease` | Bump the **minor** version, then tag and create a GitHub release |
|
|
93
|
-
| `piprelease` | Build the sdist and wheel, then upload to PyPI with twine |
|
|
94
|
-
| [`release`](https://bthek1.github.io/nbdevAuto/automate.html#release) | `gitrelease` then `piprelease` |
|
|
95
90
|
| [`ghstatus`](https://bthek1.github.io/nbdevAuto/github.html#ghstatus) | Remote status for every submodule of an nbdev superproject, from the GitHub API. `--report` for the sync view, `--audit` to check `.gitmodules` against the repos the account owns, `--json` for machine output |
|
|
96
|
-
| [`fleet`](https://bthek1.github.io/nbdevAuto/fleet.html#fleet) | Run one command across every submodule:
|
|
97
|
-
| `h` | Print the list of available commands |
|
|
91
|
+
| [`fleet`](https://bthek1.github.io/nbdevAuto/fleet.html#fleet) | Run one command across every submodule: \`fleet upload |
|
|
98
92
|
|
|
99
|
-
Both [`prep`](https://bthek1.github.io/nbdevAuto/automate.html#prep) and [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload) take `-p` to choose which version part to increment; it defaults to 2, the patch, so every [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload) ships a new version.
|
|
93
|
+
Both [`prep`](https://bthek1.github.io/nbdevAuto/automate.html#prep) and [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload) take `-p` to choose which version part to increment; it defaults to 2, the patch, so every [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload) ships a new version. Use `-p 1` for a minor release.
|
|
100
94
|
|
|
101
|
-
|
|
95
|
+
Pushing to `main` publishes to PyPI on its own: `publish.yaml` runs after CI passes, and skips quietly when the version is already there.
|
|
102
96
|
|
|
103
97
|
[`ghstatus`](https://bthek1.github.io/nbdevAuto/github.html#ghstatus) needs the `gh` extra (`pip install 'nbdevAuto[gh]'`), which brings in `githubkit`. It is an extra rather than a dependency because githubkit pulls pydantic, httpx and hishel behind it, which is a lot of weight for anyone who only wants [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload). Without it the command exits 3 with an install hint rather than a traceback. It takes its token from `$GITHUB_TOKEN` / `$GH_TOKEN`, then `gh auth token`.
|
|
104
98
|
|
|
105
|
-
|
|
99
|
+
---
|
|
106
100
|
|
|
107
101
|
## The Output Contract
|
|
108
102
|
|
|
109
|
-
Every command reports through one grid, defined in [Automate](
|
|
103
|
+
Every command reports through one grid, defined in [Automate](https://bthek1.github.io/nbdevAuto/automate.html) and reused by [Fleet](https://bthek1.github.io/nbdevAuto/fleet.html). It exists because these commands run 19 times in a row, so anything that costs three lines per stage costs sixty over a fleet.
|
|
110
104
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
105
|
+
```
|
|
106
|
+
1/6 bump version (part 2) OK 75ms 0.3.67 -> 0.3.68
|
|
107
|
+
2/6 nbdev_export OK 129ms
|
|
108
|
+
3/6 nbdev_test OK 1.5s 6 notebooks, slowest 01_Automate.ipynb 1.0s
|
|
109
|
+
```
|
|
114
110
|
|
|
115
111
|
Four rules hold it together, and a change to any stage has to keep them:
|
|
116
112
|
|
|
117
113
|
- **One stage, one line, inside 88 columns.** The columns are fixed: `n/total` (5), label (22), outcome (4), duration (7), detail (the rest). A unit test renders real stages through a console pinned to that width and asserts every line fits.
|
|
118
114
|
- **A summariser returns short strings, not a transcript.** [`_test_summary`](https://bthek1.github.io/nbdevAuto/automate.html#_test_summary) turns a line per notebook into `6 notebooks, slowest X 1.0s`; [`_push_summary`](https://bthek1.github.io/nbdevAuto/automate.html#_push_summary) turns nine lines of git progress into a sha range and a size. Anything too long for the detail column moves to an indented continuation line, so a verbose summariser degrades the layout rather than breaking it.
|
|
119
|
-
- **A stage that shells out must capture at the file-descriptor level.** `redirect_stdout` only rebinds Python
|
|
120
|
-
- **A green OK has to mean something.** [`_run`](https://bthek1.github.io/nbdevAuto/automate.html#_run) raises on a non-zero exit rather than returning a code nobody reads, and the failure prints the command
|
|
115
|
+
- **A stage that shells out must capture at the file-descriptor level.** `redirect_stdout` only rebinds Python's `sys.stdout`, so a child process writing to fd 1 walks straight past it - which is how `nbdev_readme` used to spill sixteen lines of pandoc metadata into the middle of a run. [`_quiet`](https://bthek1.github.io/nbdevAuto/automate.html#_quiet) swaps fds 1 and 2 for a temp file as well and merges both captures.
|
|
116
|
+
- **A green OK has to mean something.** [`_run`](https://bthek1.github.io/nbdevAuto/automate.html#_run) raises on a non-zero exit rather than returning a code nobody reads, and the failure prints the command's own output. Before that, a failed `git push` still reported `OK`.
|
|
121
117
|
|
|
122
118
|
On a terminal the label is written first without a newline, so a slow stage is visible while it runs, then rewritten in place. Piped output skips that entirely, because a carriage return in a log file is just noise.
|
|
123
119
|
|
|
124
|
-
|
|
120
|
+
---
|
|
125
121
|
|
|
126
122
|
## Where It Is Used
|
|
127
123
|
|
|
128
|
-
The parent Knowledge repo
|
|
124
|
+
The parent Knowledge repo's `justfile` calls [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload) once per submodule. `just upload` runs it only where the working tree is dirty, `just upload --all` runs it everywhere. That is the main consumer, so a change to `automate.py` affects the publish path for every site in the collection.
|
|
129
125
|
|
|
130
|
-
[`ghstatus`](https://bthek1.github.io/nbdevAuto/github.html#ghstatus) is the other half of that loop. [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload) pushes to 19 repos and then goes blind: whether each repo
|
|
126
|
+
[`ghstatus`](https://bthek1.github.io/nbdevAuto/github.html#ghstatus) is the other half of that loop. [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload) pushes to 19 repos and then goes blind: whether each repo's CI passed and whether its Pages deploy actually landed is invisible from the terminal. `just ci_status`, `just ci_report` and `just ci_audit` in the parent repo are all thin wrappers around this one command, which answers for the whole fleet in about 1.5 seconds instead of 19 browser tabs.
|
|
131
127
|
|
|
132
|
-
|
|
128
|
+
---
|
|
133
129
|
|
|
134
130
|
## Releases
|
|
135
131
|
|
|
136
132
|
This package publishes itself. A `publish.yaml` workflow runs after CI passes on `main` and uploads to PyPI through Trusted Publishing, so no API token is stored in the repository. It reads `__version__` out of `nbdevAuto/__init__.py` and asks PyPI whether that version already exists: a new version is published, an existing one is skipped without failing the build. Once PyPI accepts it, the same workflow creates the matching GitHub release (tag `<version>`, title `v<version>`, auto-generated notes) with the built wheel and sdist attached, and skips if that release already exists.
|
|
137
133
|
|
|
138
|
-
Because [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload) bumps the patch version on every push, an ordinary commit made with [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload) ships a release. A plain `git commit` leaves the version alone and the workflow skips.
|
|
134
|
+
Because [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload) bumps the patch version on every push, an ordinary commit made with [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload) ships a release. A plain `git commit` leaves the version alone and the workflow skips. For a minor release, run `upload -p 1`.
|
|
139
135
|
|
|
140
|
-
|
|
136
|
+
---
|
|
141
137
|
|
|
142
138
|
## Not Covered Yet
|
|
143
139
|
|
|
144
140
|
- **No tests for the helpers.** `01_Automate.ipynb`, `03_GitHub.ipynb` and `04_Fleet.ipynb` all carry unit tests for their pure functions - the fleet ones against a throwaway superproject of real git repos - but the dataset and image helpers in `00_Functions.ipynb` are exercised only by being used, so a broken one surfaces in a downstream repo rather than here.
|
|
145
|
-
- **Undeclared dependencies.** `pyproject.toml` declares `graphviz` and `fastcore`, plus `githubkit` behind the `gh` extra. The helpers additionally import `fastai`, `fastbook`, `fastdownload`, `PIL`, `matplotlib`, `tqdm`, `
|
|
146
|
-
- **`core.py` is an empty nbdev stub** (a single `foo`) left over from `00_core.ipynb`, which no longer exists.
|
|
141
|
+
- **Undeclared dependencies.** `pyproject.toml` declares `graphviz` and `fastcore`, plus `githubkit` behind the `gh` extra. The helpers additionally import `fastai`, `fastbook`, `fastdownload`, `PIL`, `matplotlib`, `tqdm`, `nbdev` and `kaggle` (which also needs its credentials). All of those are imported lazily inside the function that needs them, so installing the package and running the console scripts still works - only the specific helper you call fails. Install them yourself.
|
|
147
142
|
- **`CHANGELOG.md` is still the nbdev stub** (`Version 1.0.0 - Initial release`) while the package is past 0.3.68. Nothing generates it, and [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload) bumps the patch on every push, so it would need writing by hand or dropping.
|
|
148
143
|
- The docstrings are one-liners, so the rendered API pages are thin. The notebooks carry the real explanation.
|
|
149
144
|
|
|
150
|
-
|
|
145
|
+
---
|
|
@@ -1,120 +1,115 @@
|
|
|
1
1
|
# nbdevAuto
|
|
2
2
|
|
|
3
|
+
Command line automation for the nbdev publish cycle, plus the dataset and image helpers the notebooks in this collection reuse.
|
|
3
4
|
|
|
4
5
|
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
|
|
5
6
|
|
|
6
7
|
Unlike most sites in this collection, this one documents an **installable library** rather than a topic. `nbdevAuto` exists because the nbdev release cycle is a fixed sequence of commands typed in the same order every time: export the notebooks, run the tests, clean them, bump the version, commit, push, build the docs. Each step is one nbdev call, and forgetting one produces a confusing failure two steps later.
|
|
7
8
|
|
|
8
|
-
The library collapses that sequence into single-word shell commands. It is what `just upload` and `just
|
|
9
|
+
The library collapses that sequence into single-word shell commands. It is what `just upload` and `just upload --all` invoke under the hood for every submodule in the parent Knowledge repo.
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
---
|
|
11
12
|
|
|
12
13
|
## Install
|
|
13
14
|
|
|
14
|
-
```
|
|
15
|
+
```sh
|
|
15
16
|
pip install nbdevAuto # the publish-cycle commands and the helpers
|
|
16
17
|
pip install 'nbdevAuto[gh]' # also installs githubkit, which `ghstatus` needs
|
|
17
18
|
```
|
|
18
19
|
|
|
19
20
|
Requires Python 3.10 or newer.
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
---
|
|
22
23
|
|
|
23
24
|
## Use
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
The commands are console scripts, so the common case is a bare word in the terminal at the root of an nbdev project:
|
|
26
27
|
|
|
27
|
-
```
|
|
28
|
+
```sh
|
|
28
29
|
upload -m "commit message" # export, test, clean, then add/commit/push
|
|
29
30
|
```
|
|
30
31
|
|
|
31
32
|
Or import the helpers into a notebook:
|
|
32
33
|
|
|
33
|
-
```
|
|
34
|
+
```python
|
|
34
35
|
from nbdevAuto.functions import download_search_images, classify_images
|
|
35
|
-
from nbdevAuto.pdf import PDFreader
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
---
|
|
39
39
|
|
|
40
40
|
## Contents
|
|
41
41
|
|
|
42
42
|
| Page | Covers |
|
|
43
|
-
|
|
44
|
-
| [Functions](
|
|
45
|
-
| [Automate](
|
|
46
|
-
| [
|
|
47
|
-
| [
|
|
48
|
-
| [Fleet](04_Fleet.ipynb) | [`fleet`](https://bthek1.github.io/nbdevAuto/fleet.html#fleet): running one command across every submodule of a superproject. A walker that reports only what did work and counts the rest, plus the verbs built on it - upload, push, copy, status, update and sync |
|
|
43
|
+
|--- |--- |
|
|
44
|
+
| [Functions](https://bthek1.github.io/nbdevAuto/functions.html) | Dataset and image helpers: downloading single images or whole search-driven datasets, verifying and resizing what came back, building the folder layout a classifier expects, running a fastai learner over one image, Kaggle competition and dataset shortcuts, and [`graph`](https://bthek1.github.io/nbdevAuto/functions.html#graph), a `graphviz.Digraph` subclass preloaded with a rounded, filled style |
|
|
45
|
+
| [Automate](https://bthek1.github.io/nbdevAuto/automate.html) | The command line surface: the prep/commit/push pipeline and the one-line-per-stage console grid every command reports through |
|
|
46
|
+
| [GitHub](https://bthek1.github.io/nbdevAuto/github.html) | [`ghstatus`](https://bthek1.github.io/nbdevAuto/github.html#ghstatus): reading `.gitmodules`, resolving a token, and asking the GitHub API about every submodule at once - CI runs, Pages deploys, Pages builds, remote `main` shas - plus the `--report` and `--audit` views, the exit codes that keep "absent" apart from "cannot ask", and [`newest_run`](https://bthek1.github.io/nbdevAuto/github.html#newest_run), which picks a run by `run_number` because the API's page order is not a contract |
|
|
47
|
+
| [Fleet](https://bthek1.github.io/nbdevAuto/fleet.html) | [`fleet`](https://bthek1.github.io/nbdevAuto/fleet.html#fleet): running one command across every submodule of a superproject. A walker that reports only what did work and counts the rest, plus the verbs built on it - upload, push, template, status, update, sync, scan and nblint |
|
|
49
48
|
|
|
50
|
-
|
|
49
|
+
---
|
|
51
50
|
|
|
52
51
|
## The Command Line Surface
|
|
53
52
|
|
|
54
|
-
Installing the package puts these on your `PATH`. Most are ordinary functions in [Automate](
|
|
53
|
+
Installing the package puts these on your `PATH`. Most are ordinary functions in [Automate](https://bthek1.github.io/nbdevAuto/automate.html), exposed as scripts through `[project.scripts]`; [`ghstatus`](https://bthek1.github.io/nbdevAuto/github.html#ghstatus) comes from [GitHub](https://bthek1.github.io/nbdevAuto/github.html) and [`fleet`](https://bthek1.github.io/nbdevAuto/fleet.html#fleet) from [Fleet](https://bthek1.github.io/nbdevAuto/fleet.html).
|
|
55
54
|
|
|
56
55
|
| Command | Does |
|
|
57
|
-
|
|
56
|
+
|--- |--- |
|
|
58
57
|
| [`prep`](https://bthek1.github.io/nbdevAuto/automate.html#prep) | Bump the version, then export, test and clean the notebooks, refreshing `_quarto.yml` and the README |
|
|
59
58
|
| [`gacp`](https://bthek1.github.io/nbdevAuto/automate.html#gacp) | git add, commit, and push. Without `-m` the message is built from the staged paths |
|
|
60
|
-
| [`status`](https://bthek1.github.io/nbdevAuto/automate.html#status) | Show the working tree state |
|
|
61
59
|
| [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload) | [`prep`](https://bthek1.github.io/nbdevAuto/automate.html#prep) then [`gacp`](https://bthek1.github.io/nbdevAuto/automate.html#gacp), the one you actually type |
|
|
62
|
-
| `gitrelease` | Bump the **minor** version, then tag and create a GitHub release |
|
|
63
|
-
| `piprelease` | Build the sdist and wheel, then upload to PyPI with twine |
|
|
64
|
-
| [`release`](https://bthek1.github.io/nbdevAuto/automate.html#release) | `gitrelease` then `piprelease` |
|
|
65
60
|
| [`ghstatus`](https://bthek1.github.io/nbdevAuto/github.html#ghstatus) | Remote status for every submodule of an nbdev superproject, from the GitHub API. `--report` for the sync view, `--audit` to check `.gitmodules` against the repos the account owns, `--json` for machine output |
|
|
66
|
-
| [`fleet`](https://bthek1.github.io/nbdevAuto/fleet.html#fleet) | Run one command across every submodule:
|
|
67
|
-
| `h` | Print the list of available commands |
|
|
61
|
+
| [`fleet`](https://bthek1.github.io/nbdevAuto/fleet.html#fleet) | Run one command across every submodule: \`fleet upload |
|
|
68
62
|
|
|
69
|
-
Both [`prep`](https://bthek1.github.io/nbdevAuto/automate.html#prep) and [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload) take `-p` to choose which version part to increment; it defaults to 2, the patch, so every [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload) ships a new version.
|
|
63
|
+
Both [`prep`](https://bthek1.github.io/nbdevAuto/automate.html#prep) and [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload) take `-p` to choose which version part to increment; it defaults to 2, the patch, so every [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload) ships a new version. Use `-p 1` for a minor release.
|
|
70
64
|
|
|
71
|
-
|
|
65
|
+
Pushing to `main` publishes to PyPI on its own: `publish.yaml` runs after CI passes, and skips quietly when the version is already there.
|
|
72
66
|
|
|
73
67
|
[`ghstatus`](https://bthek1.github.io/nbdevAuto/github.html#ghstatus) needs the `gh` extra (`pip install 'nbdevAuto[gh]'`), which brings in `githubkit`. It is an extra rather than a dependency because githubkit pulls pydantic, httpx and hishel behind it, which is a lot of weight for anyone who only wants [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload). Without it the command exits 3 with an install hint rather than a traceback. It takes its token from `$GITHUB_TOKEN` / `$GH_TOKEN`, then `gh auth token`.
|
|
74
68
|
|
|
75
|
-
|
|
69
|
+
---
|
|
76
70
|
|
|
77
71
|
## The Output Contract
|
|
78
72
|
|
|
79
|
-
Every command reports through one grid, defined in [Automate](
|
|
73
|
+
Every command reports through one grid, defined in [Automate](https://bthek1.github.io/nbdevAuto/automate.html) and reused by [Fleet](https://bthek1.github.io/nbdevAuto/fleet.html). It exists because these commands run 19 times in a row, so anything that costs three lines per stage costs sixty over a fleet.
|
|
80
74
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
75
|
+
```
|
|
76
|
+
1/6 bump version (part 2) OK 75ms 0.3.67 -> 0.3.68
|
|
77
|
+
2/6 nbdev_export OK 129ms
|
|
78
|
+
3/6 nbdev_test OK 1.5s 6 notebooks, slowest 01_Automate.ipynb 1.0s
|
|
79
|
+
```
|
|
84
80
|
|
|
85
81
|
Four rules hold it together, and a change to any stage has to keep them:
|
|
86
82
|
|
|
87
83
|
- **One stage, one line, inside 88 columns.** The columns are fixed: `n/total` (5), label (22), outcome (4), duration (7), detail (the rest). A unit test renders real stages through a console pinned to that width and asserts every line fits.
|
|
88
84
|
- **A summariser returns short strings, not a transcript.** [`_test_summary`](https://bthek1.github.io/nbdevAuto/automate.html#_test_summary) turns a line per notebook into `6 notebooks, slowest X 1.0s`; [`_push_summary`](https://bthek1.github.io/nbdevAuto/automate.html#_push_summary) turns nine lines of git progress into a sha range and a size. Anything too long for the detail column moves to an indented continuation line, so a verbose summariser degrades the layout rather than breaking it.
|
|
89
|
-
- **A stage that shells out must capture at the file-descriptor level.** `redirect_stdout` only rebinds Python
|
|
90
|
-
- **A green OK has to mean something.** [`_run`](https://bthek1.github.io/nbdevAuto/automate.html#_run) raises on a non-zero exit rather than returning a code nobody reads, and the failure prints the command
|
|
85
|
+
- **A stage that shells out must capture at the file-descriptor level.** `redirect_stdout` only rebinds Python's `sys.stdout`, so a child process writing to fd 1 walks straight past it - which is how `nbdev_readme` used to spill sixteen lines of pandoc metadata into the middle of a run. [`_quiet`](https://bthek1.github.io/nbdevAuto/automate.html#_quiet) swaps fds 1 and 2 for a temp file as well and merges both captures.
|
|
86
|
+
- **A green OK has to mean something.** [`_run`](https://bthek1.github.io/nbdevAuto/automate.html#_run) raises on a non-zero exit rather than returning a code nobody reads, and the failure prints the command's own output. Before that, a failed `git push` still reported `OK`.
|
|
91
87
|
|
|
92
88
|
On a terminal the label is written first without a newline, so a slow stage is visible while it runs, then rewritten in place. Piped output skips that entirely, because a carriage return in a log file is just noise.
|
|
93
89
|
|
|
94
|
-
|
|
90
|
+
---
|
|
95
91
|
|
|
96
92
|
## Where It Is Used
|
|
97
93
|
|
|
98
|
-
The parent Knowledge repo
|
|
94
|
+
The parent Knowledge repo's `justfile` calls [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload) once per submodule. `just upload` runs it only where the working tree is dirty, `just upload --all` runs it everywhere. That is the main consumer, so a change to `automate.py` affects the publish path for every site in the collection.
|
|
99
95
|
|
|
100
|
-
[`ghstatus`](https://bthek1.github.io/nbdevAuto/github.html#ghstatus) is the other half of that loop. [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload) pushes to 19 repos and then goes blind: whether each repo
|
|
96
|
+
[`ghstatus`](https://bthek1.github.io/nbdevAuto/github.html#ghstatus) is the other half of that loop. [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload) pushes to 19 repos and then goes blind: whether each repo's CI passed and whether its Pages deploy actually landed is invisible from the terminal. `just ci_status`, `just ci_report` and `just ci_audit` in the parent repo are all thin wrappers around this one command, which answers for the whole fleet in about 1.5 seconds instead of 19 browser tabs.
|
|
101
97
|
|
|
102
|
-
|
|
98
|
+
---
|
|
103
99
|
|
|
104
100
|
## Releases
|
|
105
101
|
|
|
106
102
|
This package publishes itself. A `publish.yaml` workflow runs after CI passes on `main` and uploads to PyPI through Trusted Publishing, so no API token is stored in the repository. It reads `__version__` out of `nbdevAuto/__init__.py` and asks PyPI whether that version already exists: a new version is published, an existing one is skipped without failing the build. Once PyPI accepts it, the same workflow creates the matching GitHub release (tag `<version>`, title `v<version>`, auto-generated notes) with the built wheel and sdist attached, and skips if that release already exists.
|
|
107
103
|
|
|
108
|
-
Because [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload) bumps the patch version on every push, an ordinary commit made with [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload) ships a release. A plain `git commit` leaves the version alone and the workflow skips.
|
|
104
|
+
Because [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload) bumps the patch version on every push, an ordinary commit made with [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload) ships a release. A plain `git commit` leaves the version alone and the workflow skips. For a minor release, run `upload -p 1`.
|
|
109
105
|
|
|
110
|
-
|
|
106
|
+
---
|
|
111
107
|
|
|
112
108
|
## Not Covered Yet
|
|
113
109
|
|
|
114
110
|
- **No tests for the helpers.** `01_Automate.ipynb`, `03_GitHub.ipynb` and `04_Fleet.ipynb` all carry unit tests for their pure functions - the fleet ones against a throwaway superproject of real git repos - but the dataset and image helpers in `00_Functions.ipynb` are exercised only by being used, so a broken one surfaces in a downstream repo rather than here.
|
|
115
|
-
- **Undeclared dependencies.** `pyproject.toml` declares `graphviz` and `fastcore`, plus `githubkit` behind the `gh` extra. The helpers additionally import `fastai`, `fastbook`, `fastdownload`, `PIL`, `matplotlib`, `tqdm`, `
|
|
116
|
-
- **`core.py` is an empty nbdev stub** (a single `foo`) left over from `00_core.ipynb`, which no longer exists.
|
|
111
|
+
- **Undeclared dependencies.** `pyproject.toml` declares `graphviz` and `fastcore`, plus `githubkit` behind the `gh` extra. The helpers additionally import `fastai`, `fastbook`, `fastdownload`, `PIL`, `matplotlib`, `tqdm`, `nbdev` and `kaggle` (which also needs its credentials). All of those are imported lazily inside the function that needs them, so installing the package and running the console scripts still works - only the specific helper you call fails. Install them yourself.
|
|
117
112
|
- **`CHANGELOG.md` is still the nbdev stub** (`Version 1.0.0 - Initial release`) while the package is past 0.3.68. Nothing generates it, and [`upload`](https://bthek1.github.io/nbdevAuto/automate.html#upload) bumps the patch on every push, so it would need writing by hand or dropping.
|
|
118
113
|
- The docstrings are one-liners, so the rendered API pages are thin. The notebooks carry the real explanation.
|
|
119
114
|
|
|
120
|
-
|
|
115
|
+
---
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.3.96"
|
|
@@ -17,17 +17,11 @@ d = { 'syms': { 'nbdevAuto.automate': { 'nbdevAuto.automate.StepFailed': ('autom
|
|
|
17
17
|
'nbdevAuto.automate._push_summary': ('automate.html#_push_summary', 'nbdevAuto/automate.py'),
|
|
18
18
|
'nbdevAuto.automate._auto_msg': ('automate.html#_auto_msg', 'nbdevAuto/automate.py'),
|
|
19
19
|
'nbdevAuto.automate._staged_summary': ('automate.html#_staged_summary', 'nbdevAuto/automate.py'),
|
|
20
|
-
'nbdevAuto.automate._status_table': ('automate.html#_status_table', 'nbdevAuto/automate.py'),
|
|
21
20
|
'nbdevAuto.automate.StepFailed.__init__': ( 'automate.html#stepfailed.__init__',
|
|
22
21
|
'nbdevAuto/automate.py'),
|
|
23
22
|
'nbdevAuto.automate.prep': ('automate.html#prep', 'nbdevAuto/automate.py'),
|
|
24
23
|
'nbdevAuto.automate.gacp': ('automate.html#gacp', 'nbdevAuto/automate.py'),
|
|
25
|
-
'nbdevAuto.automate.
|
|
26
|
-
'nbdevAuto.automate.upload': ('automate.html#upload', 'nbdevAuto/automate.py'),
|
|
27
|
-
'nbdevAuto.automate.release_git': ('automate.html#release_git', 'nbdevAuto/automate.py'),
|
|
28
|
-
'nbdevAuto.automate.release_pypi': ('automate.html#release_pypi', 'nbdevAuto/automate.py'),
|
|
29
|
-
'nbdevAuto.automate.release': ('automate.html#release', 'nbdevAuto/automate.py'),
|
|
30
|
-
'nbdevAuto.automate.help_output': ('automate.html#help_output', 'nbdevAuto/automate.py')},
|
|
24
|
+
'nbdevAuto.automate.upload': ('automate.html#upload', 'nbdevAuto/automate.py')},
|
|
31
25
|
'nbdevAuto.fleet': { 'nbdevAuto.fleet.Skip': ('fleet.html#skip', 'nbdevAuto/fleet.py'),
|
|
32
26
|
'nbdevAuto.fleet.Outcome': ('fleet.html#outcome', 'nbdevAuto/fleet.py'),
|
|
33
27
|
'nbdevAuto.fleet.Report': ('fleet.html#report', 'nbdevAuto/fleet.py'),
|
|
@@ -48,7 +42,6 @@ d = { 'syms': { 'nbdevAuto.automate': { 'nbdevAuto.automate.StepFailed': ('autom
|
|
|
48
42
|
'nbdevAuto.fleet.push_one': ('fleet.html#push_one', 'nbdevAuto/fleet.py'),
|
|
49
43
|
'nbdevAuto.fleet.copy_one': ('fleet.html#copy_one', 'nbdevAuto/fleet.py'),
|
|
50
44
|
'nbdevAuto.fleet.fleet_push': ('fleet.html#fleet_push', 'nbdevAuto/fleet.py'),
|
|
51
|
-
'nbdevAuto.fleet.fleet_copy': ('fleet.html#fleet_copy', 'nbdevAuto/fleet.py'),
|
|
52
45
|
'nbdevAuto.fleet.fleet_template': ('fleet.html#fleet_template', 'nbdevAuto/fleet.py'),
|
|
53
46
|
'nbdevAuto.fleet._porcelain': ('fleet.html#_porcelain', 'nbdevAuto/fleet.py'),
|
|
54
47
|
'nbdevAuto.fleet.status_one': ('fleet.html#status_one', 'nbdevAuto/fleet.py'),
|
|
@@ -82,8 +75,7 @@ d = { 'syms': { 'nbdevAuto.automate': { 'nbdevAuto.automate.StepFailed': ('autom
|
|
|
82
75
|
'nbdevAuto.fleet.usage': ('fleet.html#usage', 'nbdevAuto/fleet.py'),
|
|
83
76
|
'nbdevAuto.fleet.run_verb': ('fleet.html#run_verb', 'nbdevAuto/fleet.py'),
|
|
84
77
|
'nbdevAuto.fleet.fleet': ('fleet.html#fleet', 'nbdevAuto/fleet.py')},
|
|
85
|
-
'nbdevAuto.functions': { 'nbdevAuto.functions.
|
|
86
|
-
'nbdevAuto.functions.download_pic': ('functions.html#download_pic', 'nbdevAuto/functions.py'),
|
|
78
|
+
'nbdevAuto.functions': { 'nbdevAuto.functions.download_pic': ('functions.html#download_pic', 'nbdevAuto/functions.py'),
|
|
87
79
|
'nbdevAuto.functions.create_searches_folder': ( 'functions.html#create_searches_folder',
|
|
88
80
|
'nbdevAuto/functions.py'),
|
|
89
81
|
'nbdevAuto.functions.download_search_image': ( 'functions.html#download_search_image',
|
|
@@ -116,6 +108,7 @@ d = { 'syms': { 'nbdevAuto.automate': { 'nbdevAuto.automate.StepFailed': ('autom
|
|
|
116
108
|
'nbdevAuto.github.client': ('github.html#client', 'nbdevAuto/github.py'),
|
|
117
109
|
'nbdevAuto.github.gather_status': ('github.html#gather_status', 'nbdevAuto/github.py'),
|
|
118
110
|
'nbdevAuto.github._state': ('github.html#_state', 'nbdevAuto/github.py'),
|
|
111
|
+
'nbdevAuto.github._table': ('github.html#_table', 'nbdevAuto/github.py'),
|
|
119
112
|
'nbdevAuto.github.format_table': ('github.html#format_table', 'nbdevAuto/github.py'),
|
|
120
113
|
'nbdevAuto.github.failures': ('github.html#failures', 'nbdevAuto/github.py'),
|
|
121
114
|
'nbdevAuto.github.has_failure': ('github.html#has_failure', 'nbdevAuto/github.py'),
|
|
@@ -132,20 +125,7 @@ d = { 'syms': { 'nbdevAuto.automate': { 'nbdevAuto.automate.StepFailed': ('autom
|
|
|
132
125
|
'nbdevAuto.github.gather_audit': ('github.html#gather_audit', 'nbdevAuto/github.py'),
|
|
133
126
|
'nbdevAuto.github._wrap': ('github.html#_wrap', 'nbdevAuto/github.py'),
|
|
134
127
|
'nbdevAuto.github.format_audit': ('github.html#format_audit', 'nbdevAuto/github.py'),
|
|
135
|
-
'nbdevAuto.github.ghstatus': ('github.html#ghstatus', 'nbdevAuto/github.py')},
|
|
136
|
-
'nbdevAuto.pdf': { 'nbdevAuto.pdf.PDFreader': ('pdf_reader.html#pdfreader', 'nbdevAuto/pdf.py'),
|
|
137
|
-
'nbdevAuto.pdf.PDFreader.__init__': ('pdf_reader.html#pdfreader.__init__', 'nbdevAuto/pdf.py'),
|
|
138
|
-
'nbdevAuto.pdf.PDFreader.__str__': ('pdf_reader.html#pdfreader.__str__', 'nbdevAuto/pdf.py'),
|
|
139
|
-
'nbdevAuto.pdf.PDFreader.__repr__': ('pdf_reader.html#pdfreader.__repr__', 'nbdevAuto/pdf.py'),
|
|
140
|
-
'nbdevAuto.pdf.PDFreader.__len__': ('pdf_reader.html#pdfreader.__len__', 'nbdevAuto/pdf.py'),
|
|
141
|
-
'nbdevAuto.pdf.PDFreader.filepath': ('pdf_reader.html#pdfreader.filepath', 'nbdevAuto/pdf.py'),
|
|
142
|
-
'nbdevAuto.pdf.PDFreader.length': ('pdf_reader.html#pdfreader.length', 'nbdevAuto/pdf.py'),
|
|
143
|
-
'nbdevAuto.pdf.PDFreader.display_pdf_slides': ( 'pdf_reader.html#pdfreader.display_pdf_slides',
|
|
144
|
-
'nbdevAuto/pdf.py'),
|
|
145
|
-
'nbdevAuto.pdf.PDFreader.__call__': ('pdf_reader.html#pdfreader.__call__', 'nbdevAuto/pdf.py'),
|
|
146
|
-
'nbdevAuto.pdf.PDFreader.__getitem__': ('pdf_reader.html#pdfreader.__getitem__', 'nbdevAuto/pdf.py'),
|
|
147
|
-
'nbdevAuto.pdf.PDFreader.slides': ('pdf_reader.html#pdfreader.slides', 'nbdevAuto/pdf.py'),
|
|
148
|
-
'nbdevAuto.pdf.PDFreader.size': ('pdf_reader.html#pdfreader.size', 'nbdevAuto/pdf.py')}},
|
|
128
|
+
'nbdevAuto.github.ghstatus': ('github.html#ghstatus', 'nbdevAuto/github.py')}},
|
|
149
129
|
'settings': { 'branch': 'main',
|
|
150
130
|
'git_url': 'https://github.com/bthek1/nbdevAuto',
|
|
151
131
|
'doc_host': 'https://bthek1.github.io',
|
|
@@ -5,15 +5,13 @@ Docs: https://bthek1.github.io/nbdevAuto/automate.html.md"""
|
|
|
5
5
|
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/01_Automate.ipynb.
|
|
6
6
|
|
|
7
7
|
# %% auto #0
|
|
8
|
-
__all__ = ['prep', 'gacp', '
|
|
8
|
+
__all__ = ['prep', 'gacp', 'upload']
|
|
9
9
|
|
|
10
10
|
# %% ../nbs/01_Automate.ipynb #6d1499d1-aa55-47d8-92fd-fa056b1fb135
|
|
11
11
|
from fastcore.script import *
|
|
12
|
-
from rich import box
|
|
13
12
|
from rich.console import Console
|
|
14
13
|
from rich.markup import escape
|
|
15
14
|
from rich.rule import Rule
|
|
16
|
-
from rich.table import Table
|
|
17
15
|
|
|
18
16
|
# %% ../nbs/01_Automate.ipynb #7c1e5a90-3f52-4d21-9b6a-2c0f4e8d1a37
|
|
19
17
|
import os
|
|
@@ -40,11 +38,8 @@ _W_DUR = 7
|
|
|
40
38
|
_W_HEAD = _W_NUM + _W_LABEL + 1 + _W_STAT + 1 + _W_DUR + 2
|
|
41
39
|
_W_DETAIL = _WIDTH - _W_HEAD
|
|
42
40
|
|
|
43
|
-
# `git status -s` codes:
|
|
44
|
-
#
|
|
45
|
-
_CODE_STYLE = {"M":"yellow", "A":"green", "D":"red", "R":"cyan", "C":"cyan", "U":"magenta", "?":"dim"}
|
|
46
|
-
_CODE_LABEL = {"M":"modified", "A":"added", "D":"deleted", "R":"renamed", "C":"copied",
|
|
47
|
-
"U":"conflict", "?":"untracked"}
|
|
41
|
+
# `git status -s` codes: the verb a commit subject gets when every staged path carries
|
|
42
|
+
# that same code.
|
|
48
43
|
_CODE_VERB = {"M":"update", "A":"add", "D":"remove", "R":"rename", "C":"copy",
|
|
49
44
|
"U":"merge", "?":"add"}
|
|
50
45
|
|
|
@@ -230,21 +225,6 @@ def _staged_summary(porcelain, width=_W_DETAIL):
|
|
|
230
225
|
tail = f", +{n - len(shown)}" if len(shown) < n else ""
|
|
231
226
|
return [f"{n} staged: {', '.join(shown)}{tail}"]
|
|
232
227
|
|
|
233
|
-
def _status_table(porcelain):
|
|
234
|
-
"Render `git status -s` output as a table, one row per path"
|
|
235
|
-
t = Table(box=None, show_header=False, pad_edge=False, expand=False)
|
|
236
|
-
t.add_column("code", no_wrap=True, justify="right")
|
|
237
|
-
t.add_column("path", overflow="fold")
|
|
238
|
-
t.add_column("what", style="dim", no_wrap=True)
|
|
239
|
-
n = 0
|
|
240
|
-
for line in porcelain.splitlines():
|
|
241
|
-
if not line.strip(): continue
|
|
242
|
-
code, path = line[:2].strip(), line[3:]
|
|
243
|
-
style = _CODE_STYLE.get(code[:1], "white")
|
|
244
|
-
t.add_row(f"[{style}]{code}[/{style}]", escape(path), _CODE_LABEL.get(code[:1], ""))
|
|
245
|
-
n += 1
|
|
246
|
-
return t, n
|
|
247
|
-
|
|
248
228
|
# %% ../nbs/01_Automate.ipynb #3a6f81d2-5c47-4e19-8b03-9d2a7f6c0e15
|
|
249
229
|
@call_parse
|
|
250
230
|
def prep(
|
|
@@ -301,36 +281,6 @@ def gacp(
|
|
|
301
281
|
d += _push_summary(_run("git", "push"))
|
|
302
282
|
_done("gacp", t0)
|
|
303
283
|
|
|
304
|
-
# %% ../nbs/01_Automate.ipynb #88017a1b-55c1-4833-aeb6-277a7e5b6314
|
|
305
|
-
def status():
|
|
306
|
-
"Show the working tree state"
|
|
307
|
-
import subprocess
|
|
308
|
-
|
|
309
|
-
def _git(*a, **kw): return subprocess.check_output(["git", *a], **kw).decode('utf-8').strip()
|
|
310
|
-
|
|
311
|
-
_banner("status")
|
|
312
|
-
branch = _git("branch", "--show-current") or "DETACHED"
|
|
313
|
-
line = f"on [bold]{branch}[/bold]"
|
|
314
|
-
try:
|
|
315
|
-
behind, ahead = _git("rev-list", "--left-right", "--count", "@{upstream}...HEAD",
|
|
316
|
-
stderr=subprocess.DEVNULL).split()
|
|
317
|
-
if behind != "0": line += f" [yellow]behind {behind}[/yellow]"
|
|
318
|
-
if ahead != "0": line += f" [cyan]ahead {ahead}[/cyan]"
|
|
319
|
-
if behind == ahead == "0": line += " [dim]in step with upstream[/dim]"
|
|
320
|
-
except subprocess.CalledProcessError:
|
|
321
|
-
line += " [dim]no upstream[/dim]"
|
|
322
|
-
console.print(line)
|
|
323
|
-
|
|
324
|
-
# NOT via _git: `git status -s` pads the code to two columns, so stripping the
|
|
325
|
-
# output would eat the leading space of the first line and shift its path by one.
|
|
326
|
-
porcelain = subprocess.check_output(["git", "status", "-s"]).decode('utf-8')
|
|
327
|
-
if not porcelain:
|
|
328
|
-
console.print("[green]clean[/green]")
|
|
329
|
-
return
|
|
330
|
-
table, n = _status_table(porcelain)
|
|
331
|
-
console.print(table)
|
|
332
|
-
console.print(f"[dim]{n} path{'' if n == 1 else 's'} changed[/dim]")
|
|
333
|
-
|
|
334
284
|
# %% ../nbs/01_Automate.ipynb #8d777a41-0160-47f8-b51c-b14360b62da4
|
|
335
285
|
@call_parse
|
|
336
286
|
def upload(
|
|
@@ -340,54 +290,3 @@ def upload(
|
|
|
340
290
|
"prep then gacp: the everyday command for shipping a notebook change"
|
|
341
291
|
prep(p)
|
|
342
292
|
gacp(m)
|
|
343
|
-
|
|
344
|
-
# %% ../nbs/01_Automate.ipynb #dee37b06-c946-4b40-be0f-056e133751ea
|
|
345
|
-
def release_git():
|
|
346
|
-
"Bump the MINOR version, then tag and create a GitHub release"
|
|
347
|
-
import nbdev.release
|
|
348
|
-
_banner("gitrelease")
|
|
349
|
-
t0 = perf_counter()
|
|
350
|
-
with _step(1, 2, "bump minor version") as d, _quiet() as out:
|
|
351
|
-
nbdev.release.nbdev_bump_version(1)
|
|
352
|
-
d += _version_summary(out.getvalue())
|
|
353
|
-
with _step(2, 2, "tag and create the GitHub release"):
|
|
354
|
-
nbdev.release.release_git()
|
|
355
|
-
_done("gitrelease", t0)
|
|
356
|
-
|
|
357
|
-
# %% ../nbs/01_Automate.ipynb #288708c6-194a-4059-9ff0-ae330079c199
|
|
358
|
-
def release_pypi():
|
|
359
|
-
"Build the sdist and wheel, then upload to PyPI with twine. CI publishes on push, so this is the manual path"
|
|
360
|
-
import nbdev.release
|
|
361
|
-
_banner("piprelease")
|
|
362
|
-
t0 = perf_counter()
|
|
363
|
-
# Deliberately not quieted: a twine upload is worth watching line by line.
|
|
364
|
-
with _step(1, 1, "build and upload to PyPI"):
|
|
365
|
-
nbdev.release.release_pypi()
|
|
366
|
-
_done("piprelease", t0)
|
|
367
|
-
|
|
368
|
-
# %% ../nbs/01_Automate.ipynb #dd798178-9d58-457e-969a-d86a5e8bf875
|
|
369
|
-
def release():
|
|
370
|
-
"release_git then release_pypi"
|
|
371
|
-
release_git()
|
|
372
|
-
release_pypi()
|
|
373
|
-
|
|
374
|
-
# %% ../nbs/01_Automate.ipynb #c4d2bd52-04c4-43fe-890b-b4cb5da8d206
|
|
375
|
-
def help_output():
|
|
376
|
-
"Print every console script this package installs, with its help"
|
|
377
|
-
from importlib.metadata import distribution
|
|
378
|
-
try:
|
|
379
|
-
eps = [e for e in distribution("nbdevAuto").entry_points if e.group == "console_scripts"]
|
|
380
|
-
except Exception:
|
|
381
|
-
# Running from a source tree with nothing installed: fall back to fastcore.
|
|
382
|
-
from fastcore.xtras import console_help
|
|
383
|
-
return console_help('nbdevAuto')
|
|
384
|
-
_banner("commands")
|
|
385
|
-
t = Table(box=box.SIMPLE, show_header=False, pad_edge=False, expand=False)
|
|
386
|
-
t.add_column("command", style="bold cyan", no_wrap=True)
|
|
387
|
-
t.add_column("does", overflow="fold")
|
|
388
|
-
for e in sorted(eps, key=lambda e: e.name):
|
|
389
|
-
try: doc = escape((e.load().__doc__ or "").strip().splitlines()[0])
|
|
390
|
-
except Exception: doc = "[red]could not load[/red]"
|
|
391
|
-
t.add_row(e.name, doc)
|
|
392
|
-
console.print(t)
|
|
393
|
-
console.print(escape("ghstatus needs the gh extra: pip install 'nbdevAuto[gh]'"), style="dim")
|