Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runner.sh Parses Some Files Incorrectly #1805

Open
ericspod opened this issue Aug 28, 2024 · 2 comments
Open

runner.sh Parses Some Files Incorrectly #1805

ericspod opened this issue Aug 28, 2024 · 2 comments

Comments

@ericspod
Copy link
Member

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

@ericspod
Copy link
Member Author

The issue for a user is that the script output describes syntax errors that aren't found in the original notebook, and references a line number of the generated script file and not where the issue is in the notebook.

@ericspod
Copy link
Member Author

I think this sed command sed 's/\(^\s*\)%/\1pass # %/' is misinterpreting % ( when it tries to remove line magics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant