AnswerDotAI / AnswerDotAI/nbdev
Commands in the `release` module always return exit code 0, even if they fail
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Jupyter Notebook
- Sterne
- 5.3k
- Forks
- 514
- Ø Merge
- 2 T. 30 Min.
- Gemergte PRs (30 T.)
- 8
Beschreibung
Hi,
When executing commands such as nbdev_pypi from a shell (which get routed to nbdev.release:release_pypi), the commands always return exit code 0 regardless of the errors happening inside the command.
I ran into this issue while using nbdev_pypi inside my CI/CD. If I forget to bump the version, for example, the twine upload command will fail with a "409 Conflict" error, but the nbdev_pypi command still returns error code 0 (success).
This is problematic, because there is no way to catch this error and do something useful (like fail the CI/CD build).
The code for release_pypi uses os.system calls like:
system(f'twine upload --repository {repository} {_dir}/dist/*')
As far as I can see, the call to os.system() returns the exit code as a 0/1 but does not throw an exception.
I'm happy to contribute a pull request to fix this, but would like some guidance on what is the right way to go about it.
Options I see:
- Change code to use subprocess instead of os.system()
- Keep using os.system, but instead of calling it directly - add a wrapping function like execute_throw_on_error() which will check the response code and throw exception if it's not 0.
- Somehow handle it in a more generic way in the the call_parse decorator (but what do we do if there are multiple calls to os.system and we want to fail if either fails?)
Thanks!
Julian.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne in nbdev/release.py bei release_pypi und dem zugehörigen os.system-Aufruf für twine upload. Untersuche die anderen Release-Befehle auf dieselbe Behandlung des Exit-Status und reproduziere anschließend einen fehlgeschlagenen Upload wie den gemeldeten 409 Conflict. Erledigt ist die Aufgabe, wenn ein fehlgeschlagener Befehl einen Exit-Code ungleich null weitergibt, sodass CI/CD den Fehler erkennen kann.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- ci-cd, release
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 48/100