AnswerDotAI / AnswerDotAI/nbdev

nbdev_trust fails - assuming notebooks are in "nbs" directory?

Offen
#1,258 2 Kommentare 3 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Jupyter Notebook
Sterne
5.3k
Forks
513
Ø Merge
2 T. 30 Min.
Gemergte PRs (30 T.)
8

Beschreibung

Hi,

I'm new to nbdev, and trying to use just the hooks to have notebooks play nice with Git.

I wanted to check out the merge-conflict handling so I generated a conflict and did a pull, but `nbdev_trust` fails as shown here:
```
dlang@cn002:~/psychic-fiesta$ git pull
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 1), reused 3 (delta 1), pack-reused 0
Unpacking objects: 100% (3/3), 4.52 KiB | 231.00 KiB/s, done.
From github.com:dstndstn/psychic-fiesta
f76b915..a6fe989 main -> origin/main
Successfully merged conflicts!
Auto-merging Untitled190.ipynb
Merge made by the 'recursive' strategy.
Untitled190.ipynb | 290 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------
1 file changed, 244 insertions(+), 46 deletions(-)
Traceback (most recent call last):
File "/cm/shared/apps/conda-environments/jupyterhub3/bin/nbdev_trust", line 8, in
sys.exit(nbdev_trust())
File "/cm/shared/apps/conda-environments/jupyterhub3/lib/python3.8/site-packages/fastcore/script.py", line 119, in _f
return tfunc(**merge(args, args_from_prog(func, xtra)))
File "/cm/shared/apps/conda-environments/jupyterhub3/lib/python3.8/site-packages/nbdev/clean.py", line 43, in nbdev_trust
nb = read_nb(fn)
File "/cm/shared/apps/conda-environments/jupyterhub3/lib/python3.8/site-packages/execnb/nbio.py", line 57, in read_nb
res = dict2nb(_read_json(path, encoding='utf-8'))
File "/cm/shared/apps/conda-environments/jupyterhub3/lib/python3.8/site-packages/execnb/nbio.py", line 16, in _read_json
return loads(Path(self).read_text(encoding=encoding, errors=errors))
File "/cm/shared/apps/conda-environments/jupyterhub3/lib/python3.8/pathlib.py", line 1235, in read_text
with self.open(mode='r', encoding=encoding, errors=errors) as f:
File "/cm/shared/apps/conda-environments/jupyterhub3/lib/python3.8/pathlib.py", line 1221, in open
return io.open(self, mode, buffering, encoding, errors, newline,
File "/cm/shared/apps/conda-environments/jupyterhub3/lib/python3.8/pathlib.py", line 1077, in _opener
return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/home/dlang/psychic-fiesta/nbs'
dlang@cn002:~/psychic-fiesta$
```

where my repository contains just:
```
dlang@mn003:~/psychic-fiesta$ ls -1
hello.txt
README.md
Untitled190.ipynb
```

This seems to be coming from the default config; running `nbdev_trust` in pdb, I see:
```
> /cm/shared/apps/conda-environments/jupyterhub3/lib/python3.8/site-packages/nbdev/clean.py(34)nbdev_trust()
-> fname = Path(fname if fname else get_config().nbs_path)
(Pdb) p get_config().nbs_path
Path('/home/dlang/psychic-fiesta/nbs')
```

I don't even have a `~/.config/nbdev/` directory, so it's not immediately obvious where to change this. (Yeah,

This web page suggests that the `nbdev` hooks are supposed to be usable for "any git repo, including those that don’t use the broader nbdev system.".... but this config default seems to break that promise, and isn't mentioned in the "Configuring nbdev hooks" section.
https://nbdev.fast.ai/tutorials/git_friendly_jupyter.html

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne damit, nbdev_trust in einem Repository ohne ein nbs-Verzeichnis zu reproduzieren, und untersuche dann nbdev/clean.py, wo der Traceback zeigt, dass der Pfad ausgewählt wird. Sieh dir den im Issue verlinkten Abschnitt Configuring nbdev hooks an. Als erledigt gilt die Aufgabe, wenn die Hooks für ein Repository mit Notebooks in dessen Root-Verzeichnis funktionieren oder die erforderliche Konfiguration und Einschränkung klar dokumentiert sind.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
jupyter, python
Bereich
tooling
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.