One useful idea
Debugging is a controlled investigation, not a sequence of random edits. State the failing input and expected contract, write three falsifiable hypotheses, then choose observations that can disprove two. For the supplied all-missing example, consider response schema, rating type and an empty denominator. Reduce to one unreviewed job and inspect the traceback’s closest frame you own before changing the calculation.
Everything here is synchronous: one job passes through fetch, validate, review and summary before the next observation. Async is taught later in Module 11; it is not a prerequisite or a repair for this bug. The deliberately broken mean divides an empty supplied-rating list by zero. Converting None to zero would hide the crash but invent evidence, so it is not an acceptable repair.
Review input is an exact mapping of requested IDs to None or exact integers 1..5. A foreign key or nonmapping input refuses the request before provider calls. Missing stays None. Bool is refused even though True == 1. The summary counts input/reviewed/unreviewed jobs using integers and averages only supplied authored values; no supplied ratings means no mean. A private Decimal context uses precision 28 and two-place ROUND_HALF_UP independently of the caller’s current settings.
Controlled events contain event, stage and job_id. A fetch fault is wrapped as PipelineFailure from the original cause; a schema or rating ValueError identifies validate or review. The final failure event names that stage. Successful completion ends with completed/summary/batch. Do not broadly catch failures and return a success-shaped zero. Logger failures themselves propagate. Contextual wrapping preserves useful evidence instead of swallowing it.
Controlled events exclude raw exception text, private prompts and authored review data, but a full chained traceback may still contain original provider text. Inspect invented fixture tracebacks locally and redact real data before sharing. Findings_present means supplied ratings exist, not authenticated review, a winner or verified creative quality. Complete the three-hypothesis investigation and changed-input defense; a supplied worked diagnosis is not your independent investigation.
Refresh first: Provider schema and failure boundaries, Machine metadata versus authored findings, Expected errors and narrow catches.
Trace a finished example
from quality_tools.core import PipelineFailure, review_pipeline
class FakeProvider:
def get_job(self, job_id):
return {"id": job_id, "status": "done"}
events = []
missing = review_pipeline(FakeProvider(), ["shot_A", "shot_B"], {}, events.append)
print(missing["mean_authored_rating"], missing["reviewed_jobs"], missing["unreviewed_jobs"])
reviewed = review_pipeline(FakeProvider(), ["shot_A", "shot_B"],
{"shot_A": 5, "shot_B": 2}, events.append)
print(reviewed["mean_authored_rating"], reviewed["status"])
try:
review_pipeline(FakeProvider(), ["shot_A"], {"shot_A": True}, events.append)
except PipelineFailure as error:
print(error.stage, error.job_id, type(error.__cause__).__name__)
print(events[-1])Expected output
None 0 2
3.50 findings_present
review shot_A ValueError
{'event': 'failed', 'stage': 'review', 'job_id': 'shot_A'}An unreviewed batch has no authored mean, not a measured zero. The supplied 5 and 2 produce 3.50 under the disclosed policy. Boolean True causes a review-stage PipelineFailure chained from ValueError, followed by a controlled failure event—not a success report.
The finished implementation is in quality_tools/core.py. Reading it is guided practice, not independent evidence.
Predict absence
One job has no authored rating. Should its mean be 0.00?
Compare your answer · self-reviewed
No. Missing is None/unreviewed, not an authored zero. Include only supplied valid ratings in the denominator and keep reviewed/unreviewed counts separate.
Find the erased cause
A fetch handler catches everything and returns status passed. What evidence has vanished?
Compare your answer · self-reviewed
The failed stage and original cause. Wrap with controlled context and raise from the original error; do not replace a fault with success or copy raw private text into events.
Recall type boundaries
Why reject True as a rating despite True == 1?
Compare your answer · self-reviewed
Equality does not establish the required runtime type. This scale requires exact integer 1..5 or None; bool would confuse an authored rating with a logical value.
Change it, then build your own
One controlled change
Use one missing and one supplied rating, then an empty batch. Introduce an invalid status and an invented provider fault separately. Predict counts/mean or the failing stage/cause and final event before running.
Your independent task
Implement review_pipeline using disclosed ID/schema helpers if needed, but own staged traversal, authored-value validation, controlled events, chained failures, counts and private-context mean. Record three hypotheses for a changed failure, disprove two, reduce the fixture, repair only the cause and retain a regression. Do not import the finished pipeline, fabricate missing ratings or log raw private source text.
What success looks like
Build 3 checks empty/partial/supplied authored data, exact integer types, caller Decimal settings, provider/schema/review stages, original cause, controlled events and visible logger faults. Keep your investigation and changed regression separately; passing a supplied case cannot prove that you independently diagnosed it.
Hint 1 · a question
Reduce to one unreviewed job. Which of your three hypotheses survives the actual schema, type and denominator observations?
Hint 2 · a concept cue
Count supplied authored ratings independently from input jobs. Calculate a mean only when that count is nonzero; no value means None.
Hint 3 · a localized example
Raise PipelineFailure(stage, job_id) from the observed cause after the controlled failed event. Keep logger faults outside success-shaped fallbacks and preserve the final stage.
Need the complete worked solution?
Open quality_tools/core.py from the kit. Trace it, close it, then try fresh inputs in your own files. Treat the attempt as guided; seeing the solution does not award a practical pass.
Course help is guidance, not independent evidence. With JavaScript, opening help records guidance locally; otherwise note it in your README. Reset does not erase that history.
Repair a failed check
If empty reviews divide by zero, represent absence before calculation. If partial means use the total job count, use only the supplied-rating denominator. If a fault prints success, remove the fallback. If cause or stage is lost, retain contextual exception chaining. If logs echo private text, restrict their declared fields and review tracebacks separately.
NotImplementedError means a practice stub is still unfinished. Read the failing test name and the last error line. Change one behavior, rerun that build, then rerun all implemented builds.
Show it works on new inputs
Investigate a different job with an invalid boolean rating and a separate provider/schema failure. Retain hypotheses, two disproving observations, minimal input, actual chained cause, repair and regression. Explain changed partial/missing counts and why controlled events do not make a raw traceback automatically safe to share.
Self-review: name the input, result, refused case and reason. Your local test output and explanation are separate from a quiz score; this page does not certify a pass.
Keep the idea
A repair preserves the contract and the evidence. Hiding a crash by inventing a value creates another bug.