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

Check syntax of each solution #21

Merged
merged 3 commits into from
Nov 27, 2024
Merged

Conversation

Krishn1412
Copy link
Contributor

@Krishn1412 Krishn1412 commented Nov 17, 2024

Solves #20

src/gpt_resolve/pdf_generator.py Outdated Show resolved Hide resolved
@lgabs
Copy link
Owner

lgabs commented Nov 18, 2024

Also, do you mind writing some unit tests? Currently the generate_solutions_pdf function has only a test for empty dir and another for a latex string which is correct. With you implementation, we could test for incorrect latex string examples.

@Krishn1412
Copy link
Contributor Author

I have made some some changes based on your comments. Can you take a look again? I'll work on the unit tests.

Comment on lines 98 to 101
if not validate_latex_content(content):
print(f"Error: Solution '{sol_file.name}' has LaTeX syntax errors. Please fix it.")
sol_files_with_issues.append(sol_file)
continue
Copy link
Owner

@lgabs lgabs Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! The only thing left here is that any errors will count in sol_files_with_issues and loop will continue, but in the end the code will try to compile the whole pdf again, generating the same error that currently happens (for many questions, the traceback will be big).

So if you print errors only outside the loop in case of sol_files_with_issues not empty, it'd be solved:

for sol_file in solution_files:
    ...
    if not validate_latex_content(content):
        sol_files_with_issues.append(sol_file)
        continue

if sol_files_with_issues:
    raise ValueError("Errors in one or more solutions:\n' + '\n'.join(sol_files_with_issues) + '\n\nPlease check for syntax errors.")
    
...

@lgabs
Copy link
Owner

lgabs commented Nov 25, 2024

@Krishn1412 do you have any updates here?

@Krishn1412
Copy link
Contributor Author

Sorry about the delay @lgabs, I had some place to be. Can you take a look now?

@lgabs
Copy link
Owner

lgabs commented Nov 26, 2024

No problem @Krishn1412 , thanks a lot! Looks great now for merging. Do you have the time to add some unit test for invalid case? If so, I'll wait for your updates; if not, I'll create another issue to add this unit test afterwards.

@Krishn1412
Copy link
Contributor Author

Sure @lgabs I'll add some unit tests. Do you want me to add them in the same PR or create a new one?

@lgabs
Copy link
Owner

lgabs commented Nov 27, 2024

You can do it in different PR, no problem.

@lgabs lgabs merged commit 37c03a3 into lgabs:main Nov 27, 2024
3 checks passed
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

Successfully merging this pull request may close these issues.

2 participants