Skip to content

Commit

Permalink
[tex2pdf] add auto_detect parameter pass on to submit tarball, BREAK …
Browse files Browse the repository at this point in the history
…output filename
  • Loading branch information
norbusan committed Oct 4, 2024
1 parent fb48a6d commit dba1d01
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
27 changes: 23 additions & 4 deletions tex2pdf_service/tests/test_docker.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import json
import logging
import os
import shutil
import subprocess
import tempfile
import time
import requests
import subprocess
import urllib.parse

import pytest
import requests
from bin.compile_submissions import get_outcome_meta_and_files_info
import logging
import json
from tex2pdf.converter_driver import RemoteConverterDriver

PORT = 33031

Expand Down Expand Up @@ -176,3 +179,19 @@ def test_api_preflight(docker_container):
assert [f["filename"] for f in meta.get("detected_toplevel_files")] == ['fake-file-1.tex', 'fake-file-2.tex', 'fake-file-3.tex']


@pytest.mark.integration
def test_remote2023(docker_container) -> None:
tarball = os.path.join(os.getcwd(), "tests", "fixture", "tarballs", "test1", "test1.tar.gz")
out_dir = os.path.join(os.getcwd(), "tests", "test-output", "test1-remote")
url = docker_container + "/convert/"

logging.debug("Before instantiating the RemoteConverterDriver")

shutil.rmtree(out_dir, ignore_errors=True)

converter = RemoteConverterDriver(url, 600, out_dir, tarball,
use_addon_tree=False,
auto_detect=True)
logging.debug("Calling generate_pdf")
pdf = converter.generate_pdf()
assert pdf == "test1.pdf"
6 changes: 4 additions & 2 deletions tex2pdf_service/tex2pdf/converter_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,11 +571,13 @@ def generate_pdf(self) -> str|None:
self.t0 = time.perf_counter()

local_tarball = os.path.join(self.work_dir, self.source)
outcome_file = os.path.join(self.work_dir, f"outcome-{self.source}")
outcome_file = os.path.join(self.work_dir, "outcome.tar.gz")

# hard coded post_timeout = 600 as of now
# not sure I want to make this another init option
submit_tarball(self.service, local_tarball, outcome_file, int(self.max_time_budget), self.post_timeout)
logger.debug("Submitting %s to %s with output to %s", local_tarball, self.service, outcome_file)
submit_tarball(self.service, local_tarball, outcome_file, int(self.max_time_budget), self.post_timeout, self.auto_detect)
logger.debug("Returned from posting")
self.outcome = get_outcome_meta(outcome_file)

# TODO
Expand Down

0 comments on commit dba1d01

Please sign in to comment.