Orders: validate, schedule, store, reconcile and release
This connected workshop develops six computing subjects through one business case. Read the chapters, predict the output, run the local Python exercise and defend a managerial interpretation. The file is synthetic; nothing here sends payment, email or production requests.
Start here
Prerequisites: basic arithmetic, familiarity with files and a Python 3 installation. Allow roughly two to four study sessions; this is guidance, not a measured completion time. The lab uses only the Python standard library and has no account requirement. If Python syntax is new, read the programming chapter before inspecting the source.
- Python: state and test a business rule
- Data structures: identity, lookup and scheduling
- Operating systems: paths, processes and failures
- SQL: grain, constraints and reconciliation
- Data practice: classification and interpretation
- DevOps: checks, release and recovery
The contract
Every record requires an identifier, a department, a positive integer quantity and a non-negative integer price in paise. A zero price is permitted in this exercise. An identical repeat is a replay. A repeated identifier with changed content is a conflict, retained as an exception. Accepted records are scheduled in arrival order. This is a single-process rule, not a global duplicate guarantee.
Predict before running
| Row | Input | Expected classification | Value included |
|---|---|---|---|
| 1 | A, sales, 2 × 12,500 paise | Accepted | 25,000 paise |
| 2 | B, operations, 3 × 5,000 | Accepted | 15,000 |
| 3 | Identical A | Replayed | 0 additional |
| 4 | A with price 13,000 | Conflicting | 0 additional |
| 5 | C with quantity 0 | Rejected | 0 |
| 6 | D with price 0 | Accepted | 0 |
| 7 | E with quantity “two” | Rejected | 0 |
| 8 | Missing identifier | Rejected | 0 |
Reconciliation: 3 accepted + 1 replay + 1 conflict + 3 rejected = 8 inputs. Accepted value = 25,000 + 15,000 + 0 = 40,000 paise = INR 400. Processing order is A, B, D. Sales contributes INR 250 and operations INR 150. These are order-line values, not departmental profits or actual receipts.
Run locally
The cumulative download already contains these files in public/labs. Alternatively download all three to the same folder: program, fixture and tests.
cd "$HOME/Documents/amit-study/amit-study/public/labs"
python3 order_workflow.py
python3 -m unittest -v order_workflow_test
Nine tests cover the fixture, empty input, changed quantity, zero price, invalid values, missing fields, a missing file, unchanged input and independent runs. Read the test expectations before changing code. A passing result establishes these checks only; it does not establish production security or exhaustive correctness.
Inspect the mechanisms
The dictionary retains accepted content by identifier. The deque preserves arrival order for processing. SQLite enforces a primary key and bounded value constraints. Parameter binding keeps values separate from SQL syntax. A grouped query and a Python total reconcile the result. The in-memory database disappears at exit; every run starts again. Use the separate durable-request workshop to study persistent replay across restarts.
Make the human decisions explicit
Sales should explain whether the changed price reflects a legitimate correction. Finance should validate the definition and units of value. Operations should confirm the schedule and capacity. IT should preserve the source and report technical failure clearly. Management must appoint an exception owner and review whether the rule creates avoidable work. Consultation informs the decision; accountability identifies who can authorise it.
Ask who approves a correction, whom delay affects, whose identifier is authoritative, what the report measures, where the file is stored, when it becomes stale, why a zero price is permitted, which scheduling rule fits the service promise and how errors are detected. Do not rank departmental performance from these designed synthetic rows.
Portfolio and assessment
- Write a field dictionary and rule contract, including zero price and duplicate identity.
- Draw the normal and exception handoffs, with correction authority.
- Predict and reconcile counts and value by hand.
- Add a new test for changed department under the same identifier; explain why it conflicts.
- Write a local release checklist and a recovery note for a missing source file.
- Submit a decision memo distinguishing accepted order value, profit and cash.
Use each chapter’s four individual questions and revision cards. At research level, propose a comparison of correction accuracy or turnaround under explicit exception categories. Specify comparable cases, evidence and limitations. At postgraduate level, critique how exclusion and scheduling affect departments and customers. At foundation level, explain one valid row and one rejection in ordinary language.
Practice boundaries and next work
There is no hosted CI run, authentication, concurrent worker, persistent database, network API or external delivery guarantee. Those require further exercises. Local repeatability is a starting point. Next connect source validation with records and data quality, and connect release decisions with the transformation workshop.
Free primary references
- Python tutorial — assumes some programming familiarity.
- Python collections — reference for container behaviour.
- Python sqlite3 — database interface reference.
- GitHub Actions concepts — hosted execution and pricing are separate from this local exercise.