nbdevAuto 0.3.95__tar.gz → 0.3.97__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.95/nbdevAuto.egg-info → nbdevauto-0.3.97}/PKG-INFO +6 -6
- {nbdevauto-0.3.95 → nbdevauto-0.3.97}/README.md +5 -5
- nbdevauto-0.3.97/nbdevAuto/__init__.py +1 -0
- {nbdevauto-0.3.95 → nbdevauto-0.3.97}/nbdevAuto/_modidx.py +1 -0
- {nbdevauto-0.3.95 → nbdevauto-0.3.97}/nbdevAuto/fleet.py +4 -2
- {nbdevauto-0.3.95 → nbdevauto-0.3.97}/nbdevAuto/github.py +74 -65
- {nbdevauto-0.3.95 → nbdevauto-0.3.97/nbdevAuto.egg-info}/PKG-INFO +6 -6
- nbdevauto-0.3.95/nbdevAuto/__init__.py +0 -1
- {nbdevauto-0.3.95 → nbdevauto-0.3.97}/LICENSE +0 -0
- {nbdevauto-0.3.95 → nbdevauto-0.3.97}/MANIFEST.in +0 -0
- {nbdevauto-0.3.95 → nbdevauto-0.3.97}/nbdevAuto/automate.py +0 -0
- {nbdevauto-0.3.95 → nbdevauto-0.3.97}/nbdevAuto/functions.py +0 -0
- {nbdevauto-0.3.95 → nbdevauto-0.3.97}/nbdevAuto.egg-info/SOURCES.txt +0 -0
- {nbdevauto-0.3.95 → nbdevauto-0.3.97}/nbdevAuto.egg-info/dependency_links.txt +0 -0
- {nbdevauto-0.3.95 → nbdevauto-0.3.97}/nbdevAuto.egg-info/entry_points.txt +0 -0
- {nbdevauto-0.3.95 → nbdevauto-0.3.97}/nbdevAuto.egg-info/requires.txt +0 -0
- {nbdevauto-0.3.95 → nbdevauto-0.3.97}/nbdevAuto.egg-info/top_level.txt +0 -0
- {nbdevauto-0.3.95 → nbdevauto-0.3.97}/pyproject.toml +0 -0
- {nbdevauto-0.3.95 → nbdevauto-0.3.97}/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.97
|
|
4
4
|
Summary: automating nbdev
|
|
5
5
|
Author-email: Benedict Thekkel <bthekkel1@gmail.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -36,7 +36,7 @@ Command line automation for the nbdev publish cycle, plus the dataset and image
|
|
|
36
36
|
|
|
37
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.
|
|
38
38
|
|
|
39
|
-
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.
|
|
40
40
|
|
|
41
41
|
---
|
|
42
42
|
|
|
@@ -53,7 +53,7 @@ Requires Python 3.10 or newer.
|
|
|
53
53
|
|
|
54
54
|
## Use
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
The commands are console scripts, so the common case is a bare word in the terminal at the root of an nbdev project:
|
|
57
57
|
|
|
58
58
|
```sh
|
|
59
59
|
upload -m "commit message" # export, test, clean, then add/commit/push
|
|
@@ -100,7 +100,7 @@ Pushing to `main` publishes to PyPI on its own: `publish.yaml` runs after CI pas
|
|
|
100
100
|
|
|
101
101
|
## The Output Contract
|
|
102
102
|
|
|
103
|
-
Every command
|
|
103
|
+
Every command prints through [Rich](https://github.com/Textualize/rich). The commands that run stages report through one grid, defined in [Automate](https://bthek1.github.io/nbdevAuto/automate.html) and reused by [Fleet](https://bthek1.github.io/nbdevAuto/fleet.html); [`ghstatus`](https://bthek1.github.io/nbdevAuto/github.html#ghstatus) prints Rich tables instead (see [GitHub](https://bthek1.github.io/nbdevAuto/github.html)), and its `--json` output stays plain. It exists because these commands run 19 times in a row, so anything that costs three lines per stage costs sixty over a fleet.
|
|
104
104
|
|
|
105
105
|
```
|
|
106
106
|
1/6 bump version (part 2) OK 75ms 0.3.67 -> 0.3.68
|
|
@@ -121,9 +121,9 @@ On a terminal the label is written first without a newline, so a slow stage is v
|
|
|
121
121
|
|
|
122
122
|
## Where It Is Used
|
|
123
123
|
|
|
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
|
|
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.
|
|
125
125
|
|
|
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
|
|
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.
|
|
127
127
|
|
|
128
128
|
---
|
|
129
129
|
|
|
@@ -6,7 +6,7 @@ Command line automation for the nbdev publish cycle, plus the dataset and image
|
|
|
6
6
|
|
|
7
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.
|
|
8
8
|
|
|
9
|
-
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.
|
|
10
10
|
|
|
11
11
|
---
|
|
12
12
|
|
|
@@ -23,7 +23,7 @@ Requires Python 3.10 or newer.
|
|
|
23
23
|
|
|
24
24
|
## Use
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
The commands are console scripts, so the common case is a bare word in the terminal at the root of an nbdev project:
|
|
27
27
|
|
|
28
28
|
```sh
|
|
29
29
|
upload -m "commit message" # export, test, clean, then add/commit/push
|
|
@@ -70,7 +70,7 @@ Pushing to `main` publishes to PyPI on its own: `publish.yaml` runs after CI pas
|
|
|
70
70
|
|
|
71
71
|
## The Output Contract
|
|
72
72
|
|
|
73
|
-
Every command
|
|
73
|
+
Every command prints through [Rich](https://github.com/Textualize/rich). The commands that run stages report through one grid, defined in [Automate](https://bthek1.github.io/nbdevAuto/automate.html) and reused by [Fleet](https://bthek1.github.io/nbdevAuto/fleet.html); [`ghstatus`](https://bthek1.github.io/nbdevAuto/github.html#ghstatus) prints Rich tables instead (see [GitHub](https://bthek1.github.io/nbdevAuto/github.html)), and its `--json` output stays plain. It exists because these commands run 19 times in a row, so anything that costs three lines per stage costs sixty over a fleet.
|
|
74
74
|
|
|
75
75
|
```
|
|
76
76
|
1/6 bump version (part 2) OK 75ms 0.3.67 -> 0.3.68
|
|
@@ -91,9 +91,9 @@ On a terminal the label is written first without a newline, so a slow stage is v
|
|
|
91
91
|
|
|
92
92
|
## Where It Is Used
|
|
93
93
|
|
|
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
|
|
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.
|
|
95
95
|
|
|
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
|
|
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.
|
|
97
97
|
|
|
98
98
|
---
|
|
99
99
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.3.97"
|
|
@@ -108,6 +108,7 @@ d = { 'syms': { 'nbdevAuto.automate': { 'nbdevAuto.automate.StepFailed': ('autom
|
|
|
108
108
|
'nbdevAuto.github.client': ('github.html#client', 'nbdevAuto/github.py'),
|
|
109
109
|
'nbdevAuto.github.gather_status': ('github.html#gather_status', 'nbdevAuto/github.py'),
|
|
110
110
|
'nbdevAuto.github._state': ('github.html#_state', 'nbdevAuto/github.py'),
|
|
111
|
+
'nbdevAuto.github._table': ('github.html#_table', 'nbdevAuto/github.py'),
|
|
111
112
|
'nbdevAuto.github.format_table': ('github.html#format_table', 'nbdevAuto/github.py'),
|
|
112
113
|
'nbdevAuto.github.failures': ('github.html#failures', 'nbdevAuto/github.py'),
|
|
113
114
|
'nbdevAuto.github.has_failure': ('github.html#has_failure', 'nbdevAuto/github.py'),
|
|
@@ -253,7 +253,9 @@ def fleet_template(
|
|
|
253
253
|
):
|
|
254
254
|
"Copy shared files into every submodule, filling ${owner} and ${repo} per submodule"
|
|
255
255
|
fs = [f for f in re.split(r"[,\s]+", files) if f]
|
|
256
|
-
if not fs:
|
|
256
|
+
if not fs:
|
|
257
|
+
console.print("[bold red]fleet template:[/bold red] no files given")
|
|
258
|
+
sys.exit(1)
|
|
257
259
|
rep = walk(lambda p, s: copy_one(p, s, files=fs, dest=dest, dry_run=dry_run, fill=True),
|
|
258
260
|
root=root, workers=8, style="line")
|
|
259
261
|
sys.exit(finish(rep, "would update" if dry_run else "updated"))
|
|
@@ -842,7 +844,7 @@ def fleet():
|
|
|
842
844
|
sidesteps the collision and keeps `--help` working per verb."""
|
|
843
845
|
picked = parse_verb(sys.argv[1:])
|
|
844
846
|
if not picked:
|
|
845
|
-
print(usage())
|
|
847
|
+
console.print(escape(usage()), highlight=False)
|
|
846
848
|
sys.exit(0 if sys.argv[1:2] in ([], ["-h"], ["--help"]) else 2)
|
|
847
849
|
# `_step` has already printed the failing command's output, so a traceback on top of
|
|
848
850
|
# it only buries the hint. One line and the exit code are all that is left to say.
|
|
@@ -5,11 +5,10 @@ Docs: https://bthek1.github.io/nbdevAuto/github.html.md"""
|
|
|
5
5
|
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/03_GitHub.ipynb.
|
|
6
6
|
|
|
7
7
|
# %% auto #0
|
|
8
|
-
__all__ = ['Submodule', 'CI_WORKFLOWS', 'PAGES_WORKFLOWS', 'FAILED', 'RUNNING', '
|
|
9
|
-
'
|
|
10
|
-
'
|
|
11
|
-
'
|
|
12
|
-
'format_audit', 'ghstatus']
|
|
8
|
+
__all__ = ['Submodule', 'CI_WORKFLOWS', 'PAGES_WORKFLOWS', 'FAILED', 'RUNNING', 'find_root', 'parse_gitmodules', 'resolve_token',
|
|
9
|
+
'local_sha', 'api_error', 'newest_run', 'repo_status', 'client', 'gather_status', 'format_table', 'failures',
|
|
10
|
+
'has_failure', 'git', 'local_state', 'ahead_behind', 'add_local', 'format_report', 'stale_sections',
|
|
11
|
+
'owned_repos', 'self_repo', 'audit_result', 'gather_audit', 'format_audit', 'ghstatus']
|
|
13
12
|
|
|
14
13
|
# %% ../nbs/03_GitHub.ipynb #519f31cd-5e6f-4ff9-9137-0293e57c0929
|
|
15
14
|
import asyncio
|
|
@@ -20,6 +19,10 @@ from collections import namedtuple
|
|
|
20
19
|
from pathlib import Path
|
|
21
20
|
|
|
22
21
|
from fastcore.script import *
|
|
22
|
+
from rich.console import Console
|
|
23
|
+
from rich.markup import escape
|
|
24
|
+
from rich.table import Table
|
|
25
|
+
from rich.text import Text
|
|
23
26
|
|
|
24
27
|
Submodule = namedtuple("Submodule", "path owner repo")
|
|
25
28
|
|
|
@@ -196,30 +199,32 @@ async def gather_status(subs, token=None, root=None):
|
|
|
196
199
|
FAILED = {"failure", "timed_out", "cancelled", "action_required", "startup_failure"}
|
|
197
200
|
RUNNING = {"in_progress", "queued", "requested", "waiting", "pending",
|
|
198
201
|
"building"} # "building" is the Pages build in flight
|
|
199
|
-
BOLD, RED, YELLOW, CYAN, DIM, OFF = "\033[1m", "\033[31m", "\033[33m", "\033[36m", "\033[2m", "\033[0m"
|
|
200
|
-
|
|
201
202
|
def _state(v):
|
|
202
|
-
"Display text and
|
|
203
|
-
if v is None: return "-",
|
|
204
|
-
if v in FAILED: return v.upper(),
|
|
205
|
-
if v in RUNNING: return v,
|
|
203
|
+
"Display text and Rich style for one conclusion / build status"
|
|
204
|
+
if v is None: return "-", "dim"
|
|
205
|
+
if v in FAILED: return v.upper(), "red"
|
|
206
|
+
if v in RUNNING: return v, "yellow"
|
|
206
207
|
return v, ""
|
|
207
208
|
|
|
208
|
-
def
|
|
209
|
-
"
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
209
|
+
def _table(*cols):
|
|
210
|
+
"A borderless table with a bold header row; cells never wrap, so one row stays one line"
|
|
211
|
+
t = Table(box=None, pad_edge=False, header_style="bold", show_edge=False)
|
|
212
|
+
for col in cols: t.add_column(col, no_wrap=True)
|
|
213
|
+
return t
|
|
214
|
+
|
|
215
|
+
def format_table(rows):
|
|
216
|
+
"The status table, one row per submodule"
|
|
217
|
+
t = _table("SUBMODULE", "CI", "PAGES", "BUILT", "LOCAL", "REMOTE")
|
|
213
218
|
for r in rows:
|
|
214
|
-
ci, ci_c = _state(r["ci"]["state"] if r["ci"] else None)
|
|
215
|
-
dp, dp_c = _state(r["deploy"]["state"] if r["deploy"] else None)
|
|
216
|
-
bl, bl_c = _state(r["built"])
|
|
217
219
|
# a local/remote mismatch is unpushed or unpulled work, not a failure
|
|
218
|
-
sync =
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
220
|
+
sync = "cyan" if (r["local"] and r["remote"] and r["local"] != r["remote"]) else ""
|
|
221
|
+
t.add_row(Text(r["path"]),
|
|
222
|
+
Text(*_state(r["ci"]["state"] if r["ci"] else None)),
|
|
223
|
+
Text(*_state(r["deploy"]["state"] if r["deploy"] else None)),
|
|
224
|
+
Text(*_state(r["built"])),
|
|
225
|
+
Text(r["local"] or "-", sync), Text(r["remote"] or "-", sync))
|
|
226
|
+
return t
|
|
227
|
+
|
|
223
228
|
|
|
224
229
|
# %% ../nbs/03_GitHub.ipynb #b3391604-c63e-4c83-9739-7d5d35025d13
|
|
225
230
|
def failures(rows):
|
|
@@ -231,7 +236,7 @@ def failures(rows):
|
|
|
231
236
|
def has_failure(rows):
|
|
232
237
|
"True when any workflow failed or a Pages build errored"
|
|
233
238
|
# A Pages build in flight is not a verdict: "building" is the state every
|
|
234
|
-
# healthy deploy passes through, and counting it red made `just
|
|
239
|
+
# healthy deploy passes through, and counting it red made `just ci_status` exit 1
|
|
235
240
|
# on a fleet that was merely mid-build, with no red row in the table to
|
|
236
241
|
# explain it. Same shape as the `_latest_run` bug in issue #8: a transient
|
|
237
242
|
# state read as a result. Unknown states still count as failures.
|
|
@@ -279,12 +284,9 @@ def add_local(rows, root, fetch=True):
|
|
|
279
284
|
return rows
|
|
280
285
|
|
|
281
286
|
# %% ../nbs/03_GitHub.ipynb #8ff8c6e9-7047-4717-882c-e67a65c8c344
|
|
282
|
-
def format_report(rows
|
|
283
|
-
"Local sync state plus remote health, one
|
|
284
|
-
|
|
285
|
-
head = (f"{'SUBMODULE':<28} {'BRANCH':<9} {'DIRTY':<5} {'BEHIND':<6} "
|
|
286
|
-
f"{'AHEAD':<5} {'CI':<9} {'PAGES':<9} {'BUILT':<7}")
|
|
287
|
-
out = [c(head, BOLD)]
|
|
287
|
+
def format_report(rows):
|
|
288
|
+
"Local sync state plus remote health, one row per submodule"
|
|
289
|
+
t = _table("SUBMODULE", "BRANCH", "DIRTY", "BEHIND", "AHEAD", "CI", "PAGES", "BUILT")
|
|
288
290
|
for r in rows:
|
|
289
291
|
br = r.get("branch") or "?"
|
|
290
292
|
detached = br == "HEAD"
|
|
@@ -292,16 +294,15 @@ def format_report(rows, color=True):
|
|
|
292
294
|
behind = "?" if r.get("behind") is None else str(r["behind"])
|
|
293
295
|
ahead = "?" if r.get("ahead") is None else str(r["ahead"])
|
|
294
296
|
# yellow for a detached HEAD, cyan for anything wanting a sync, push or upload
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
return "\n".join(out)
|
|
297
|
+
local = ("yellow" if detached else
|
|
298
|
+
"cyan" if (r.get("dirty") or r.get("behind") or r.get("ahead")) else "")
|
|
299
|
+
t.add_row(*(Text(v, local) for v in (r["path"], br, "YES" if r.get("dirty") else "no",
|
|
300
|
+
behind, ahead)),
|
|
301
|
+
Text(*_state(r["ci"]["state"] if r.get("ci") else None)),
|
|
302
|
+
Text(*_state(r["deploy"]["state"] if r.get("deploy") else None)),
|
|
303
|
+
Text(*_state(r.get("built"))))
|
|
304
|
+
return t
|
|
305
|
+
|
|
305
306
|
|
|
306
307
|
# %% ../nbs/03_GitHub.ipynb #31b3b22e-f332-471a-80f7-1b27314e53bf
|
|
307
308
|
def stale_sections(root=None):
|
|
@@ -354,25 +355,27 @@ def _wrap(items, width=92):
|
|
|
354
355
|
if cur: lines.append(cur)
|
|
355
356
|
return lines
|
|
356
357
|
|
|
357
|
-
def format_audit(res
|
|
358
|
-
"The audit as
|
|
359
|
-
|
|
360
|
-
|
|
358
|
+
def format_audit(res):
|
|
359
|
+
"The audit as Rich text. Only `gone` and `stale` are findings"
|
|
360
|
+
out = Text()
|
|
361
|
+
def line(s="", style=""): out.append(s + "\n", style)
|
|
362
|
+
line(f"Audit of .gitmodules against github.com/{res['login']}", "bold")
|
|
361
363
|
if res["gone"]:
|
|
362
|
-
|
|
363
|
-
|
|
364
|
+
line(f"\nIn .gitmodules but not on GitHub ({len(res['gone'])}):", "red")
|
|
365
|
+
for r in res["gone"]: line(f" {r}")
|
|
364
366
|
if res["stale"]:
|
|
365
|
-
|
|
366
|
-
|
|
367
|
+
line(f"\nSection name no longer matches its path ({len(res['stale'])}):", "yellow")
|
|
368
|
+
for n, p in res["stale"]: line(f' [submodule "{n}"] -> path = {p}')
|
|
367
369
|
if not res["gone"] and not res["stale"]:
|
|
368
|
-
|
|
370
|
+
line("\nEvery submodule resolves to a repo that exists, and every section name matches.")
|
|
369
371
|
if res["foreign"]:
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
out
|
|
375
|
-
return
|
|
372
|
+
line(f"\nSubmodules owned by someone else ({len(res['foreign'])}):", "dim")
|
|
373
|
+
for r in res["foreign"]: line(f" {r}")
|
|
374
|
+
line(f"\nOwned repos that are not submodules here ({len(res['untracked'])}), usually deliberate:", "dim")
|
|
375
|
+
for l in _wrap(res["untracked"]): line(f" {l}")
|
|
376
|
+
out.rstrip()
|
|
377
|
+
return out
|
|
378
|
+
|
|
376
379
|
|
|
377
380
|
# %% ../nbs/03_GitHub.ipynb #13693bba-b21c-4092-b5e4-b9ba45b4595e
|
|
378
381
|
@call_parse
|
|
@@ -382,12 +385,17 @@ def ghstatus(
|
|
|
382
385
|
offline:bool=False, # Skip the GitHub API entirely (implies --report)
|
|
383
386
|
no_fetch:bool=False, # Never fetch; unknown behind/ahead counts stay as ?
|
|
384
387
|
json:bool=False, # Emit JSON instead of the table
|
|
385
|
-
no_color:bool=False, # Disable
|
|
388
|
+
no_color:bool=False, # Disable colour
|
|
386
389
|
root:str=None, # Superproject root (default: nearest ancestor with .gitmodules)
|
|
387
390
|
):
|
|
388
391
|
"Remote CI, Pages and main-branch status for every submodule"
|
|
389
392
|
import sys
|
|
390
393
|
from json import dumps
|
|
394
|
+
# At least 160 columns, terminal or pipe: Rich otherwise fits the table to the terminal
|
|
395
|
+
# and truncates cells ("succe..."), where one long line per submodule is the better
|
|
396
|
+
# failure. The table only takes the width its content needs.
|
|
397
|
+
out = Console(no_color=no_color, width=max(Console().width, 160))
|
|
398
|
+
err = Console(stderr=True, no_color=no_color)
|
|
391
399
|
try:
|
|
392
400
|
base = Path(root) if root else find_root()
|
|
393
401
|
subs = parse_gitmodules(base)
|
|
@@ -400,27 +408,28 @@ def ghstatus(
|
|
|
400
408
|
rows = asyncio.run(gather_status(subs, root=base))
|
|
401
409
|
if report or offline: add_local(rows, base, fetch=not no_fetch)
|
|
402
410
|
except FileNotFoundError as e: # 2: bad input, and no fallback would help
|
|
403
|
-
print(f"{
|
|
411
|
+
err.print(f"[red]{escape(str(e))}[/red]")
|
|
404
412
|
sys.exit(2)
|
|
405
413
|
except (ImportError, RuntimeError) as e: # 3: cannot ask, so a git-only view is still useful
|
|
406
|
-
print(f"{
|
|
414
|
+
err.print(f"[red]{escape(str(e))}[/red]")
|
|
407
415
|
sys.exit(3)
|
|
408
416
|
except Exception as e: # 3: auth, rate limit, transport. Never report health here
|
|
409
|
-
print(f"{
|
|
417
|
+
err.print(f"[red]{escape(api_error(e))}[/red]")
|
|
410
418
|
sys.exit(3)
|
|
411
419
|
if audit:
|
|
412
|
-
print
|
|
420
|
+
# JSON stays plain print: it is machine output, and Rich would wrap and highlight it
|
|
421
|
+
if json: print(dumps(res, indent=2))
|
|
422
|
+
else: out.print(format_audit(res))
|
|
413
423
|
sys.exit(1 if res["gone"] else 0)
|
|
414
424
|
if json:
|
|
415
425
|
print(dumps({r["path"]: r for r in rows}, indent=2))
|
|
416
426
|
sys.exit(0)
|
|
417
|
-
print(format_report(rows
|
|
418
|
-
else format_table(rows, color=not no_color))
|
|
427
|
+
out.print(format_report(rows) if (report or offline) else format_table(rows))
|
|
419
428
|
for path, kind, url in failures(rows):
|
|
420
|
-
print(f"{
|
|
429
|
+
out.print(f"[red]{escape(path)}[/red] {kind} failed: {escape(url)}", soft_wrap=True, highlight=False)
|
|
421
430
|
hint = ("BEHIND>0 -> just sync AHEAD>0 -> just push DIRTY -> just upload"
|
|
422
431
|
if (report or offline) else "LOCAL != REMOTE -> just sync / just push")
|
|
423
|
-
print(f"\n
|
|
432
|
+
out.print(f"\n[dim]FAILURE -> open the url above {escape(hint)}[/dim]", highlight=False)
|
|
424
433
|
sys.exit(1 if has_failure(rows) else 0)
|
|
425
434
|
|
|
426
435
|
# %% ../nbs/03_GitHub.ipynb #552ba864-23f5-4fcc-b887-7bb8dca7bd54
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nbdevAuto
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.97
|
|
4
4
|
Summary: automating nbdev
|
|
5
5
|
Author-email: Benedict Thekkel <bthekkel1@gmail.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -36,7 +36,7 @@ Command line automation for the nbdev publish cycle, plus the dataset and image
|
|
|
36
36
|
|
|
37
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.
|
|
38
38
|
|
|
39
|
-
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.
|
|
40
40
|
|
|
41
41
|
---
|
|
42
42
|
|
|
@@ -53,7 +53,7 @@ Requires Python 3.10 or newer.
|
|
|
53
53
|
|
|
54
54
|
## Use
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
The commands are console scripts, so the common case is a bare word in the terminal at the root of an nbdev project:
|
|
57
57
|
|
|
58
58
|
```sh
|
|
59
59
|
upload -m "commit message" # export, test, clean, then add/commit/push
|
|
@@ -100,7 +100,7 @@ Pushing to `main` publishes to PyPI on its own: `publish.yaml` runs after CI pas
|
|
|
100
100
|
|
|
101
101
|
## The Output Contract
|
|
102
102
|
|
|
103
|
-
Every command
|
|
103
|
+
Every command prints through [Rich](https://github.com/Textualize/rich). The commands that run stages report through one grid, defined in [Automate](https://bthek1.github.io/nbdevAuto/automate.html) and reused by [Fleet](https://bthek1.github.io/nbdevAuto/fleet.html); [`ghstatus`](https://bthek1.github.io/nbdevAuto/github.html#ghstatus) prints Rich tables instead (see [GitHub](https://bthek1.github.io/nbdevAuto/github.html)), and its `--json` output stays plain. It exists because these commands run 19 times in a row, so anything that costs three lines per stage costs sixty over a fleet.
|
|
104
104
|
|
|
105
105
|
```
|
|
106
106
|
1/6 bump version (part 2) OK 75ms 0.3.67 -> 0.3.68
|
|
@@ -121,9 +121,9 @@ On a terminal the label is written first without a newline, so a slow stage is v
|
|
|
121
121
|
|
|
122
122
|
## Where It Is Used
|
|
123
123
|
|
|
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
|
|
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.
|
|
125
125
|
|
|
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
|
|
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.
|
|
127
127
|
|
|
128
128
|
---
|
|
129
129
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.3.95"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|