Level 5 / Project 13 - Operational Run Logger¶
Home: README
Learn Your Way¶
| Read | Build | Watch | Test | Review | Visualize | Try |
|---|---|---|---|---|---|---|
| — | This project | — | — | Flashcards | — | Browser |
Estimated time: 85 minutes
Focus¶
- run lifecycle observability
Why this project exists¶
This project gives you level-appropriate practice in a realistic operations context. Goal: run the baseline, alter behavior, break one assumption, recover safely, and explain the fix.
Run (copy/paste)¶
Use <repo-root> as the folder containing this repository's README.md.
cd <repo-root>/projects/level-5/13-operational-run-logger
python project.py --input data/sample_input.txt --output data/processed.json --log data/run_log.json --run-id demo-001
pytest -q
Expected terminal output¶
Expected artifacts¶
data/processed.jsondata/run_log.json- Passing tests
- Updated
notes.md
Checkpoint: Baseline code runs and all tests pass. Commit your work before continuing.
Alter it (required) — Extension¶
- Add a
--verboseflag that prints each event to stdout as it is logged. - Add error counting: track how many errors occurred and include in the summary.
- Add a
log_warningmethod toRunLoggerfor non-fatal issues. - Re-run script and tests.
Break it (required) — Core¶
- Point
--inputat a file that does not exist and observe the error handling. - Pass an empty input file (0 lines) and check the event count.
- Capture the first failing test or visible bad output.
Fix it (required) — Core¶
- Ensure
RunLogger.finishis always called even when exceptions occur. - Handle empty input gracefully (0 items processed, status still "completed").
- Add tests for missing input and empty input.
- Re-run until output and tests are deterministic.
Checkpoint: All modifications done, tests still pass. Good time to review your changes.
Explain it (teach-back)¶
- Why does
RunLoggergenerate a uniquerun_idfor each execution? - How does
finish()calculateduration_msfrom start and end times? - What is the purpose of separating
log_eventandlog_error? - Where do you see structured run logging in production (CI/CD pipelines, ETL jobs, cron tasks)?
Mastery check¶
You can move on when you can: - run baseline without docs, - explain one core function line-by-line, - break and recover in one session, - keep tests passing after your change.
Related Concepts¶
| ← Prev | Home | Next → |
|---|---|---|