forked from ploomber/sklearn-evaluation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
override_failed_result_images.py
44 lines (29 loc) · 1022 Bytes
/
override_failed_result_images.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""
Override failed result images so they become the new reference,
this happens sometimes when we make changes, we have to check manually
if differences are acceptable, then run this script
"""
from pathlib import Path
from glob import glob
import shutil
failed = glob("result_images/*/*-failed-diff*.png")
print("Found failed images...")
for f in failed:
print("* ", f)
print("Getting reference images to replace...")
def get_ref_image(path):
path = Path(path)
return path.with_name(path.name.replace("-failed-diff", ""))
ref = [get_ref_image(f) for f in failed]
for f in ref:
print("* ", f)
def get_new_location(path):
path = Path(path)
# get rid of the first part "result_images", and add the new relative
# location inside tests/baseline_images
return Path("tests", "baseline_images", *path.parts[1:])
new_location = [get_new_location(f) for f in ref]
print("Copying...")
for old, new in zip(ref, new_location):
print(f"* {old} -> {new}")
shutil.copy(old, new)