How I Automated a 7-Step Data Pipeline in 7 Days—and the 3 Pitfalls That Almost Broke It
This article documents a seven-day effort to fully automate a repetitive data analysis workflow: logging into business sites, searching by fixed conditions, capturing trend charts, reading values off those charts, running calculations, and archiving a summary table. It breaks the pipeline into seven chained steps, explains why overall reliability follows a multiplication rule (95% per step drops to roughly 70% across seven), and details three concrete failure modes with practical fixes: treating browser automation as a conversation instead of a contract, using general-purpose vision models for charts that should be measured locally with pixel thresholds, and trying to accumulate lessons in chat context rather than in files, code, and test cases. Includes working Python examples for overlay handling, self-checking search, and chart-to-matrix conversion, plus four reusable conclusions for building deterministic automation.
1. Where It Started: Half a Day Lost to Mechanical Work
Anyone who does data trend analysis knows this state well. At fixed times each day you log into several business sites, search by set conditions, capture more than three hundred trend charts, then read each one to judge the direction, annotate the values, apply an established algorithm, and finally roll everything into a table. None of it is technically demanding, but it consumes attention at an enormous rate. Your eyes ache, your focus scatters, and half the day is gone before you can even find time to drink water.
Work like this has a defining profile: the process is fixed, the inputs are well defined, and the outputs are verifiable. That makes it an ideal candidate for automation. I had previously built a hotspot collection and aggregation pipeline on an old laptop, which proved that the chain “scheduled trigger + browser operation + results written to a database” works. So a natural question followed: if browser operations can be automated, can the “look at the chart, read the number, compute” segment be taken over as well?
With that expectation, I ran a complete attempt over seven days, went through six different model approaches, and eventually got all seven steps working end to end. Below I break down the pitfalls by stage, with a practical way to avoid each one.
2. Breaking Down the Pipeline: Seven Steps and Their Weak Points
The automation chain was divided into seven steps:
- Simulate login and establish a session;
- Search precisely by conditions;
- Capture a screenshot of the root node;
- Capture screenshots of the detail (boot number) entries;
- Map the screenshots into a numeric matrix;
- Produce results according to the algorithm dictionary;
- Aggregate and archive.
Overall reliability of the chain follows the multiplication rule: at 95% success per step, seven steps in series yield only about 70% overall. This means the optimization focus should not be “make one step smarter” but “make every step more deterministic, make failures observable, and make them retryable.” That was the single most important shift in thinking from this whole exercise.
3. Pitfall 1: Teaching Browser Automation as If It Were a Conversation
The earliest failures clustered around login and search. When asking an AI coding tool to generate the operation script, two problems showed up repeatedly. First, element locators were written to depend too heavily on tag structure; after a partial page redesign the locator broke, the search condition was typed into the wrong field, and the returned content had nothing to do with expectations. Second, on encountering a CAPTCHA, a floating ad, or a consent popup, the script simply stalled, or clicked the wrong button and closed the whole tab.
What cost even more time was my own response: repeatedly telling it in natural language to “remember to close the popup first.” I corrected it more than fifty times, and each time it found a new way to be wrong.
Root cause: I handed something that required determinism to probabilistic generation, and used conversation to carry constraints that belonged in code.
The fix is to make implicit rules explicit, forming an executable and verifiable contract:
# 1) Centralize selectors so they are not scattered everywhereSELECTORS = {"search_input": "#kw","search_button": ".btn-search","overlay_close": ".modal-close, .mask .close",}def dismiss_overlays(page, max_rounds=5):"""Close overlays from an explicit list; exit if none found, never guess a button"""for _ in range(max_rounds):closed = Falsefor sel in SELECTORS["overlay_close"].split(", "):el = page.query_selector(sel)if el and el.is_visible():el.click()closed = Truebreakif not closed:return Truereturn Falsedef safe_search(page, keyword):dismiss_overlays(page)page.fill(SELECTORS["search_input"], keyword)page.click(SELECTORS["search_button"])page.wait_for_load_state("networkidle")# Key point: self-check the result and fail here instead of running onassert page.query_selector(".result-item"), "Empty search results, aborting the chain"
Three points matter: separate selectors from business logic; handle overlays with a whitelist rather than visual guessing; add an assertion at the end of each step so failures surface early. In addition, reuse an existing session for login state whenever possible, and hand strong human-verification challenges such as CAPTCHAs to a person to complete once, rather than asking the program to “crack” them.
4. Pitfall 2: Both Cost and Accuracy Spin Out of Control on Visual Recognition
Step 5, “screenshot to numeric matrix,” is the throat of the whole chain. My first move was the one most beginners take: call a general-purpose vision model API to do the recognition.
The process went through roughly three stages. First I used a model on a free tier; it misjudged even basic colors, and the output matrix was almost entirely wrong. Then I switched to two mid-tier models; recognition was usable but hallucination was obvious, with near-identical targets such as 5 versus 3 and red versus blue frequently confused. Finally I used a high-spec model; accuracy met the bar, but cost per image rose to the level of a few dimes, and three hundred images a day for a month was completely unacceptable.
Root cause: these charts are graphics generated in a controlled environment. Colors, legends, axes, and ticks are deterministic pixels drawn by a program—a typical case of “structured vision.” General-purpose vision models are designed for open-domain semantic understanding; using their probabilistic generation to solve a deterministic problem is the most expensive way to do the least reliable thing.
The fix is to switch to local image processing and degrade “recognition” into “measurement.” The core is to do color space conversion and threshold segmentation first, then count pixel ratios over a grid:
import cv2, numpy as npdef chart_to_matrix(img_path, rows=4, cols=6, palette=None):img = cv2.imread(img_path)hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)palette = palette or {"red": (0, 120, 80), "blue": (110, 130, 90)}h, w = img.shape[:2]matrix = []for r in range(rows):line = []for c in range(cols):cell = hsv[r*h//rows:(r+1)*h//rows, c*w//cols:(c+1)*w//cols]best, best_ratio = None, 0.0for name, rng in palette.items():mask = cv2.inRange(cell, np.array(rng[:2]+(40,)), np.array(rng[2:]+(255,)))ratio = cv2.countNonZero(mask) / mask.sizeif ratio > best_ratio:best, best_ratio = name, ratioline.append(best if best_ratio > 0.15 else None)matrix.append(line)return matrix
The payoff runs in two directions: no network access and no consumed API quota, so marginal cost approaches zero; and the decision rests on a deterministic rule—pixel thresholds—so results are reproducible, regression-testable, and accuracy stays at a usable level. Engineering-wise only two things are needed: fix the screenshot resolution and crop region, and maintain a color threshold dictionary that you update whenever the chart palette changes.
5. Pitfall 3: The “Triangle Trap”—Corrections in Conversation Never Accumulate
The most draining part was not writing code but the training process itself. My original expectation was that if I fed errors back to the model, it would not repeat them next time. The actual result was a closed loop: it makes a mistake, I correct it, it says it has noted the point, the same issue resurfaces two days later, I correct it again, and the same explanation gets output over and over. This is the so-called “triangle trap”: the three parties (human, model, context) keep circling each other and nothing accumulates.
Root cause is twofold. First, session context is limited, so early agreements in a long project get pushed out of the window. Second, natural-language agreements carry no enforcement; a model can “understand” while not “complying.”
The fix is to move all experience out of the conversation and into engineering structures:
- Rules as files: write project conventions, directory structure, coding standards, and prohibited items into a documentation file in the repository that loads automatically every session, instead of relying on me to restate them;
- Constraints as code: anything that can be expressed as an assertion, a type annotation, or a validation function should never be written as a “please note” in a comment;
- Tasks as tickets: split requirements into small tasks with acceptance criteria and close them one by one, avoiding delivery of one giant script;
- Regression cases: prepare fixed inputs and expected outputs for each step, run the cases after any change, and turn “it did it again” into “the test went red”;
- Observable failures: emit structured logs at every step containing the screenshot path, elapsed time, and decision result, paired with monitoring and alerting so anomalies are intercepted before aggregation.
6. Final Form and Reusable Conclusions
After the rework, the chain runs unattended on a schedule: a local script handles login and screenshots, local algorithms handle matrix mapping and calculation, aggregated results are written to a table and archived, and failing steps retry automatically and trigger alerts. If stronger semantic understanding is needed later, services in general categories can supplement it—for example, object storage to archive raw screenshots, a message queue to decouple steps, a container platform to carry scheduling, and a logging service with monitoring and alerting for observability—keeping the architecture flexible without binding to any specific product.
The conclusions from seven days compress into four sentences:
- Use deterministic means for deterministic tasks, and for vision problems first ask whether they can be reduced to measurement;
- Add self-checks and assertions at every step so the chain fails early and fails clearly;
- Experience must be deposited into files, code, and test cases, not left in the conversation;
- Get a minimal loop working first, then replace the weak links one at a time; do not chase full-chain intelligence from the start.
Following these four rules, the half day previously swallowed by mechanical work can genuinely be returned to analysis itself—which is also the most tangible value of automation.
