Closes #536
This commit is contained in:
@@ -112,6 +112,7 @@ COUNTED = (
|
||||
# The ladder steps whose answer is certain enough to keep a link.
|
||||
KEEP_SOURCES = ("recorded-run", "inspector")
|
||||
# What must be unchanged since the dry run for a row to be written.
|
||||
MANUAL_REASON = "linked by hand in Needs review"
|
||||
DRIFT_KEYS = (
|
||||
"action",
|
||||
"file",
|
||||
@@ -181,6 +182,13 @@ class Judge:
|
||||
)
|
||||
return self.decisions[path]
|
||||
|
||||
def _manually_linked(self, image_id):
|
||||
"""True when the reviewer named this row's prompt in Needs review (#536)."""
|
||||
return any(
|
||||
link["provenance"].get("kind") == "manual-link"
|
||||
for link in self.db.get_image_prompt_pairs(image_id)
|
||||
)
|
||||
|
||||
def row(self, row):
|
||||
"""The plan entry of one ``generated_images`` row."""
|
||||
conn = self.db.model.get_connection()
|
||||
@@ -200,6 +208,8 @@ class Judge:
|
||||
except OSError:
|
||||
return {**item, "action": "skip", "reason": "file gone"}
|
||||
item.update(file_size=stat.st_size, file_mtime_ns=stat.st_mtime_ns)
|
||||
if self._manually_linked(row["id"]):
|
||||
return {**item, "action": "skip", "reason": MANUAL_REASON}
|
||||
decision = self.decide(path, stat.st_size)
|
||||
action = action_of(decision, prompt_hash)
|
||||
if action == "skip":
|
||||
|
||||
@@ -142,6 +142,14 @@ def certain_prompts(db, handler, path, metadata, output_dir):
|
||||
return found
|
||||
|
||||
|
||||
def _manually_linked(db, image_id):
|
||||
"""True when a link of this image records a reviewer's manual choice."""
|
||||
return any(
|
||||
link["provenance"].get("kind") == "manual-link"
|
||||
for link in db.get_image_prompt_pairs(image_id)
|
||||
)
|
||||
|
||||
|
||||
def judge(db, handler, row, output_dir):
|
||||
"""One image's verdict dict."""
|
||||
path = row["image_path"]
|
||||
@@ -152,6 +160,9 @@ def judge(db, handler, row, output_dir):
|
||||
"sources": {},
|
||||
"target": None,
|
||||
}
|
||||
if _manually_linked(db, row["id"]):
|
||||
# The reviewer named this prompt in Needs review (#536): not ours to undo.
|
||||
return {**verdict, "verdict": "manual", "target": row["prompt_id"]}
|
||||
if not os.path.isfile(path):
|
||||
return {**verdict, "verdict": "missing"}
|
||||
try:
|
||||
|
||||
+30
-24
@@ -43,14 +43,14 @@
|
||||
},
|
||||
"gallery-settings.js": {
|
||||
"lines": 98,
|
||||
"branches": 94,
|
||||
"branches": 95,
|
||||
"functions": 98,
|
||||
"statements": 98
|
||||
},
|
||||
"gallery.js": {
|
||||
"lines": 54,
|
||||
"branches": 72,
|
||||
"functions": 57,
|
||||
"functions": 58,
|
||||
"statements": 54
|
||||
},
|
||||
"html-escape.js": {
|
||||
@@ -216,10 +216,10 @@
|
||||
"statements": 98
|
||||
},
|
||||
"workspace/file-inspector.mjs": {
|
||||
"lines": 96,
|
||||
"lines": 97,
|
||||
"branches": 93,
|
||||
"functions": 93,
|
||||
"statements": 96
|
||||
"statements": 97
|
||||
},
|
||||
"workspace/heading.mjs": {
|
||||
"lines": 98,
|
||||
@@ -288,16 +288,10 @@
|
||||
"statements": 98
|
||||
},
|
||||
"workspace/images-delete.mjs": {
|
||||
"lines": 80,
|
||||
"branches": 70,
|
||||
"functions": 80,
|
||||
"statements": 80
|
||||
},
|
||||
"workspace/images-return.mjs": {
|
||||
"lines": 80,
|
||||
"branches": 70,
|
||||
"functions": 80,
|
||||
"statements": 80
|
||||
"lines": 95,
|
||||
"branches": 81,
|
||||
"functions": 92,
|
||||
"statements": 95
|
||||
},
|
||||
"workspace/images-export.mjs": {
|
||||
"lines": 98,
|
||||
@@ -317,6 +311,12 @@
|
||||
"functions": 98,
|
||||
"statements": 98
|
||||
},
|
||||
"workspace/images-return.mjs": {
|
||||
"lines": 93,
|
||||
"branches": 86,
|
||||
"functions": 98,
|
||||
"statements": 93
|
||||
},
|
||||
"workspace/images-selection.mjs": {
|
||||
"lines": 98,
|
||||
"branches": 93,
|
||||
@@ -355,7 +355,7 @@
|
||||
},
|
||||
"workspace/images.mjs": {
|
||||
"lines": 97,
|
||||
"branches": 89,
|
||||
"branches": 90,
|
||||
"functions": 98,
|
||||
"statements": 97
|
||||
},
|
||||
@@ -368,7 +368,7 @@
|
||||
"workspace/inspect.mjs": {
|
||||
"lines": 98,
|
||||
"branches": 92,
|
||||
"functions": 93,
|
||||
"functions": 94,
|
||||
"statements": 98
|
||||
},
|
||||
"workspace/inspection-state.mjs": {
|
||||
@@ -379,7 +379,7 @@
|
||||
},
|
||||
"workspace/inspector-collections.mjs": {
|
||||
"lines": 98,
|
||||
"branches": 92,
|
||||
"branches": 93,
|
||||
"functions": 98,
|
||||
"statements": 98
|
||||
},
|
||||
@@ -397,7 +397,7 @@
|
||||
},
|
||||
"workspace/library-editor.mjs": {
|
||||
"lines": 98,
|
||||
"branches": 93,
|
||||
"branches": 94,
|
||||
"functions": 92,
|
||||
"statements": 98
|
||||
},
|
||||
@@ -504,10 +504,10 @@
|
||||
"statements": 98
|
||||
},
|
||||
"workspace/more-menu.mjs": {
|
||||
"lines": 80,
|
||||
"branches": 70,
|
||||
"functions": 80,
|
||||
"statements": 80
|
||||
"lines": 98,
|
||||
"branches": 86,
|
||||
"functions": 98,
|
||||
"statements": 98
|
||||
},
|
||||
"workspace/plural.mjs": {
|
||||
"lines": 98,
|
||||
@@ -551,9 +551,15 @@
|
||||
"functions": 80,
|
||||
"statements": 95
|
||||
},
|
||||
"workspace/review-link.mjs": {
|
||||
"lines": 95,
|
||||
"branches": 70,
|
||||
"functions": 91,
|
||||
"statements": 95
|
||||
},
|
||||
"workspace/review-state.mjs": {
|
||||
"lines": 96,
|
||||
"branches": 84,
|
||||
"branches": 85,
|
||||
"functions": 98,
|
||||
"statements": 96
|
||||
},
|
||||
@@ -619,7 +625,7 @@
|
||||
},
|
||||
"workspace/system-sources.mjs": {
|
||||
"lines": 98,
|
||||
"branches": 88,
|
||||
"branches": 89,
|
||||
"functions": 95,
|
||||
"statements": 98
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user