Developer toolingmedium

Review a batch import change

Review a proposed Python importer, document reproducible findings and fix duplicate handling and partial writes.

Suggested effort
~2h focused work
Window
24 hours
Starts from
An empty repo
Stack
Requires Python
Sign in to start this build →

Opens in a new tab. The clock starts when you press Start inside the environment, not before, and your workspace is kept while you step away.

Time window 24 hours. Suggested effort about 2 hours.

Context

A warehouse team receives batches of inventory records from an upstream service. A teammate proposes the importer below to make reruns painless. This is an original practice change for the GitLab-style code review track.

Stage 1. Review the proposed change

Copy this proposed version into importer.py. Write review comments in REVIEW.md before making your edits. For each blocking finding, name the affected line or behavior, give a concrete input and explain the impact.

def import_batch(rows, records):
    """Add rows to records and return the full inventory snapshot."""
    for row in rows:
        external_id = row["external_id"].strip()
        if external_id in records:
            continue
        records[external_id] = {
            "external_id": external_id,
            "quantity": int(row["quantity"]),
        }
    return list(records.values())

The caller passes a list of dictionaries and a dictionary of existing inventory records keyed by external ID. Each input row must have a nonempty string ID after trimming and an integer quantity of zero or more. Booleans and numeric strings are invalid. IDs are case-sensitive after trimming. Existing records already satisfy the contract.

A repeat with the same ID and quantity should be a successful no-op. An existing ID with a different quantity is a conflict, including within the same batch. Treat invalid rows and conflicts as ValueError. A failed batch must leave every existing record unchanged and add nothing. A successful batch returns the full snapshot in insertion order. Persistence and multiple writers are outside this exercise.

Stage 2. Propose and verify a follow-up

Add a focused set of tests and revise the function. Keep the function signature and successful return shape. In the review handoff, describe which test distinguishes the original and revised implementations and one trade-off you considered. Include a command to run the whole test suite locally.

Acceptance criteria

  • Import ID " A-7 " with quantity 0. The stored ID is "A-7" and its quantity stays zero.
  • Replay the same record. The successful return still contains one record for "A-7".
  • Include a valid new record followed by an invalid record. The original inventory is unchanged. Repeat this check with a conflicting duplicate as the second record.
  • A repeated ID with the same quantity within one batch does not appear twice. A repeated ID with a different quantity raises ValueError.
  • Reject a missing ID, a blank ID, a negative quantity, a numeric string and a boolean.
  • A valid batch still returns previously stored and newly added records in insertion order.
  • REVIEW.md includes actionable findings. README.md gives the test command and identifies a test that fails on the proposal.

Deliverables (every project)

  • Source code committed in this repository (the grader diffs against the first commit).
  • README.md that replaces the stub, with: how to install, run and test it (copy-pasteable commands); the decisions and trade-offs you made; what you would do next with more time; and a short note on how you used the AI agent (what you delegated, what you checked or rewrote).
  • Automated tests that run with a single command (npm test, pytest, go test ./... or cargo test).
  • No secrets in the repository. Anything configurable reads from environment variables with safe defaults.

Ground rules

  • The 24-hour clock is a window, not a workload. Stop at roughly the suggested effort, then write down what you would do next. A small, finished, tested core beats a large unfinished one.
  • Use the AI agent as much or as little as you like: every prompt is recorded and the report shows how it was used. You are judged on the result and on whether you understood and verified what the agent produced.
  • The work is yours. PraxisAI uses it only to produce your assessment report.
Review a batch import change: a 24-hour take-home project | PraxisAI