Merge nucleic/sleek-ember-seal-uady into dev
This commit is contained in:
+14
-1
@@ -65,6 +65,17 @@ def reviewed_population(args: argparse.Namespace) -> list[SourceRecord]:
|
||||
).records
|
||||
|
||||
|
||||
def review_policy_status(path: Path) -> str:
|
||||
try:
|
||||
value = json.loads(path.read_text(encoding="utf-8"))
|
||||
status = value["humanLabelAndDifficultyReview"]["status"]
|
||||
except (OSError, UnicodeError, json.JSONDecodeError, KeyError, TypeError) as exc:
|
||||
raise DataError(f"{path}: cannot read human-review policy: {exc}") from exc
|
||||
if not isinstance(status, str) or not status:
|
||||
raise DataError(f"{path}: invalid human-review policy status")
|
||||
return status
|
||||
|
||||
|
||||
def build_parser() -> argparse.ArgumentParser:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--source", action="append", type=Path)
|
||||
@@ -98,6 +109,7 @@ def main(argv: Sequence[str] | None = None) -> int:
|
||||
args = build_parser().parse_args(argv)
|
||||
try:
|
||||
population = reviewed_population(args)
|
||||
policy_status = review_policy_status(args.curation_review.resolve())
|
||||
sample = stratified_review_sample(
|
||||
population,
|
||||
fraction=args.review_fraction,
|
||||
@@ -152,7 +164,8 @@ def main(argv: Sequence[str] | None = None) -> int:
|
||||
print(
|
||||
f"Human review: {progress.completed}/{progress.records} complete "
|
||||
f"({progress.accepted} accept, {progress.relabeled} relabel, "
|
||||
f"{progress.rejected} reject, {progress.incomplete} remaining)."
|
||||
f"{progress.rejected} reject, {progress.incomplete} remaining). "
|
||||
f"Dataset policy: {policy_status}."
|
||||
)
|
||||
return 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user