Skip to content

Refactor: LaTeX processing in external Docker container #38

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

Closed

Conversation

b0ink
Copy link

@b0ink b0ink commented Aug 11, 2024

Depends on thoth-tech/doubtfire-deploy#13
Feasibility document: thoth-tech/documentation#534

Description

This update moves LaTeX processing into a dedicated TeX Live container. Instead of running lualatex from the latex_config, the latex_run.sh script is executed after being copied into the working directory (along with other input files such as input.tex and jupynotex.py).

latex_run.sh then runs sudo docker exec ... into the TeX Live container and executes latex_build.sh, which is in charge of running the lualatex commands.

latex_run.sh relies on two environment variables to be set:

LATEX_CONTAINER_NAME=formatif-texlive-container # Name of the TeX Live container
LATEX_BUILD_PATH=/texlive/shell/latex_build.sh # Path on the TeX Live container

The render_to_string() method that renders the PDFs is now wrapped in a generate_pdf() method defined in latex_helper.rb, ensuring the environment variables are set before executing latex_run.sh via render_to_string.

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Use the modified docker-compose from Refactor: External TeX Live docker container doubtfire-deploy#13
  • If you encounter issues with the setup, remove any previous Docker devcontainer builds and volumes.
  • Run rake test in doubtfire-api to validate PDF generation.
  • Optionally, run rake db:simulate_signoff which will create several tasks and render them with lualatex.
  • You can also manually create a portfolio when logged in as a student, upload different test files, click "Create my portfolio", then run doubtfire-api/lib/shell/generate_pdfs.sh

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation if appropriate
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have created or extended unit tests to address my new additions
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

TODO:

  • Remove previous texlive-install.sh and texlive.profile scripts
  • Add TeX Live service to docker-compose in doubtfire-api

@b0ink b0ink changed the title Refactor: Latex processing in separate docker container Refactor: LaTeX processing in external Docker container Aug 20, 2024
@b0ink b0ink marked this pull request as ready for review August 20, 2024 05:19
@b0ink b0ink marked this pull request as draft August 21, 2024 02:49
@b0ink b0ink marked this pull request as ready for review August 21, 2024 04:01
@b0ink b0ink changed the base branch from development to 8.0.x August 28, 2024 12:59
@JackSCarroll
Copy link

This looks good and latex works as intended.
Old function calls have been replaced with new functions correctly.
I like that you've added the env var checks in latex_helper.rb.

@b0ink b0ink force-pushed the refactor/latex-docker-downsize-api branch from eddd49b to 2e0c0a5 Compare September 17, 2024 00:58
b0ink and others added 27 commits September 22, 2024 02:34
- use archive folder when unit archived
- move submission history to archive folder when unit archived
- move submission history on task abbr change
- move submission history on username change
- delete submission history on task delete
- action is too slow for use in sidekiq
- removed from scheduled actions
@b0ink b0ink closed this Apr 6, 2025
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.

3 participants