Dear Community,
I am maintaining a rather large parametrisable Typst Document, that originally came from a LaTeX base, which was a pain in the ass, as LaTeX does not seem to be meant for something like this.
We have moved our workflow over to Typst this year and using it is big fun now.
Now, as a compile run in Typst does not take a minute, as in LaTeX, I had the idea to realize a tester script in Python.
Main Specs:
- Builds a grid of parameter combinatoric sets using itertools
- Filters forbidden sets
- Runs all parameter sets (partly in parallel) using concurrent futures
- uses Typst CLI call
- parameter injection using
--inputand a special parameter file - compiled result (pdf) is not checked for content, but erased after the run
- Compile result (CLI Error returncode) is checked
if it is equal 0 (success):- discard the result, count as success
if it is unequal 0 (error): - record the returncode, stdout and stderr texts and the injected parameter set for later analysis and bugfixing
- discard the result, count as success
- run a bit of statistics over the tests
- After the test finshed or a test is aborted, store the statistics and all the recorded failed test runs with their configuration set to a log file (JSON format)
I run this test every time before a release of the template document and I have already found a lot of failures in certain sets or just some configurations of the document I were not writing code in.
However, you might quickly realise that the amount of sets is quickly increasing with the number of parameters (there are ~30 of them). In the beginning, I had millions of sets to test and this would have taken months. I have now split the test runs into two separate runs with ~30k to 50k runs in order to reduce the compile count and therefore time. Now, it takes a couple of hours (can run over night), paid by the fact that not all possible combinations are tested, but I can live with that.
I wonder if there is a better solution to do this same thing?
Does anyone have a good idea or is this already as good as it can become?
I thought about if using the watch infrastructure of the CLI compiler could offer any advantage in speed?
This way, I could not inject my parameters using --input right? I would need to edit my .typ file programmatically wait for the compile run / error code and text (is there any with watch?) and then run the next set.