Testing the Renderer's Backwards Compatibility - #7
Conversation
| @@ -0,0 +1,128 @@ | |||
| import csv | |||
There was a problem hiding this comment.
this file contains lots of repeated code from examples/pixel_renderer/create_sample_images.py
I think you could move all three files under tests/pixel_renderer/regression
then you can import, in the test_ file the relevant functions.
there should also be tests/pixel_renderer/regression/assets with all of the sample images (you should push the images to the repo)
| Taken from the SAMPLE_IMAGES_DIR environment variable. | ||
| If unset, all tests will be skipped. | ||
| """ | ||
| path = os.environ.get("SAMPLE_IMAGES_DIR") |
There was a problem hiding this comment.
once the files are in the same dir, you can Path(__file__).parent / "assets" or something, then there's no env variable
|
Thanks a lot for this, @ilkerkesen! Since we couldn't push the review changes to your fork, we carried this work over to #15 (with you credited as co-author) — it applies the review feedback: everything moved under |
This is related to #2, and it should fix the issue also as well. This PR implements backward compatibility tests for the renderer. There are 3 new files,
examples/pixel_renderer/samples.tsvcontains example sentences from SIB-200. This file includes 5 examples per language, covering all 200 langauges present in the SIB-200 benchmark.examples/pixel_renderer/create_sample_images.py: This script reads thesamples.tsv(via--input-fileoption) and produces sample rendered text images per language at the specified--output-dir, using the provided set of example sentences. So, instead of saving all images individually, this script groups examples by language, concatenates visually rendered sentences vertically, and produces one image file per language (e.g.eng_Latn.png). It copies thesamples.tsvfile into this directory, and additionally creates a JSON fileversions.jsonwhich contains the current versions of related packages (e.g.pango,pygobject).tests/pixel_renderer/test_backward_compatibility.py: This is the main test file. It takes the sample image directory path via the environment variableSAMPLE_IMAGES_DIR. I don't know whether there exists a more viable solution to pass command line arguments usingpytest.ruff checkdoes not create any warning/error for these new files. I used AI tools to implement tests where I reviewed the code accordingly in detail. I was not completely sure about where I should have putsamples.tsvandcreate_sample_images.pyfiles. We can also move these files to somewhere else. Also, if there is better way to pass the sample image dir value other than environment variable, let's follow that approach. Lastly, this PR is not ready for merge, because I need to write some documentation about it.