Describe the issue
When running python -m pytest cirq-core/ some tests in cirq.contrib failed when LaTeX dependencies are missing or partially installed, instead of being skipped. The error is (when grep with error/warning string the outputs):
ubuntu@fuzzer-03:~/git/try/H-Fuzz$ ./Cirq/script.sh
cirq-core/cirq/contrib/quantikz/circuit_to_latex_render_test.py:41: AssertionError
!!! pdflatex failed on run 1 (exit code 1) !!!
! LaTeX Error: File `standalone.cls' not found.
! ==> Fatal error occurred, no output PDF file produced!
os_error = None
except (OSError, IOError) as e:
# Use FileNotFoundError when python 2 is dropped
os_error = e
if os_error.errno == errno.ENOENT:
except subprocess.CalledProcessError as e:
# For all other errors print the output and raise the error
except (OSError, IOError, subprocess.CalledProcessError):
except (OSError, IOError) as e:
# Use FileNotFoundError when python 2 is dropped
CompilerError(
E pylatex.errors.CompilerError: No LaTex compiler was found
.venv/lib/python3.11/site-packages/pylatex/document.py:325: CompilerError
=============================== warnings summary ===============================
cirq-core/cirq/experiments/z_phase_calibration_test.py::test_calibrate_z_phases_workflow_no_options[angles1-error1]
cirq-core/cirq/experiments/z_phase_calibration_test.py::test_calibrate_z_phases_workflow_no_options[angles2-error2]
warnings.warn(
warnings.warn(f"Op {op} no qubits.")
warnings.warn(
cirq-core/cirq/experiments/single_qubit_readout_calibration_test.py::test_estimate_parallel_readout_errors_no_noise
cirq-core/cirq/experiments/single_qubit_readout_calibration_test.py::test_estimate_parallel_readout_errors_no_noise
warnings.warn("Optimal parameters could not be found for curve fit", RuntimeWarning)
cirq-core/cirq/experiments/t1_decay_experiment_test.py::test_plot_does_not_raise_error
cirq-core/cirq/experiments/t1_decay_experiment_test.py::test_plot_does_not_raise_error
cirq-core/cirq/work/observable_measurement_data_test.py::test_bitstring_accumulator_errors
cirq-core/cirq/work/observable_measurement_data_test.py::test_bitstring_accumulator_errors
warnings.warn(
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
FAILED cirq-core/cirq/contrib/quantikz/circuit_to_latex_render_test.py::test_render_circuit
FAILED cirq-core/cirq/contrib/qcircuit/qcircuit_pdf_test.py::test_qcircuit_pdf
= 2 failed, 20025 passed, 10 skipped, 64 xfailed, 21 warnings in 285.91s (0:04:45) =
Then, after trying to install LaTeX/TeX packages, it works a little bit better (but I assume it was not the full right installation):
cirq-core/cirq/contrib/quantikz/circuit_to_latex_render_test.py:42: AssertionError
stdout = b'Latexmk: This is Latexmk, John Collins, 26 Dec. 2019, version: 4.67.\nRule \'latex\': The following rules & subrules... or warnings treated as errors.\n=== TeX engine is \'pdfTeX\'\nLatexmk: Errors, so I did not complete making targets\n'
CalledProcessError. The CalledProcessError object will have the return code
triggered by setting any of text, encoding, errors or universal_newlines.
raise ValueError('stdin and input arguments may not both be used.')
raise ValueError('stdout and stderr arguments may not be used '
> raise CalledProcessError(retcode, process.args,
E subprocess.CalledProcessError: Command '['latexmk', '-pdfps', '--interaction=nonstopmode', '/tmp/pytest-of-ubuntu/pytest-38/test_qcircuit_pdf0/test_file.tex']' returned non-zero exit status 12.
/usr/lib/python3.11/subprocess.py:571: CalledProcessError
! LaTeX Error: Missing \begin{document}.
! LaTeX Error: Missing \begin{document}.
! LaTeX Error: Missing \begin{document}.
! LaTeX Error: Missing \begin{document}.
! LaTeX Error: Missing \begin{document}.
! LaTeX Error: Missing \begin{document}.
! LaTeX Error: Missing \begin{document}.
! LaTeX Error: Missing \begin{document}.
! LaTeX Error: Missing \begin{document}.
! LaTeX Error: Missing \begin{document}.
! LaTeX Error: Missing \begin{document}.
! LaTeX Error: Missing \begin{document}.
! LaTeX Error: Missing \begin{document}.
! LaTeX Error: Missing \begin{document}.
! LaTeX Error: Missing \begin{document}.
! LaTeX Error: Missing \begin{document}.
! LaTeX Error: Missing \begin{document}.
! LaTeX Error: Missing \begin{document}.
! LaTeX Error: Missing \begin{document}.
! LaTeX Error: Missing \begin{document}.
! LaTeX Error: Missing \begin{document}.
! LaTeX Error: Missing \begin{document}.
Collected error summary (may duplicate other messages):
unless error was exceeding maximum runs, or warnings treated as errors.
Latexmk: Errors, so I did not complete making targets
...
FAILED cirq-core/cirq/contrib/quantikz/circuit_to_latex_render_test.py::test_render_circuit
FAILED cirq-core/cirq/contrib/qcircuit/qcircuit_pdf_test.py::test_qcircuit_pdf
= 2 failed, 20025 passed, 10 skipped, 64 xfailed, 21 warnings in 289.77s (0:04:49) =
Some documentation in some deep subfolder helps to resolve it, but it takes some effort to find it:
cirq-core/cirq/contrib/quantikz/circuit_to_latex_render.py: "On Ubuntu/Debian: `sudo apt-get install texlive-full` "
However, it will be a good idea to add it in the main README.
Expected Result:
Not to crash if there are missing install, either suggest exactly how to install the missing packages or add a skip:
[Suggested Fix] Nonetheless, the best practice is likely to skip when one of the LaTeX/TeX dependencies is missing, adding something like this:
pytest.mark.skipif(shutil.which("pdflatex") is None, ...)
Tell us the version of Cirq where this happens
I use Cirq from source version: commit 9888067c5c36b4505917de57f0528c53882ec240
Python: Python 3.11.11
You can get the Cirq version you are running by using Python
to print the value of cirq.__version__. From the command line:
python -c 'import cirq; print(cirq.__version__)'
This prints:
(.venv) ubuntu@fuzzer-03:~/Cirq$ python -c 'import cirq; print(cirq.__version__)'
1.6.1
Reproducing the error:
I used this script:
ubuntu@fuzzer-03:~/git/try/H-Fuzz$ cat Cirq/script.sh
#!/bin/bash
cd ~/Cirq
source .venv/bin/activate
which pdflatex
python -m pytest cirq-core/ | grep -e"Crash" -e"Failed" -e"FAILED" -e"failed" -e"error" -e"crash" -e"warnings" -e"Warnings" -e"Error" -e"ERROR"
initially, without the installation of LaTeX/TeX, and then trying to install it using the hints I have found in the documentation of Cirq.
Describe the issue
When running
python -m pytest cirq-core/some tests in cirq.contrib failed when LaTeX dependencies are missing or partially installed, instead of being skipped. The error is (when grep with error/warning string the outputs):Then, after trying to install LaTeX/TeX packages, it works a little bit better (but I assume it was not the full right installation):
Some documentation in some deep subfolder helps to resolve it, but it takes some effort to find it:
However, it will be a good idea to add it in the main README.
Expected Result:
Not to crash if there are missing install, either suggest exactly how to install the missing packages or add a skip:
[Suggested Fix] Nonetheless, the best practice is likely to skip when one of the LaTeX/TeX dependencies is missing, adding something like this:
Tell us the version of Cirq where this happens
I use Cirq from source version:
commit 9888067c5c36b4505917de57f0528c53882ec240Python: Python 3.11.11
You can get the Cirq version you are running by using Python
to print the value of
cirq.__version__. From the command line:python -c 'import cirq; print(cirq.__version__)'This prints:
Reproducing the error:
I used this script:
initially, without the installation of LaTeX/TeX, and then trying to install it using the hints I have found in the documentation of Cirq.