Work directory¶
All state lives in the work directory (default ./review_work), which
preprocess creates.
review_work/
manifest.tsv # Master list of images
skipped.tsv # Inputs that produced no image
notes.tsv # Notable things written inputs hold
preprocess.json # How it was made
review.tsv # Verdicts (created later during review)
review.lock # Present while review or serve has it open
batch_001/
img_00001.jpg # Individual preprocessed images
img_00002.jpg
...
batch_002/
...
File |
Format |
Description |
|---|---|---|
TSV |
Master image list, written by |
|
TSV |
Inputs that produced no image, written by |
|
TSV |
What rendered inputs hold that downstream tools should know about or strip, written by |
|
JSON |
How the work directory was made |
|
TSV |
Review decisions, appended by |
|
JSON |
Present while a writer ( |
|
|
JPG |
Preprocessed individual images, numbered in order within each batch |
The TSV files are tab-separated UTF-8 with \r\n line endings, and
review.tsv also accepts \n. Every file except the JPGs holds source
paths, which may carry patient identifiers: treat them as PHI (see
Local disk). How the tool reads and writes
them internally is in the specification’s
Data Files.
manifest.tsv¶
One row per image, in the order the inputs were found.
Column |
Description |
|---|---|
|
Batch subdirectory name (e.g. |
|
Path of the JPG within the work directory; unique |
|
The image’s source (see below) |
|
SHA-256 (64 lowercase hex characters) of the source file’s bytes, or of the ZIP entry’s bytes. One per source (in a work directory made by an older version, a DICOM and its |
|
SHA-256 (64 lowercase hex characters) of the JPG as written |
An image_id is an absolute path:
a file named as a SOURCE: its fully-resolved path, so a symlink named on the command line is recorded under its target’s path;
a file found inside a directory: the resolved directory SOURCE’s path plus the names below it, so a symlinked file there keeps its link path;
a ZIP entry:
<zip path>::<entry name>; when several entries share a name, the later ones get#2,#3, …;a DICOM’s embedded icon image:
<path>#icon, a second row beside the main image, only in a work directory made by an older version (preprocess no longer renders icons);a name that is not UTF-8 or holds a control character or line separator never reaches the manifest: it is a
failedrow inskipped.tsv, under an escaped name.
The same image_id can appear on more than one row when one file was reached
through overlapping SOURCES; one verdict covers all of them. Such rows have
the same source_sha256.
Work directories from older versions have only the first three columns
(batch, preprocessed_path, image_id). They still load; their images are
not hash-checked.
Strict parsing. review, status, serve and export read the file
when they open the work directory, and stop (exit 1) with
Cannot read work directory: <file>:<line>: <problem>
if the header is not exactly one of the two above, a row has a missing or
empty field, a hash is not 64 lowercase hex characters, or a
preprocessed_path repeats, or one image_id has two different
source_sha256 values (the error names the later line and the first). A file that is not valid UTF-8 is named with a
byte offset instead of a line (<file>: not valid UTF-8 at byte N), and a
field longer than 131072 characters (csv’s field limit) is a parse error at its
line (field larger than field limit). The tool never repairs the file: fix or
remove the line it names.
Hash check. Each JPG is checked against its jpeg_sha256 whenever it is
loaded. A JPG changed or cut short after preprocessing is shown as an
unloadable placeholder, which can only be marked DIRTY, never as an image
that could be marked CLEAN.
skipped.tsv¶
One row per input that produced no image. It is always written, with only
its header when nothing was skipped. Every input ends up in exactly one of
manifest.tsv or skipped.tsv.
Column |
Description |
|---|---|
|
The input, in the same form as in |
|
|
|
|
What each kind covers, with example reasons, is in
Skipped inputs. status counts
the rows and export reports them. Both read the file strictly and stop with
an error naming the file and line if it is malformed, including a field
longer than 131072 characters. status and serve treat an absent file as no
skipped inputs, but export refuses a work directory without it, unless the
manifest has rows and no hash columns (an older version); see
Refusals.
notes.tsv¶
One row per note on an input that was written to manifest.tsv: something
the input holds that downstream tools should know about or strip, whether or
not its image shows it. It is always written, with only its header when there are
no notes. Rows follow manifest.tsv order; an input with several notes has
one row each. A failed or ignored input, including one whose image_id
collides, has no notes.
Column |
Description |
|---|---|
|
The input, as in |
|
|
|
One line describing it, e.g. |
It is encoded like skipped.tsv, and the detail is cleaned like a skipped
reason (no tabs, newlines or other control characters). What each kind means,
with example details, is in
Input notes. It holds source paths,
so it is as sensitive as manifest.tsv. Only export reads it, to deny
files holding content their review image does not show (see What is
allowlisted); it refuses a
malformed notes.tsv, naming the file and line, and a missing one under the
same rule as skipped.tsv (so work directories made before 0.4.0, which have
none, cannot be exported). The server never sends it.
preprocess.json¶
One JSON object recording how the work directory was made:
Key |
Description |
|---|---|
|
The image-review version ( |
|
UTC time the run finished, ISO 8601 ( |
|
The SOURCES as resolved absolute paths, in the order given, escaped like an |
|
|
|
Versions of |
|
|
It holds source paths, so it is as sensitive as manifest.tsv. The tool
never reads it back, and the server never sends it.
review.tsv¶
Every verdict is appended to review.tsv, with who gave it and how. The file
is created by the first verdict.
Column |
Description |
|---|---|
|
As in |
|
Batch the image belongs to |
|
|
|
Pass (an integer from 1 to 1000000) in which the verdict was given; in an undo row, the restored verdict’s pass, or for a tombstone the undone mark’s pass |
|
ISO 8601 UTC time |
|
Who gave the verdict: the name from the browser page’s name box (rows from earlier versions may hold the name given to the old |
|
|
|
How many images the one keypress covered (1 in single mode); in an undo row, how many images the undo covered |
|
The image-review version that wrote the row ( |
|
The source file’s SHA-256, as |
reviewer, mode, grid_size, tool_version and source_sha256 are empty
in rows carried over from an older file (see
Upgrading an older file). An upgrade never fills in
source_sha256 from the current manifest: the file at that path may have
changed since the verdict was given.
Verdicts on changed content. A row whose source_sha256 is not empty and
differs from the one manifest.tsv records now for its image_id is a
verdict on other content: the file at that path was replaced and preprocessed
again, or review.tsv was copied into a work directory rebuilt from different
files. Such a row counts as no verdict: the image is UNREVIEWED in review,
serve and status (and keeps the pass at 1 until it is marked again), and
export reports it UNREVIEWED with the reason verdict recorded for different content (the file changed since it was reviewed). The row stays in
the file, and an undo can restore it. A row with an empty source_sha256
(from before this column, or carried over by an upgrade) cannot be checked and
is trusted by image_id alone, as is any row when the manifest has no hashes:
those verdicts are not protected against a replaced file.
Last row wins. The file is an append-only log: every rating action
appends a line per image and syncs it to disk, and when an image appears more
than once its last line wins. Only images that have been marked appear; an
image with no row, or whose last row is an undo’s UNREVIEWED, is
UNREVIEWED. FLAGGED (marked DIRTY in an earlier pass; see
Passes) is worked out when the file is read and is
never written.
Strict parsing. A malformed file stops the tool with the same
Cannot read work directory: <file>:<line>: <problem> message as
manifest.tsv, instead of being skipped or rewritten, so a hand edit cannot
silently lose decisions (a file that is not UTF-8 is named with a byte
offset instead of a line). The header must be exactly these ten columns (or
an older header: the first nine, or the first five), and every row has as many
fields as its header, with:
a non-empty
image_id;a
statusofCLEANorDIRTY, orUNREVIEWEDwithmodeundo;a
pass_numberfrom 1 to 1000000;a
modeofsingle,grid,undoor empty;a
grid_sizethat is empty or at least 1;a
source_sha256that is empty or exactly 64 lowercase hex characters.
The other columns are free text and may be empty.
A line cut short by a crash. It is safe to kill the process at any time.
An empty file holds no decisions. A last line cut short by a crash is skipped
with a warning and dropped on the next rating, unless all of its fields made
it to disk. In a current file that means its whole source_sha256: a last
line with no line ending whose hash is empty or incomplete counts as cut
short, so a verdict never loses its hash to a crash. In an older file (nine or
five columns, before its upgrade), such a line is kept, and its last field
(tool_version in a nine-column file, timestamp in a five-column one) may
be cut short or empty. A crash
in the middle of a grid mark can record only some of its images, cut at a line
ending; the rows that landed are kept and loading logs a warning when the last
mark has fewer rows than its grid_size. export refuses only until the next
verdict is recorded, so re-check that grid first. A bad line
anywhere else is still an error. A last line with no line ending that holds a
field longer than 131072 characters (for example the zero-filled tail some
file systems leave after a crash) counts as cut short; the same field on a
complete line is a parse error. export refuses a file whose last line or last mark was
cut short; see Refusals.
Undo rows¶
An undo (z) appends one row for each image of the mark it undoes, with
mode undo, the time of the undo and the undoing reviewer. Where the image
had a verdict before that mark, the row restores that verdict’s batch,
status, pass_number and source_sha256 exactly, so the pass can go down.
That includes a verdict given on other content (see Verdicts on changed
content above): undoing a mark over it restores that row, not a tombstone,
so the image reads UNREVIEWED again. Where it had none, the row is a
tombstone: status UNREVIEWED, keeping the undone row’s batch,
pass_number and source_sha256, which makes the image read as never
reviewed until it is marked again.
Upgrading an older file¶
Upgrade everyone sharing a work directory together. A review.tsv from
an older version has only the first nine columns (0.3.0 and 0.4.0) or the
first five (earlier versions). It is upgraded in place the first time review
or serve opens it, with the new columns left empty for its existing rows.
status and export read it as is, without upgrading it.
Older image-review versions cannot read the upgraded file: 0.4.0 and earlier refuse a ten-column
review.tsv.Versions before wire API v5 (before undo) reject a
review.tsvthat holds undo rows, so upgrade everyone sharing a work directory before anyone pressesz.
If the upgrade is interrupted, a .review.tsv.*.tmp file may be left in the
work directory; see Leftover temporary files.
review.lock¶
Only one writer (review or serve) can use a work directory at a time. It
holds review.lock while the work directory is open and removes it when it
exits. status takes no lock and always works. export takes none either,
but refuses while a writer holds the lock unless given --allow-live.
The lock is a JSON object naming the holder: host, boot_id (the
machine’s boot id, "" where unavailable), user, pid and started (UTC,
ISO 8601). It has the work directory’s file mode, so teammates in a group
work directory can read who holds it.
A second writer exits 1 with:
work directory is in use by USER on HOST (pid PID) since STARTED; lock file PATH. If that process is gone, delete PATH by hand
A lock file that cannot be read or is malformed counts as held, and the message names it with the same advice.
Reclaiming. A lock is cleared automatically only when the tool can verify
that its process is gone: same host name, same machine boot, and no process
with that pid. A lock left on another node (for example by a serve job that
was killed), one from before a reboot, or one whose process id has since been
reused is not cleared. Nor is a lock without a boot id: one written on a
system that has none (such as macOS, which has no
/proc/sys/kernel/random/boot_id) or by an older version.
Deleting it by hand. Delete review.lock only when you are sure its
process is gone: check squeue, or ps -p PID on that node, and compare the
start time.
Browser review over SSH
shows the command.
If it was still running and a second writer starts, each checks before
every verdict that review.tsv is exactly the file it last read or wrote,
and refuses the verdict if not. So once one writer has recorded a verdict,
the other’s next one is refused (a verdict recorded at the same moment can
still land, but then both writers refuse their next). What each command
does then is in
Another writer on the work directory;
review serves the same page and behaves the same way.
Leftover temporary files¶
Each of these is normally removed when the command exits, but an abrupt kill
(e.g. kill -9, a node crash) can leave it behind. They hold the same data
as the files they stand in for, source paths included, so delete any you
find. Apart from .NAME.partial, the tool ignores them:
.NAME.partial, next to the work directory:preprocess’s staging directory. The next run into that work directory refuses and names it..review.tsv.*.tmp, inside the work directory: an interrupted upgrade ofreview.tsv.review.lock.<host>.<boot id>.<pid>.<random>, inside the work directory: a writer killed while taking the lock. The next writer on the same machine removes those whose process is gone, unless the machine has no boot id; others are safe to delete by hand..FILE.<random>.tmp, beside anexport --outputor--reportfile: an interrupted export.