Comparing two runs¶
What it is for¶
A run is what read or ask wrote for a set of files: one record per
file. diff sets two runs beside each other and says, field by field, in
how many files they differ, with examples. It reads no PDF and asks no
model, so it takes seconds and can be repeated at will.
Runs |
What the comparison shows |
|---|---|
|
where a model reads a sheet otherwise than the program: places to look for reading errors |
|
what a change to the program does to a collection, before and after |
|
where two models, or two runs of one model, disagree |
Running it¶
sdb-reader read sheets/ --output read.jsonl --jobs 8
sdb-reader ask sheets/ --output answers.jsonl --jobs 4 --retries 3
sdb-reader diff read.jsonl answers.jsonl
The two runs are named A and B in the order given. Each is a file of
records as read or ask wrote it: JSON Lines from --output, or the JSON
list the command prints otherwise. Where a file of JSON Lines names a PDF
several times, the last line holds.
Option |
Effect |
|---|---|
|
two records are of the same file if their paths are the same; this is the default |
|
two records are of the same file if their file names are the same, for runs over copies in different places; a name that a run holds under several paths ends the command |
|
show up to N files per field; 3 unless you say otherwise |
|
print counts and examples as JSON instead of text |
|
write every differing file with all its differences and both values to FILE, as JSON Lines; an existing FILE is replaced |
|
count the files FILE names in a group of their own and show none of them, see below |
|
as for |
Files that only one run names are counted and not compared.
What is compared¶
Two runs of read are compared in every field of a reading. The fields are
named as in the output of read:
|
What is compared |
|---|---|
|
what the file is |
|
what section 2 says about the classification, whether the sheet calls itself voluntary and the product an article there, whether the product needs a sheet, the countries |
|
the signal word and the pictograms |
|
the codes of the H, P and EUH statements |
|
the texts of the statements |
|
dates, version and product name |
|
the supplier, the address of whoever answers for the sheet, and the emergency number |
|
the codes of the findings |
|
the fields in which the embedded file differs from the sheet as read |
|
why a file could not be read |
Where one of the runs is of ask, only what a model is asked for is
compared:
|
What is compared |
|---|---|
|
the codes of the H, P and EUH statements; a joined code such as P305+P351 counts as its parts |
|
the wording of a statement both name, with its |
|
the supplier’s name and e-mail; capitals and spaces do not count |
|
the date of revision; a model that names no date that counts does not differ from a reading, but from another model that names one |
A file for which one of the two records has nothing to compare, such as a file that is no sheet, counts as not comparable.
What comes back¶
A: read.jsonl (read), Dateien: 5000
B: answers.jsonl (ask), Dateien: 5000
Dateien in beiden: 5000; nur in A: 0; nur in B: 0; nicht vergleichbar: 700
Dateien mit Abweichung: 610; nur gezählt: 0
hazard_codes: dazugekommen 12, weggefallen 85, geändert 140
/data/sheets/reiniger.pdf
A: ["H315"]
B: ["H315", "H319"]
wording: dazugekommen 0, weggefallen 0, geändert 96
/data/sheets/lack.pdf [P102]
A: ["Darf nicht in die Hände von Kindern"]
B: ["Darf nicht in die Hände von Kindern gelangen."]
Value |
Meaning |
|---|---|
dazugekommen (gained) |
A has no value, B has one |
weggefallen (lost) |
A has a value, B has none |
geändert (changed) |
both have a value, and the two differ |
A file counts once per field, however many of its statements differ. In the
text a long value is cut after 220 characters; --json and --details
hold it whole. A line of --details:
{"file": "/data/sheets/reiniger.pdf", "differences": [{"field": "hazard_codes", "a": ["H315"], "b": ["H315", "H319"]}, {"field": "wording", "code": "P102", "a": ["Darf nicht in die Hände von Kindern"], "b": ["Darf nicht in die Hände von Kindern gelangen."]}]}
The program against a model¶
sdb-reader diff read.jsonl answers.jsonl --details differences.jsonl
Every difference is a place to look, in the PDF itself. Where the model is
right, the program has a reading error; where the program is right, nothing
follows. The answers are kept, so after a change to the program only read
runs again, and the same answers show whether the change did what it
should.
The program before and after a change¶
sdb-reader read sheets/ --output before.jsonl --jobs 8
sdb-reader read sheets/ --output after.jsonl --jobs 8
sdb-reader diff before.jsonl after.jsonl
The first run is made with the program as it was, the second with the changed one. Exit code 0 says the change altered no reading. Otherwise the counts show how far the change reaches: a rule meant for a few sheets that changes hundreds is too wide.
Files that are only counted¶
sdb-reader diff before.jsonl after.jsonl --count-only-from held-back.txt
A part of a collection that nobody is to look at while working on the
program can still be counted. --count-only-from FILE names those files,
one per line: a file name, an absolute path, or the end of a path such as
lieferant-a/reiniger.pdf. Empty lines and lines beginning with # do not
count. Such a file is counted in a group of its own for each field and is
in no example and no line of --details:
Dateien mit Abweichung: 41; nur gezählt: 5
revision_date: dazugekommen 38, weggefallen 0, geändert 3
revision_date, nur gezählt: dazugekommen 4, weggefallen 0, geändert 1
So the held-back files show whether a change holds on sheets it was not
made from, and nobody gets to see them. To keep them out of a run
altogether, read and ask have --exclude-from.
Warnings¶
The command compares what it is given and says on the error output when the two runs do not fit each other well:
Warning |
Meaning |
|---|---|
different reading stages |
the text of the PDFs was read by different versions; differences may come from the text, not from the reading |
different models |
two runs of |
not the same question |
two runs of |
A warning does not change the exit code.
Exit codes¶
Exit code |
Meaning |
|---|---|
0 |
no file differs in a compared field |
1 |
at least one file differs, shown or only counted |
2 |
a run cannot be read, mixes records of |
Files that only one run names do not change the exit code.