Project-MONAI / Project-MONAI/tutorials

`runner.sh` Parses Some Files Incorrectly

Offen
#1,805 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Jupyter Notebook
Sterne
2.5k
Forks
803
Ø Merge
6 T. 22 Std.
Gemergte PRs (30 T.)
3

Beschreibung

Describe the bug
The runner.sh script parses out the output from jupytext into something for feeding into pep8. sed is used in places to pick parts out, however for some weirdly formatting Python this will introduce syntax errors. For example, the following will not be interpreted correctly:

if epoch % 10 == 0:
        print(
            "Train: reconstruction: %.4f; generator: %.4f; discriminator: %.4f; perceptual: %.4f; kld: %.4f"
            % (
                epoch_recon_losses[-1],
                epoch_gen_losses[-1],
                epoch_disc_losses[-1],
                epoch_perc_losses[-1],
                epoch_kld_losses[-1],
            )
        )

The solution is to reformulate the code to avoid these sorts of issues. This example here isn't very attractive code anyway so a refactor to break the contents into multiple lines which are read properly wouldn't hurt anyhow. There will be other cases potentially that are well-formed code but still introduce parsing issues.

This is a minor issue I haven't had time to work on a solution for other than to refactor code, a solution to using jupytext and sed better should be investigated later.

To Reproduce
This can be seen as a problem in PR #1794 currently though a fix is being worked on.

Expected behavior
Script shouldn't introduce issues

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit der Untersuchung von runner.sh und seinem jupytext- und sed-Extraktionspfad und vergleiche dann das in PR #1794 beschriebene Verhalten. Als erledigt gilt die Aufgabe, wenn das Skript wohlgeformtes Python beim Extrahieren von Inhalten für pep8 bewahrt, ohne Syntaxfehler einzuführen, einschließlich des hier gezeigten mehrzeiligen Beispiels.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
jupyter-notebook, python, shell
Bereich
tooling
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

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