<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Alice Bui on Medium]]></title>
        <description><![CDATA[Stories by Alice Bui on Medium]]></description>
        <link>https://medium.com/@alice_bui?source=rss-5a1ff9131477------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0PJd3gUL0X4C_gZWrPgavw.jpeg</url>
            <title>Stories by Alice Bui on Medium</title>
            <link>https://medium.com/@alice_bui?source=rss-5a1ff9131477------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 13:36:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alice_bui/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Writing Agent-Ready LookML for Looker Conversational Analytics]]></title>
            <link>https://medium.com/refined-and-refactored/writing-agent-ready-lookml-for-looker-conversational-analytics-32a004f873ce?source=rss-5a1ff9131477------2</link>
            <guid isPermaLink="false">https://medium.com/p/32a004f873ce</guid>
            <category><![CDATA[looker]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[conversational-ai]]></category>
            <dc:creator><![CDATA[Alice Bui]]></dc:creator>
            <pubDate>Mon, 27 Jul 2026 09:19:20 GMT</pubDate>
            <atom:updated>2026-07-29T10:08:06.213Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Part 1 of a series on rolling out Looker Conversational Analytics — 7 best practices with LookML examples.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YeOUp4izKBALODKZPZmzLg.png" /><figcaption>Writing Agent-Ready LookML for Looker Conversational Analytics</figcaption></figure><p>Most Looker teams already have Conversational Analytics. Few trust it. The gap almost always traces back to LookML — labels, synonyms, hidden fields — done carelessly or skipped.</p><p>Google actually documents the core of this well. Its Conversational Analytics best-practices guide lists five key LookML takeaways: precise labels, synonyms &amp; descriptions for mapping, centralized calculations, hiding technical fields, and optimizing suggestions for fuzzy search. What it doesn’t give you is LookML examples. This post walks through those five, plus a couple of adjacent practices, each with the actual LookML.</p><h3>1. Business-friendly labels</h3><p>Conversational Analytics maps natural language to field names — if your labels are internal shorthand, every question starts at a disadvantage. Labels should read the way a business user would say them out loud, not the way an engineer named the column.</p><pre>dimension: rfm_segment {<br>  type: string<br>  sql: ${TABLE}.rfm_segment ;;<br>  label: &quot;Customer Segment&quot;        # not &quot;rfm_segment_cd&quot;<br>}</pre><p><strong>Demo — before/after.</strong> A field labeled rfm_segment will rarely get picked when someone asks &quot;who&#39;s at risk of churning.&quot; Labeled label: &quot;Customer Segment&quot;, it&#39;s a near-exact string match.</p><h3>2. Synonyms &amp; descriptions for field mapping</h3><p>These two parameters do different jobs, and mixing them up is the most common LookML mistake for CA. synonyms handles general vocabulary variations Gemini should map without being told twice — &quot;revenue&quot; to &quot;sales,&quot; for instance. description anchors the field&#39;s exact math and boundaries — not more vocabulary.</p><pre>measure: total_net_revenue {<br>  type: sum<br>  sql: ${TABLE}.gross_revenue - ${TABLE}.refunds ;;<br>  label: &quot;Total Net Revenue&quot;<br>  synonyms: [&quot;sales&quot;, &quot;top line&quot;, &quot;net sales&quot;]<br>  description: &quot;Aggregates gross revenue minus processed refunds. Excludes promotional credits. Used for official GAAP financial reporting.&quot;<br>}</pre><p>synonyms catches the vocabulary variation. description keeps the definition airtight — what&#39;s included, what&#39;s excluded, which reporting standard it maps to — so the agent doesn&#39;t quietly redefine &quot;revenue&quot; when it summarizes results.</p><p>For fields where a business phrase doesn’t map to a single value but to a <em>combination</em>, that logic can’t live in a synonym — it belongs in Agent Instructions instead. LookML’s job here is making the individual fields unambiguous; instructions handle compound terms like “High-Value + At-Risk customer.”</p><h3>3. Centralized measures &amp; dimensions</h3><p>Conversational Analytics can’t compute custom fields on the fly. If a metric isn’t defined once in LookML, the agent can’t produce it consistently — it’ll either refuse or, worse, approximate it differently across conversations.</p><p>In some scenarios, you will need to build a PDT for new measures or dimensions.</p><pre>view: clv_prediction_pdt {<br>  derived_table: {<br>    sql: SELECT customer_id, predicted_clv_90d<br>         FROM ${clv_model.SQL_TABLE_NAME}<br>    ;;<br>    datagroup_trigger: daily_etl<br>  }<br>  dimension: predicted_clv_90d {<br>    type: number<br>    sql: ${TABLE}.predicted_clv_90d ;;<br>    label: &quot;Predicted 90-Day CLV&quot;<br>  }<br>}</pre><h3>4. Hide internal and technical fields</h3><p>Every field Conversational Analytics can see is context it has to reason over on every question. Fields with no business meaning — join keys, ETL metadata, internal flags — should be hidden so they don’t compete with the fields that actually answer questions.</p><pre>dimension: internal_customer_key {<br>  hidden: yes<br>  type: string<br>  sql: ${TABLE}.internal_customer_key ;;<br>}</pre><p><strong>Demo.</strong> In one explore we curated, hiding 14 of 40 fields (join keys and ETL metadata) was the single change that moved a batch of ambiguous test questions from “agent grabs the wrong column” to passing — no instruction changes required.</p><h3>5. Suggestions and suggest_explore for fuzzy search</h3><p>By default, Looker generates suggestions by querying the field’s own explore for distinct values. When users reference specific values by name — a segment, a campaign, a product line — suggestions gives Conversational Analytics a controlled list to match against, rather than triggering a live database lookup on every guess.</p><pre>dimension: rfm_segment {<br>  type: string<br>  sql: ${TABLE}.rfm_segment ;;<br>  suggestions: [&quot;Champion&quot;, &quot;Loyal&quot;, &quot;At-Risk&quot;, &quot;Hibernating&quot;, &quot;Promising&quot;, &quot;Need Attention&quot;, &quot;New Customers&quot;]<br>}</pre><p>That’s fine for a handful of RFM segments, but expensive and messy against a campaign_name or SKU field with tens of thousands of rows — especially if the underlying table has typos, deprecated entries, or duplicate casing sitting in it. suggest_explore and suggest_dimension redirect that lookup to a separate, smaller table you control — typically a clean lookup or dimension table — instead of querying the raw fact table directly.</p><p>Two concrete gains from that: the suggestion query runs against a much smaller, indexed table instead of scanning millions of fact rows, and the values CA is matching against are the ones you’ve deliberately curated as correct — not whatever variant happens to exist in raw transactional data.</p><p>For high-cardinality fields where a static list isn’t practical (product SKUs, campaign names), point CA at a dedicated suggest explore instead:</p><pre>dimension: campaign_name {<br>type: string<br>sql: ${TABLE}.campaign_name ;;<br>suggest_explore: campaign_lookup<br>suggest_dimension: campaign_lookup.campaign_name<br>}</pre><p>Here, campaign_lookup is a small, clean explore — one row per campaign, current values only — separate from the fact table campaign_name actually lives on. This is the difference between the agent silently misreading “Win-Back” as a filter on the wrong column, versus matching it correctly against a known entity list — and it’s faster, since it skips a live sample-data query against the full fact table.</p><h3>6. Aggregate awareness for response speed</h3><p>Conversational Analytics queries run in a conversational context — a 15-second wait breaks the experience in a way it wouldn’t in a scheduled dashboard. Aggregate tables let Looker route a query to a pre-aggregated table when the requested grain allows it.</p><pre>aggregate_table: rollup_by_segment_month {<br>  query: {<br>    dimensions: [rfm_segment, order_month]<br>    measures: [repeat_revenue, order_count]<br>  }<br>  materialization: {<br>    datagroup_trigger: daily_etl<br>  }<br>}</pre><p>The exact aggregate table shape should be tuned to your own explore’s grain and query patterns — this is the general pattern, not a copy-paste fit for every model.</p><h3>7. Extended explores</h3><p>Conversational Analytics doesn’t need the full analyst-facing explore. An extends explore lets you expose a lean, high-signal subset purpose-built for conversational use, without duplicating the underlying view. Google&#39;s docs mention this as an optional step for explores with a lot of fields — worth calling out on its own since it&#39;s an easy one to skip.</p><pre>explore: clv_rfm_predict_ca {<br>  extends: [clv_rfm_predict]<br>  # CA-facing view — only fields relevant to segment &amp; CLV questions<br>  fields: [ALL_FIELDS*, -internal_customer_key, -etl_batch_id, -legacy_score_v1]<br>}</pre><p>This keeps your analyst explore untouched — full field set, full flexibility — while Conversational Analytics gets a version scoped tightly to the six or so decision areas it’s actually meant to answer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32a004f873ce" width="1" height="1" alt=""><hr><p><a href="https://medium.com/refined-and-refactored/writing-agent-ready-lookml-for-looker-conversational-analytics-32a004f873ce">Writing Agent-Ready LookML for Looker Conversational Analytics</a> was originally published in <a href="https://medium.com/refined-and-refactored">Joon Solutions</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Dashboard to Action: Predictive RFM Inside Looker]]></title>
            <link>https://medium.com/refined-and-refactored/from-dashboard-to-action-predictive-rfm-inside-looker-89501df081ad?source=rss-5a1ff9131477------2</link>
            <guid isPermaLink="false">https://medium.com/p/89501df081ad</guid>
            <category><![CDATA[digital-marketing]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[looker]]></category>
            <dc:creator><![CDATA[Alice Bui]]></dc:creator>
            <pubDate>Wed, 03 Jun 2026 07:46:00 GMT</pubDate>
            <atom:updated>2026-06-04T09:51:21.049Z</atom:updated>
            <content:encoded><![CDATA[<p>We’ve all seen this lifecycle in modern analytics.</p><p>A data team builds a brilliant machine learning model. They publish a beautiful dashboard. The marketing team reviews it, says “that’s nice,” and immediately asks for a manual CSV export so they can upload it to their email tool. By the time the campaign actually launches, the data is stale, the data boundary has been broken, and the friction has delayed revenue generation.</p><p>We decided to fix this. By unifying a native BigQuery ML (BQML) predictive engine with Looker’s semantic layer and Action Hub, we built a <strong>closed-loop customer scoring system </strong>that refreshes daily and lets marketers <strong>trigger targeted campaigns with a single click.</strong></p><h3>1. The Strategy: RFM + Predictive CLV</h3><p>Traditional RFM (Recency, Frequency, Monetary) is purely historical. It tells you who was a loyal customer three months ago, but fails to forecast future risk. A standalone CLV model gives you a predicted dollar amount but misses the customer’s current behavioral state.</p><p>Combining them unlocks a <strong>2D Action Matrix</strong>. The intersection of a customer’s RFM state and their predicted 12-month value dictates the exact recommended marketing play:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-4aFWn9CJqNASrJHYuLmtA.png" /><figcaption>2D Action Matrix</figcaption></figure><p>Instead of guessing, marketers see native fields like <em>Recommended Action</em> and <em>Action Priority</em> generated automatically by the matrix. A customer flagged as High CLV but At-Risk triggers an immediate <strong>Urgent Retention</strong> action — no analyst interpretation needed.</p><h3>2. The Brains: BigQuery ML Under the Hood</h3><blockquote>If you’re primarily interested in the marketing activation story, skip ahead to Section 3.</blockquote><p>The Looker deployment manages training and daily scoring natively through BigQuery ML using four key view files: clv_features_training.view.lkml, clv_models.view.lkml, clv_rfm_predict.view.lkml, and clv_eval_*.view.lkml for evaluation metrics.</p><p>Every day, three specialized BQML BOOSTED_TREE models evaluate each customer against 8 core behavioral features — including frequency, recency, days since last order, and average order value:</p><ul><li><strong>The Classifier</strong> (clv_fit_classifier): Predicts the probability a customer will purchase in the next 90 days.</li><li><strong>The Count Regressor</strong> (clv_fit_count_regressor): Forecasts total expected purchases over that window.</li><li><strong>The AOV Regressor</strong> (clv_fit_aov_regressor): Predicts expected average order value.</li></ul><p>These outputs combine into a final annualized value formula:</p><blockquote><strong><em>Predicted CLV (12m) = P(purchase) × Expected Purchases × Predicted AOV × 4.06</em></strong><em> </em>(4.06 = annualization factor for a 90-day prediction window, i.e. 365/90)</blockquote><p>To ensure stability as the customer distribution shifts over time, Looker uses APPROX_QUANTILES to dynamically recalculate CLV Tiers (High / Mid / Low) as daily percentiles — Top 20%, Next 30%, Bottom 50% — rather than fixed dollar thresholds.</p><h3>3. The Interface: Dashboards for Two Audiences</h3><p>To bridge analytics and operations, the deployment features two distinct dashboard spaces — one built for marketers, one for data teams.</p><h3>For Marketing: Business Activation</h3><p>Marketers don’t see raw SQL or model weights. They get clear behavioral buckets and immediate tactical answers. Using the RFM — Predictive CLV Segment Explore, they can answer business questions instantly:</p><ul><li><strong>Geographic Value:</strong> Where are our highest-value customers located?</li><li><strong>Acquisition Health:</strong> Which channels bring in the most valuable cohorts?</li><li><strong>Product Correlation:</strong> Which product categories scale with High CLV tiers?</li></ul><p>Rather than surfacing every available metric, the dashboard points marketers to what actually moves the needle. It’s built as a top-down funnel — three pages, three jobs: understand the full picture, drill into what matters, then act on it.</p><h4>Page 1: Segment Overview</h4><p>This is the landing page. It answers one question: <em>where do our customers stand right now?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oYXg3PZiwzOqpfsVk8qulQ.png" /><figcaption><em>Customer Segment Overview — Landing Page</em></figcaption></figure><p>The centerpiece is an RFM scatter plot — X axis is days since last order, Y axis is average order value, bubble size is customer count. Champions cluster top-left. Hibernating customers drift to the bottom-right. Any audience can read it in ten seconds.</p><p>The supporting charts answer the follow-up questions: How much revenue is concentrated in each tier? How has spending shifted over time? Which segments are growing, which are shrinking?</p><p>A KPI row at the top — total customers, total revenue, average order value, average days since last order, all with period-over-period comparison — gives the marketer a baseline before they ask their first question.</p><p>The color palette was tailored to the audience’s own brand. Each segment gets a distinct color derived from brand assets, applied consistently across every chart on every page. The dashboard feels like a single designed product, not a collection of charts.</p><h4>Page 2: Segment Deep-Dive</h4><p>Once you know which segment needs attention, the questions start stacking up. <em>Who exactly are these customers? What do they buy? Where are they? How close are they to converting again?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RVrw5RraEH8chTDfOb0JzA.png" /><figcaption><em>Segment Deepdive — Granular View</em></figcaption></figure><p>This page answers all of it. RFM scores for the filtered segment sit side by side so you can see immediately whether the problem is recency, frequency, or spend. A product category breakdown shows what this segment actually buys. Gender and age distributions round out the behavioral picture, and a benchmark bar compares the segment’s purchase probability against the sitewide average — so the audience knows how urgent the situation actually is.</p><p>The page closes with a heatmap showing customer density by region. High-value customers concentrate in predictable markets; at-risk customers spread thin elsewhere. That’s what a well-built map does: it tells a story that a table never could.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q8QKt1pjcXxtKYuqy0g7rw.png" /><figcaption><em>A Heatmap Showing Customer Count &amp; Revenue</em></figcaption></figure><h4>Page 3: Action Center</h4><p>This is where the dashboard stops being a report and becomes a tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jsMP20QQiqG4aZk9LfgGJg.png" /><figcaption><em>Action Center — Data-driven Recommended Actions</em></figcaption></figure><p>Four KPI tiles at the top frame the urgency: high-value “need attention” segment customer count, revenue “need attention”, average days since last order for the segment, average purchase probability. All filtered to the “need attention” segment by default. The numbers are alarming by design.</p><p>Below that, a segment action table sorted by priority — Urgent Retention at the top. Each row shows the segment, audience size, predicted CLV, purchase likelihood, and a recommended action computed by the model. Click the recommended action column, a form opens pre-filled with campaign type and segment context. Hit send. The data goes directly to the marketing automation platform.</p><p><strong>No CSV. No copy-paste. No analyst in the loop. The workflow takes under 30 seconds.</strong></p><p>A revenue trend line and traffic source chart round out the page — giving the marketer enough context to understand <em>why</em> a segment is declining before they send the campaign.</p><p><strong>Design decisions that mattered:</strong> Visual consistency was non-negotiable. Every chart shares the same background, grid style, typography, and tooltip treatment. Filters were wired with intent — not every tile should respond to every filter. The dashboard was built entirely on a single explore: one query surface, three pages, consistent filter behavior throughout.</p><h3>For Data Teams: Model Trust and Evaluation</h3><p>A predictive model is only useful if it’s trusted. The evaluation dashboard exposes model health parameters, class weights, and calibration data directly to analysts — giving full visibility into when models automatically retrain each quarter and flagging drift before it affects campaign quality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QposZrJqiVMtfFdbzLmBDg.png" /><figcaption>Dashboard for Model Evaluation</figcaption></figure><h3>4. The Closer: One-Click Execution via Looker Actions</h3><p>This is where the closed loop completes. A marketer targeted a customer segment that need ‘Protect &amp; Delight’ on the dashboard and see the following actions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ijYh97WWzG805dHXqOZiCA.png" /></figure><p>Instead of copying rows or pulling a CSV, the marketer clicks the native Looker Action dropdown and sends the segment directly to an automated email flow in SendGrid, Klaviyo or Resend, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uGDGBZR-JewGQi7Y9FJ-Sw.png" /></figure><p>The customer receives a personalized coupon within seconds. The data never leaves the secure boundary of the data warehouse. And marketers can track the request status, whether the email is successfully sent to the customer or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2l2UTA_On7EWfLI8Y6Zc8w.png" /></figure><h3>Analytics Made Operational</h3><p>By moving the predictive logic into BigQuery with BQML and serving it through Looker’s semantic layer, we’ve transformed the traditional dashboard from a passive chart into an active operational engine.</p><ul><li>Marketing teams move faster with pre-built action recommendations.</li><li>Data scientists retain full model governance through the evaluation dashboard.</li><li>The business actively prevents churn before it happens — no CSV required.</li></ul><blockquote><strong><em>Want to see it for yourself? Walk through the dashboards and see the actions fire in real time. Get in touch, and we’ll set up a session: </em></strong><a href="https://joonsolutions.com/">https://joonsolutions.com/</a></blockquote><p><em>This blog is co-written by </em><strong><em>Alice</em></strong><em>, </em><strong><em>Ted</em></strong><em>, and </em><strong><em>Duc</em></strong><em> — Analytics Engineers at </em><a href="https://joonsolutions.com/"><em>Joon Solutions</em></a><em>. We specialize in building end-to-end data and analytics solutions that turn raw data into operational tools.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89501df081ad" width="1" height="1" alt=""><hr><p><a href="https://medium.com/refined-and-refactored/from-dashboard-to-action-predictive-rfm-inside-looker-89501df081ad">From Dashboard to Action: Predictive RFM Inside Looker</a> was originally published in <a href="https://medium.com/refined-and-refactored">Joon Solutions</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Debugging Python in VSCode: Everything You Need to Know!]]></title>
            <link>https://medium.com/@alice_bui/debugging-python-in-vscode-everything-you-need-to-know-39340a2b79fb?source=rss-5a1ff9131477------2</link>
            <guid isPermaLink="false">https://medium.com/p/39340a2b79fb</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[debugging-tools]]></category>
            <category><![CDATA[debugging]]></category>
            <dc:creator><![CDATA[Alice Bui]]></dc:creator>
            <pubDate>Mon, 26 Jan 2026 09:30:45 GMT</pubDate>
            <atom:updated>2026-01-26T09:30:45.723Z</atom:updated>
            <content:encoded><![CDATA[<h3>1. Stop printing, start using Vscode Debugger</h3><p>If you are still debugging your Python scripts by sprinkling print(variable) everywhere, you are wasting resources. When you are writing a simple script that runs in 1 second, print() works fine. But when you are working on <strong>complicated code files, </strong>like processing huge datasets or running a long automation task - print() becomes expensive.</p><p><strong>The Problem: </strong>Imagine your script takes <strong>20 minutes</strong> to run because it is processing a large file.</p><ol><li>You suspect a bug, so you add print(variable).</li><li>You run the script and wait <strong>20 minutes</strong> just to see that one value.</li><li>You realize you need to see a different variable.</li><li>You add another print statement and wait <strong>another 20 minutes</strong>.</li></ol><p>In complex projects, every print() statement costs you valuable time and computing resources. You are essentially restarting a movie from the beginning every time you want to see a specific scene.</p><p><strong>The Solution:</strong> The VS Code Debugger acts as a <strong>“Magic Pause Button.”</strong> It freezes execution exactly where the bug is, allowing you to inspect <em>all</em> variables instantly without ever re-running the code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1ZRA1K48FLPYDbiOlvLu6A.png" /></figure><h3>2. Set up Python Debugger Extension</h3><p>The <a href="https://marketplace.visualstudio.com/items?itemName=ms-python.debugpy">Python Debugger extension</a> is automatically installed along with the <a href="https://marketplace.visualstudio.com/items?itemName=ms-python.python">Python extension</a> for VS Code. It offers debugging features with <a href="https://pypi.org/project/debugpy/">debugpy</a> for several types of Python applications, including scripts, web apps, remote processes and more.</p><p>To verify it’s installed, open the Extensions view (⇧⌘X) and search for @installed python debugger. You should see the Python Debugger extension listed in the results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fzY0hWVr4zXCnQzc.png" /></figure><h3>3. Configuration: launch.json</h3><p>VS Code can often “Run &amp; Debug” a file with zero setup. But for professional applications, you need a plan. This plan lives in a file called launch.json. To create it, go to the <strong>Run and Debug</strong> tab and click <strong>“create a launch.json file”</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Mg6pNUlfS58QMDpK.png" /></figure><p>Below are the key properties in the launch.json file:</p><ul><li><strong>&quot;name&quot;</strong>: The label that appears in the Debug dropdown list (e.g., &quot;Debug ETL Script&quot; or &quot;Debug Startup&quot;). Make this descriptive so you know which config you are picking.</li><li><strong>&quot;program&quot;</strong>: The entry point of your script.</li></ul><p><strong>Common:</strong> &quot;${file}&quot; runs whatever file is currently open in your editor.</p><p><strong>Best Practice:</strong> &quot;${workspaceFolder}/src/main.py&quot; ensures you always start from the <em>same</em> entry point, no matter which file you are looking at.</p><ul><li><strong>&quot;args&quot;</strong>: Simulates command-line arguments. <em>Use Case:</em> If you usually run python main.py --date 2023-01-01, you add &quot;args&quot;: [&quot;--date&quot;, &quot;2023-01-01&quot;].</li><li><strong>&quot;env&quot;</strong>: Sets environment variables <em>only</em> for the debug session. <em>Use Case:</em> Injecting secrets without hardcoding them. e.g., &quot;DB_PASSWORD&quot;: &quot;my_secret_key&quot;.</li><li><strong>&quot;cwd&quot;</strong> (Current Working Directory): Determines what folder Python considers &quot;Home&quot; when running. <em>Why it matters:</em> If your code does pd.read_csv(&#39;data/file.csv&#39;), it might fail if the cwd is wrong. Setting &quot;cwd&quot;: &quot;${workspaceFolder}&quot; usually fixes &quot;File Not Found&quot; errors.</li></ul><h4>Summary Snippet</h4><pre>{<br>    &quot;name&quot;: &quot;Debug Data Pipeline&quot;,<br>    &quot;type&quot;: &quot;debugpy&quot;,<br>    &quot;request&quot;: &quot;launch&quot;,<br>    &quot;program&quot;: &quot;${workspaceFolder}/etl_script.py&quot;, <br>    &quot;cwd&quot;: &quot;${workspaceFolder}&quot;,<br>    &quot;justMyCode&quot;: true,<br>    &quot;args&quot;: [&quot;--daily-run&quot;],<br>    &quot;env&quot;: {<br>        &quot;API_KEY&quot;: &quot;12345&quot;<br>    }<br>}</pre><h3>4. Breakpoints</h3><p>The <strong>Breakpoint</strong> (the red dot) is your stop sign. You create one by clicking to the left of the line number. It tells the debugger: <em>“Run at full speed until you hit this line, then freeze.”</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PjNM6FqBBu4HaEM5aRb61w.png" /></figure><p>But if you are looping through thousands of rows, a standard breakpoint is a trap. You don’t want to hit “Continue” 500 times. This is where <strong>Smart Breakpoints</strong> come in.</p><p>Right-click any red dot to access these hidden features:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ne9J3G14emlqQjXYqTbLdg.png" /></figure><h4>4.1. Conditional Breakpoints</h4><p><strong>The Scenario:</strong> You are processing a CSV with 10,000 rows. The script crashes, but only on row #4,500.</p><ul><li><strong>The Problem:</strong> You can’t step through the first 4,499 rows manually.</li><li><strong>The Fix:</strong> Right-click the breakpoint and select <strong>Edit Breakpoint</strong>. Add a condition like row_id == 4500.</li><li><strong>The Result:</strong> You hit <strong>F5</strong>. The debugger runs at full speed for the first 4,499 records and pauses <em>only</em> when that specific condition is met.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*ebqLnf6mR5g5CvS6TqsKnw.png" /></figure><h4>4.2. Logpoints (The “Clean” Print Statement)</h4><p><strong>The Scenario:</strong> You want to see a running feed of progress (e.g., “Processed User A… Processed User B…”) or check a value inside a loop, but you don’t want to stop the code every time.</p><ul><li><strong>The Problem:</strong> Adding print() statements means editing your file, re-saving, and remembering to delete them later.</li><li><strong>The Fix:</strong> Select <strong>Add Logpoint</strong>. Enter a message like Processing ID: {user_id}.</li><li><strong>The Result:</strong> As the code runs, it prints these messages to the <strong>Debug Console</strong> <em>without pausing execution</em> and without modifying your actual source code.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jqkVwO8h1pKrKa1hD4MokA.png" /></figure><h3>5. Debugging Interface</h3><h4>5.1. Command console</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eHBYkPaPUXsv140J_Liv_Q.png" /></figure><h4>5.2. Variables, Watch, Call Stack</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VLFphB1XffpPukvbVDuD4g.png" /></figure><h3>6. Putting It All Together</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K-3kfeyKMJHyUieVEt5PQQ.png" /></figure><ul><li>Set breakpoints</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jAF-AWjgDXu-gidWWpWqOg.png" /></figure><ul><li>Review Variables &amp; Watch panel</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BnxhDam5M6w1n0VIwSbGzQ.png" /></figure><ul><li>Review the Call Stack panel</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RuFaZhMNndbQTmrYjXUK1A.png" /></figure><ul><li>Use Debugger Console (advanced):</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5hyrZIqXj5WR3P_CmAnDOA.png" /></figure><h3>The Takeaway: Slow Down to Speed Up</h3><p>Switching from print() to the debugger requires a shift in mindset. At first, setting up a launch.json or configuring a Watch variable might feel slower than just typing print(x).</p><p>But think about the “Return on Investment.” The debugger doesn’t just show you what is wrong; it teaches you how your code actually works. It turns opaque errors into transparent logic.</p><p>The next time you are tempted to type print(&quot;HERE&quot;) or print(&quot;TEST&quot;), stop. Click the red dot, hit <strong>F5</strong>, and step into the code instead. Your future self and your clean, clutter-free git commits will thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39340a2b79fb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I learnt Bash Script from scratch with Gemini Guided Learning!]]></title>
            <link>https://medium.com/@alice_bui/i-learnt-bash-from-scratch-with-gemini-guided-learning-5da361f7503f?source=rss-5a1ff9131477------2</link>
            <guid isPermaLink="false">https://medium.com/p/5da361f7503f</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[google-gemini]]></category>
            <category><![CDATA[gemini]]></category>
            <dc:creator><![CDATA[Alice Bui]]></dc:creator>
            <pubDate>Thu, 09 Oct 2025 09:52:42 GMT</pubDate>
            <atom:updated>2025-10-09T10:43:11.748Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YeXTXVPNp23F3DdbtzwnMw.png" /></figure><h3>1️⃣Why Gemini Guided Learning?</h3><p>As an analytics engineer, I see Bash power every day, but the thought of starting from scratch is daunting. My main challenge isn’t a lack of information — the internet is flooded with guides and cheat sheets. My demand was more specific.</p><ul><li>First, I didn’t want to<strong> spend my limited learning time curating dozens of blog posts</strong>, trying to piece together a coherent curriculum.</li><li>Second, I was acutely aware of the <strong>“you don’t know what you don’t know” problem</strong>. A beginner’s tutorial might teach me the ls command, but would it tell me about common use cases of Bash?</li><li>Finally, <strong>reading isn’t the same as understanding</strong>. I needed a way to check my knowledge and apply concepts in real-time. Simply memorizing commands wasn’t enough!</li></ul><p>This is the exact niche that Gemini’s Guided Learning mode filled for me. Instead of being a passive repository of information, it became an active learning partner.</p><ul><li>✅It acts as <strong>a single, reliable place </strong>that could guide me <strong>from the fundamentals to more advanced topics seamlessly</strong>.</li><li>✅It can <strong>suggest the next logical topic to explore</strong>.</li><li>✅It helps me by <strong>asking me questions, challenging my assumptions, </strong>and confirming that I was truly grasping the material.</li></ul><h3>2️⃣How I learnt Bash with Gemini Guided Learning?</h3><h4><em>Exploring core concepts</em></h4><p>I get started by switching to Gemini Guided Learning mode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*7JkFU7Xi8JBVfMpC23cpOA.png" /></figure><p>.. and wrote a simple prompt:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*5qb1N2P4WaIYhWxOTRXnDA.png" /></figure><p>For every iteration, it either checked up on my understanding:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*NTJIVXlwosHoVaLrhdIMyw.png" /></figure><p>… or suggests me new topic:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*m3-jXpNUBctLiZHyF9MJdg.png" /></figure><h4>Learning by doing</h4><p>I asked Gemini to design a use case for me to apply what I’ve learned:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*_JBgjj5TslfVP26TyC1h0A.png" /></figure><h4>Some critical concerns</h4><p>I asked when I should Bash over Python. Gemini replied with a check-up question. This was great!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*AipNVGFhaC5hVTZIvc1m3w.png" /></figure><h4>Summarizing</h4><p>Now it’s time for a recap 🎉</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*OAvF4efGhARpUZXKDl0aOg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*KLNMfqom9WFkFIkXawI84g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*G-lXtKYAp2C6j82lMGBk8g.png" /></figure><h3>3️⃣Conclusion: My Tips for Guided Learning Journey</h3><p>For anyone looking to take a similar path, here are my key tips for making the most of learning with Gemini Guided Learning:</p><p><strong>1. Master the Fundamentals with the <em>Learn, Apply, Recap</em> Cycle:</strong></p><ul><li><strong>Learn</strong>: Ask it to explain core concepts with simple analogies.</li><li><strong>Apply</strong>: When you learn a new command, immediately follow up with, “Show me a real-world use case for this.”</li><li><strong>Recap</strong>: At the end of a learning session, ask it to “summarize everything we’ve covered” to help consolidate your knowledge.</li></ul><p><strong>2. Be Critical of Advanced Topics:</strong></p><p>As you venture into more complex topics, it’s crucial to verify the facts. While an AI is a fantastic learning accelerator, it’s not always true. By balancing guided exploration with critical thinking, you can transform your skills far more effectively than by just reading articles alone.</p><p>💛 Good luck on your growth journey!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5da361f7503f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is MCP? — An ELI5 Guide: MCP vs. RAG vs. Traditional APIs]]></title>
            <link>https://medium.com/@alice_bui/what-is-mcp-an-eli5-guide-mcp-vs-rag-vs-traditional-apis-b690b15a46b2?source=rss-5a1ff9131477------2</link>
            <guid isPermaLink="false">https://medium.com/p/b690b15a46b2</guid>
            <category><![CDATA[mcp-protocol]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Alice Bui]]></dc:creator>
            <pubDate>Wed, 03 Sep 2025 10:43:18 GMT</pubDate>
            <atom:updated>2025-09-23T07:24:51.368Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is MCP? — An ELI5 Guide: MCP vs. RAG vs. Traditional APIs</h3><h3>1️⃣What’s the problem MCP solves?</h3><h4>⭐️ What’s MCP by definition?</h4><ul><li>MCP is an open protocol that <strong>standardizes </strong>how applications <strong>provide context</strong> <strong>(from different data sources) </strong>to large language models (LLMs).</li><li>MCP enables developers to build secure, <strong>two-way connections</strong> between their data sources and AI-powered tools.</li></ul><p>BUT… you might wonder:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MKJJc2cu-_Oe84r9WkSpGw.png" /><figcaption>Image by the author</figcaption></figure><p>… So… Why do we need MCP? What’s the problem it solves? There must be reasons!</p><h4>⭐️ MCP vs RAG</h4><p>Retrieval-Augmented Generation (RAG) is a framework that enhances an LLM’s knowledge by retrieving specific information from external sources before generating an answer. Both RAG and MCP aim to reduce hallucinations and enrich LLMs with external data. However, there’s a key distinction:</p><ul><li>RAG’s Scope: RAG primarily focuses on retrieving data. It can find information, but is not designed for multi-step or complex actions.</li><li>MCP’s Scope: MCP enables AI agents to perform multi-step, complex actions and retrieve data. It’s a two-way street — the AI can not only get information but also act on it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4coMA_N0Kk7m8lT5bE_vFg.png" /><figcaption>Image by the author</figcaption></figure><p>Furthermore, RAG faces significant challenges with data management, particularly “chunking” and updating data in vector databases, which can be costly and labor-intensive to maintain.</p><p>MCP’s scope largely overlaps with RAG’s core purpose. If MCP gains widespread adoption, traditional RAG workflows could become obsolete or simply a component within MCP’s broader framework.</p><h4>⭐️ MCP vs Traditional API</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/0*j5_THCfnsla1Edub.jpg" /><figcaption>Source: Ailoitte</figcaption></figure><ul><li><strong>Traditional APIs </strong>rely on standard HTTP methods (GET, POST, PUT, DELETE) to perform different actions. Each request follows a rigid structure, requiring precise formatting of parameters. To add new features, you have to create new endpoints and update every application that uses the API, which often leads to versioning problems.</li><li>In contrast, <strong>MCP </strong>is a more flexible solution. It solves the issue of connecting many AI models to many tools by using a standard protocol that works with all systems, eliminating the need to build custom connectors for every single combination.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Jyht4fcYaB5yToLk.jpeg" /><figcaption>Source: <a href="https://medium.com/@poojanvig.pv?source=post_page---byline--202900c2782f---------------------------------------">Poojan Vig</a></figcaption></figure><ul><li><strong>MCP</strong> is built to handle context. It allows an AI to ask a memory server for only the most relevant information, which means the AI can access a huge long-term memory without flooding its limited context window.</li><li><strong>Traditional APIs</strong> are often stateless. To give an AI memory, you have to manually send the entire conversation history with every request. This is inefficient, expensive, and can quickly make the AI “forget” previous parts of a long conversation.</li></ul><h4>⭐️The core problem MCP solves</h4><p>In a nutshell, the Model Context Protocol (MCP) is designed to solve four key problems in AI development, transforming AI from a passive tool into a dynamic, active partner.</p><ul><li>💠<strong><em>Provide Context: </em></strong>MCP gives AI models access to real-time, structured data and resources.</li><li>💠<strong><em>Create Persistent Memory: </em></strong>MCP is a protocol that allows AI to create and access persistent, long-term memory via external memory servers.</li><li>💠<strong><em>Simplify Tool Integration:</em></strong> MCP provides a universal interface for all tools.</li><li>💠<strong><em>Enable Two-Way Interaction:</em></strong> MCP’s most significant achievement is enabling the AI to not only retrieve information but also to perform actions.</li></ul><h3>2️⃣MCP Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*mVF1N4OZTKh94q4k" /><figcaption>Source: Ailoitte</figcaption></figure><h4>⭐️MCP Servers</h4><ul><li>MCP servers are programs that expose specific capabilities to AI applications through standardized protocol interfaces. Each server provides focused functionality for a particular domain.</li><li>Common examples include file system servers for document management, email servers for message handling, travel servers for trip planning, and database servers for data queries. Each server brings domain-specific capabilities to the AI application.</li></ul><p><strong><em>Core Building Blocks:</em></strong></p><ul><li><strong>Tools</strong>: Tools enable AI models to perform actions through server-implemented functions. Each tool defines a specific operation with typed inputs and outputs. The model requests tool execution based on context. Real-world examples: search flights, send messages, create calendar events.</li><li><strong>Resources</strong>: Resources provide structured access to information that the host application can retrieve and provide to AI models as context. Real-world examples: file system servers, email servers, database servers.</li><li><strong>Prompts</strong>: Prompts provide reusable templates. They allow MCP server authors to provide parameterized prompts for a domain or showcase how to best use the MCP server. Real-world examples: ”Plan a vacation”, “Summarize my meetings”, “Draft an email”.</li></ul><h4>⭐️<strong>MCP Clients</strong></h4><p>MCP clients are instantiated by host applications to communicate with particular MCP servers. The host application, like Claude.ai or an IDE, manages the overall user experience and coordinates multiple clients. Each client handles one direct communication with one server.</p><h3>3️⃣Real-world MCP use cases</h3><ul><li><strong>Data Analytics:</strong> A user can create an analytics dashboard by simply typing questions like “Create me a dashboard about sales performance in 2025”. An MCP-powered AI agent interprets the natural language, translates it into a structured query, and fetches the real-time data to dynamically generate a dashboard.</li><li><strong>E-commerce:</strong> An AI manager handles a full e-commerce workflow, from taking an order to checking inventory levels in real-time, placing restock orders with suppliers, and then sending shipping notifications. All of these actions are coordinated through a single, seamless conversational interface.</li></ul><h3>Reference</h3><p>RAG vs MCP makes sense? is RAG dead?: <a href="https://medium.com/@gejing/rag-vs-mcp-makes-sense-is-rag-dead-134856664cd6">https://medium.com/@gejing/rag-vs-mcp-makes-sense-is-rag-dead-134856664cd6</a></p><p>MCP vs Traditional APIs: Real Performance Data You Need to See: <a href="https://www.ailoitte.com/insights/mcp-vs-traditional-api-connectors/">https://www.ailoitte.com/insights/mcp-vs-traditional-api-connectors/</a></p><p>MCP vs. API: Understanding the Differences and Use Cases: <a href="https://pub.towardsai.net/mcp-vs-api-understanding-the-differences-and-use-cases-202900c2782f">https://pub.towardsai.net/mcp-vs-api-understanding-the-differences-and-use-cases-202900c2782f</a></p><p>MCP Architecture Overview: <a href="https://modelcontextprotocol.io/docs/learn/architecture">https://modelcontextprotocol.io/docs/learn/architecture</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b690b15a46b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[dbt_project_evaluator: How to Evaluate Your dbt Project for Performance, Cost, and Scalability]]></title>
            <link>https://medium.com/refined-and-refactored/dbt-project-evaluator-how-to-evaluate-your-dbt-project-for-performance-cost-and-scalability-abdd496472e7?source=rss-5a1ff9131477------2</link>
            <guid isPermaLink="false">https://medium.com/p/abdd496472e7</guid>
            <category><![CDATA[dbt-labs]]></category>
            <category><![CDATA[dbt]]></category>
            <dc:creator><![CDATA[Alice Bui]]></dc:creator>
            <pubDate>Wed, 04 Jun 2025 08:51:14 GMT</pubDate>
            <atom:updated>2025-12-12T06:04:27.577Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6T01mq8ZTO9egTOy6Mn9TQ.png" /></figure><h3>Why does the dbt project need to be aligned with best practices?</h3><p><strong>As your dbt project grows,</strong> hidden issues can creep in — like slow models, unclear logic, and messy coding habits. These aren’t just small problems — they can lead to:</p><ul><li><strong>🚨 Slow Performance: </strong>Dashboards take too long to load, reports are outdated, and decisions get delayed. This directly impacts your organization’s ability to make timely, data-driven decisions.</li><li><strong>💸 Higher Costs: </strong>Every redundant join, unoptimized materialization, or untested model translates into unnecessary compute cycles. What seems like a minor query inefficiency on a small scale can quickly balloon into a significant monthly expense as data volumes grow, eating into your budget.</li><li><strong>🤔 Lower Data Trust: </strong>Inconsistent testing, undocumented assumptions, and a lack of robust data quality checks inevitably lead to errors in your data, making others doubt your data.</li><li><strong>📉 Hard to Scale: </strong>New team members struggle to understand the project. Without clear rules or structure, onboarding is slow, and bugs take longer to fix.</li></ul><p><strong>You may be well aware of these problems. But keeping up with every dbt best practice across development cycles is overwhelming.</strong> Guidelines are long, hard to track, and easy overlooked under tight deadlines.</p><p>That’s where the dbt_project_evaluator package bridges the gap. In this blog, I’ll walk you through <strong>how to use the </strong><strong>dbt_project_evaluator package effectively, what I’ve found particularly valuable about it, and where I think there’s still room to grow.</strong></p><h3>Why I Find dbt_project_evaluator Valuable</h3><p>What makes the dbt_project_evaluator package <strong>is truly valuable in automating critical checks</strong> across five key areas of any dbt project: <strong>Modelling, Testing, Documentation, Structure, and Performance</strong>. These aren&#39;t just checkboxes—they directly improve your team’s <strong>efficiency, scalability, and trust in the data</strong>.</p><ul><li><strong>Modelling</strong>: Enforces clean DAG structure and traceability from sources</li><li><strong>Testing</strong>: Ensures each model has a primary key test and meets test coverage thresholds</li><li><strong>Documentation</strong>: Flags missing model descriptions and tracks overall doc completeness</li><li><strong>Structure</strong>: Validates naming conventions and directory organization</li><li><strong>Performance</strong>: Surfaces inefficient materializations and overly long dependency chains</li></ul><p>These automated checks save hours of manual auditing while improving data quality and collaboration across the team.</p><p>Among all features, <strong>Modeling checks stand out most for me</strong>. They uncover deep, often-hidden issues that can silently drag down performance — like:</p><ul><li>Models with too many joins</li><li>Unnecessary re-joins of upstream logic</li><li>Overly broad fanout at the end of the DAG</li><li>Unused sources</li></ul><p><strong>In large projects, for example, a more-than-100-model project, spotting these manually is nearly impossible</strong> — this package does it for you. That’s what makes it a game-changer:</p><ul><li><strong>🔍 No More Manual DAG Reviews</strong>: It identifies unclear model relationships automatically, saving hours of eyeballing messy DAGs.</li><li><strong>💸 Time &amp; Cost Efficiency</strong>: By catching inefficiencies early, it reduces compute usage and helps cut cloud warehouse costs — especially as your data scales.</li></ul><h3>Room for Improvement: What Doesn&#39;t Cover (Yet)</h3><p>While dbt_project_evaluator provides powerful automation for structural and metadata checks, there are still some important areas it doesn’t cover:</p><h4>🚫 Current Limitations:</h4><ul><li><strong>SQL Query Quality</strong>: It doesn’t validate SQL against best practices like CTE usage, window functions, or performance-optimized logic.</li><li><strong>Upstream Transformation</strong>: The package can’t detect if basic transformations (e.g., renaming, casting) are happening in the upstream models, which creates repeated code.</li><li><strong>Model Overlap</strong>: There’s no built-in check for duplicated logic or overlapping transformation logic across multiple models.</li></ul><h4>🛠️ Workarounds &amp; Tips</h4><ul><li><strong>Manually Review 1 by 1</strong>: For critical models, continue to manually inspect logic and lineage to catch edge cases and transformation drift.</li><li><strong>Use AI Agents for SQL Reviews</strong>: Consolidate your internal <strong>SQL best practices</strong> into a shared document, and use an AI tool (like ChatGPT) to scan your dbt models and compare them against those guidelines to flag violations or risky patterns.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jhx56j0j8lXqZ7P-_nzqLQ.png" /><figcaption>Image by the author</figcaption></figure><p>Example prompt:</p><blockquote>“Here’s our dbt best practices. Compare it to this dbt model and point out any violations or anti-patterns.”</blockquote><p>This hybrid approach helps fill the gap while waiting for more advanced static analysis features to emerge in the dbt ecosystem.</p><h3>Try it out!<a href="https://docs.getdbt.com/blog/align-with-dbt-project-evaluator#try-it-out">​</a></h3><p>To try out the package in your project:</p><ul><li><strong>Install the package</strong>: Include the following in your packages.yml file:</li></ul><pre>packages:<br>  - package: dbt-labs/dbt_project_evaluator<br>    version: 1.0.0</pre><ul><li><strong>Run and test all of the models in the package</strong>: Execute a dbt build --select package:dbt_project_evaluator command.</li><li><strong>Identify any warnings</strong>: Each test warning indicates the presence of a type of misalignment.</li></ul><p>To add this package as a CI check:</p><ul><li>Override the severity of your tests using an environment variable.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*JRIIM7kQJBK4qqFuZgBOOg.png" /><figcaption>dbt Labs demo</figcaption></figure><ul><li>Run this package as a step in your CI job</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QxAIePFyXnXo8TSiHXhqtg.png" /><figcaption>dbt Labs demo</figcaption></figure><p><strong>💡 Stay in the loop.</strong> If you found this helpful, follow my blog for more deep dives into dbt and data best practices.</p><p><strong>Reference</strong>:</p><ul><li><a href="https://dbt-labs.github.io/dbt-project-evaluator/latest/rules/">https://dbt-labs.github.io/dbt-project-evaluator/latest/rules/</a></li><li><a href="https://github.com/dbt-labs/dbt-project-evaluator">https://github.com/dbt-labs/dbt-project-evaluator</a></li><li><a href="https://docs.getdbt.com/blog/align-with-dbt-project-evaluator">https://docs.getdbt.com/blog/align-with-dbt-project-evaluator</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abdd496472e7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/refined-and-refactored/dbt-project-evaluator-how-to-evaluate-your-dbt-project-for-performance-cost-and-scalability-abdd496472e7">dbt_project_evaluator: How to Evaluate Your dbt Project for Performance, Cost, and Scalability</a> was originally published in <a href="https://medium.com/refined-and-refactored">Joon Solutions</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Looker + Looker Studio: Key Changes, Feature Comparison & 2025 Roadmap]]></title>
            <link>https://medium.com/refined-and-refactored/looker-looker-studio-key-changes-feature-comparison-2025-roadmap-195bbce21e61?source=rss-5a1ff9131477------2</link>
            <guid isPermaLink="false">https://medium.com/p/195bbce21e61</guid>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[google-analytics]]></category>
            <category><![CDATA[google-looker-studio]]></category>
            <category><![CDATA[looker-studio]]></category>
            <category><![CDATA[looker]]></category>
            <dc:creator><![CDATA[Alice Bui]]></dc:creator>
            <pubDate>Thu, 13 Mar 2025 04:52:40 GMT</pubDate>
            <atom:updated>2025-12-12T06:04:46.373Z</atom:updated>
            <content:encoded><![CDATA[<h3>[Looker Newsletter] Looker + Looker Studio Unification: Key Changes, Feature Comparison &amp; 2025 Roadmap</h3><p>🚀 Welcome to the<strong> Looker Newsletter </strong>by<strong> Joon Solutions!</strong> Your go-to resource for <strong>business intelligence professionals</strong> and <strong>data teams</strong> looking to maximize Looker’s capabilities. With <strong>5+ years of experience</strong> in complex Looker projects — training developers, optimizing deployments, and implementing cutting-edge BI strategies — our team stays ahead of the latest updates.</p><p>🔥 What’s in this newsletter? <strong>New Features, Advanced Use Cases, Expert Tips! — 💡 Subscribe now </strong>to stay ahead of Looker updates<strong>!</strong></p><h3>I. The Core Concept: A Unified Looker Experience</h3><p>Looker and Looker Studio are separate BI tools owned by Google. They both have outstanding but distinctive strengths.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7oZSvUegZqrTPCA_wb6tvw.png" /><figcaption>Image by the author</figcaption></figure><p>🚀 The <strong><em>core concept </em></strong>of the Looker Unification initiative is to bring Looker Studio into the Looker core, <strong><em>combining the strengths of both platforms: governance &amp; visualization capabilities.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*guq40QtkExTLUhynCDmN3A.png" /><figcaption>Image by the author</figcaption></figure><p>With this shift, users now benefit from a Single Looker Offering!</p><h4><strong>1. Unified UI</strong></h4><p>🔹<strong>Single log-in and UI</strong> to access Reports (Looker Studio) &amp; Dashboards (Looker core) from your Looker instance</p><p>🔹 <strong>Accessing</strong> <strong>Reports (Looker Studio)</strong> will be available within your Looker instance, under the <strong>“Explore → Create Reports”</strong> button in the left sidebar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*mtHYWPPZ46XnTtcWLhUVsg.png" /><figcaption>Image by the author</figcaption></figure><p><strong>How Will Looker Unification Impact Your Current Reports &amp; Dashboards?</strong></p><p>🔹 <strong>No impact on your existing Looker content. </strong>All your current Dashboards, Looks, and Reports will continue to function as they do today. <strong>Looker Dashboards and Looker Studio Reports will remain independent.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8LZOPuZo9dcKWjVnpnFXKg.png" /><figcaption>Source: Google BICC</figcaption></figure><p>🔹 There is <strong>no direct migration or conversion tool</strong> between Looker Dashboards and Looker Studio Reports. Google has not announced any official plan, but updates may be introduced in the future.</p><h4><strong>2. Unified Capabilities</strong></h4><p>🔹System Activity, Permissions, Looker semantic layer, Gemini in Looker, etc. are unified in 1 single product.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*51C05zvG7DFFsT0m-mzOcg.png" /><figcaption>Image by the author</figcaption></figure><h4><strong>3. Unified Purchasing</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eVKOYi4ZIUbE5x6lepA-XQ.png" /><figcaption>Image by the author — <a href="https://cloud.google.com/looker/docs/studio/complimentary-looker-studio-pro-licenses-offer-details?visit_id=638780586853929508-118596323&amp;p=lsp4l-licenses&amp;rd=2">Reference</a></figcaption></figure><h3>II. Looker Dashboards vs. Looker Studio Reports: Which One to Choose?</h3><p>Looker remains <strong>neutral </strong>on whether users should fully migrate to one option over the other. Currently, they recommend <strong>leveraging both for different use cases</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z9iHdoNfa5uh8T3D3vwnsg.png" /><figcaption>Image by the author</figcaption></figure><p>The key reason is that each platform offers unique capabilities that the other lacks. As a result, Looker is waiting for users’ feedback to guide future decisions. As Looker Unification evolves, we’ll keep you updated on best practices!</p><h3>III. 2025 Roadmap Insights</h3><p>This is not an official statement from the Looker team; however, based on the 2025 roadmap, Looker Studio Reports are expected to<strong> receive significant analytics enhancements</strong>, leading us to believe it may <strong>become more feature-rich than Looker Dashboards.</strong></p><p>Additionally, governance improvements<strong> </strong>will <strong>align it more closely with Looker Core’s security and management standards</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*65Fe2Bzx9Q2AKnhJ-GtL9Q.png" /><figcaption>Studio in Looker 2025 Roadmap — Image by the author</figcaption></figure><p><em>Note: The private preview is now closed. The public preview is coming on 25th April, 2025.</em></p><p>🚀<strong> </strong>Stay ahead with Looker’s latest updates! <strong>Subscribe </strong>to our newsletter today! Got questions? <strong>Drop </strong>them in the <strong>comments!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=195bbce21e61" width="1" height="1" alt=""><hr><p><a href="https://medium.com/refined-and-refactored/looker-looker-studio-key-changes-feature-comparison-2025-roadmap-195bbce21e61">Looker + Looker Studio: Key Changes, Feature Comparison &amp; 2025 Roadmap</a> was originally published in <a href="https://medium.com/refined-and-refactored">Joon Solutions</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Looker Newsletter] Unlock AI-Powered Analytics: Using GenAI Capabilities in Looker]]></title>
            <link>https://medium.com/refined-and-refactored/looker-newsletter-unlock-ai-powered-analytics-using-genai-capabilities-in-looker-1bfccfb2a7f6?source=rss-5a1ff9131477------2</link>
            <guid isPermaLink="false">https://medium.com/p/1bfccfb2a7f6</guid>
            <category><![CDATA[google-analytics]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[looker-online-training]]></category>
            <category><![CDATA[looker]]></category>
            <dc:creator><![CDATA[Alice Bui]]></dc:creator>
            <pubDate>Thu, 16 Jan 2025 08:06:15 GMT</pubDate>
            <atom:updated>2025-03-12T04:11:08.937Z</atom:updated>
            <content:encoded><![CDATA[<p>Welcome to the <strong>Looker </strong>newsletter by Joon Solutions — your go-to resource for unlocking Looker’s full potential. Designed for businesses and analytics professionals using Looker, we’ll share advanced strategies to optimize performance, explore new use cases, and update you on the latest features.</p><p>At <strong>Joon Solutions</strong>, we’ve been <strong>handling both small and large</strong> <strong>Looker projects for 5+ years</strong>. Our team has worked on some of the most complex projects, trained countless new Looker developers, and helped companies maximize their Looker investments. With the pace of new features, especially GenAI updates, my fellow Joon Looker Veterans and I think it will be a great idea to have a newsletter on where we break down:</p><ul><li><strong>New Features</strong>: Practical tips and business implications of the latest releases.</li><li><strong>Innovative Use Cases</strong>: Advanced strategies to elevate your analytics.</li><li><strong>Expert Insights</strong>: Lessons, solutions from our real-world experience.</li></ul><p>Let’s take your Looker expertise to the next level!</p><h3>[Looker feature]</h3><h3>1. Gemini in Looker</h3><p>By embedding AI-driven assistance into Looker, Gemini enhances usability, productivity, and data accessibility across organizations. Key benefits include:</p><ul><li><strong>Enables non-technical users</strong> to extract maximum value from their data.</li><li><strong>Reduces the time</strong> required to transform data into actionable insights.</li></ul><p>Gemini in Looker provides AI assistance to help you in the following ways:</p><h4>1.1. Generate custom Looker visualizations in natural language</h4><ul><li>Gemini in Looker lets you customize formatting options for Looker visualizations using natural language. Gemini generates JSON formatting options from a text-based prompt, which you can apply to your visualization. You can also use prompts as a starting point for creating templates and patterns for more complex customizations, and then manually update the visualization’s formatting options.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kQ0MPOKfEYidjr8nXz2XfQ.png" /></figure><h4>1.2. Write LookML with Gemini assistance</h4><p>Generate LookML. Gemini in Looker assists you in generating LookML parameters. Based on a natural language prompt, Gemini suggests LookML parameters that you can add to your project files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tYyJxTt8aCSa8d1RNdetUA.png" /></figure><p>Note: These features are available in Looker (Google Cloud core).</p><h3>[Looker extension]</h3><h3>2. Looker Explore Assistant Extension</h3><h4>2.1. Who is the Explore Assistant for?</h4><p>This Explore Assistant is for you if:</p><ul><li>You need to make data-driven decisions efficiently but lack technical skills or familiarity with Looker. If you’re often waiting on reports or struggling with complex datasets, this tool lets you query data using natural language.</li><li>You’re short on data analysts to meet departmental demands and can’t provide Looker training for all users. This tool empowers non-technical users to explore data, reducing their workload and improving access to insights.</li></ul><h4>2.2. Key Features</h4><p>The Explore Assistant allows a user to generate a Looker Explore Query via natural language outputted into a visualization. As opposed to writing the raw SQL itself, the LLM is optimized to translate a text input into a Looker explore query. This is important as the LLM does what it’s great at, <strong>generative content</strong>, and Looker powers it with all the <strong>underlying data context, metadata and nuances</strong> that come with business data and analytics.</p><h4>2.3. What’s great about this extension?</h4><ul><li><strong>Data leakage prevention:</strong> Unlike traditional LLM-based solutions that may expose sensitive data to the LLM, the LLM simply takes 3 inputs: prompt, your LookML metadata, and pre-defined examples. None of your real data has to go through the LLM. This eliminates the risk of data leakage.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VbWKxCuefyFDozTylkgiqg.png" /></figure><ul><li><strong>Authentication verification:</strong> Before processing any prompt, the extension carefully verifies the user’s Looker permissions. It ensures that only authorized individuals with the necessary access rights can interact with the extension and access sensitive data.</li><li><strong>Cost-effective: </strong>Compared to traditional methods that require LLMs to scan through large datasets, the Looker Explore Assistant offers a more streamlined and cost-effective approach. The LLM only receives the essential information (your LookML metadata, pre-defined examples) needed to generate a response, significantly reducing the amount of data that needs to be processed.</li><li><strong>Scalable:</strong> The Looker Explore Assistant is designed to evolve with your data. As your data grows or the LookML models change, all you need is to update your LookML model or examples, and the assistant will automatically adjust its understanding.</li></ul><h4>2.4. How can we make it even better?</h4><p>There is huge room to refine and expand the capabilities of the Looker Explore Assistant extension since it’s open-source. Here are some promising ideas that we — Joon are developing:</p><ul><li><strong>Prompt History Storage: </strong>Expand the storage capacity for prompt history to accommodate monitoring purposes.</li><li><strong>Feedback Mechanism:</strong> Implement a feedback feature to gather user insights and suggestions for improvement.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H9i-Ok9PAfobJGAW8VJnGA.png" /><figcaption>Image by the author</figcaption></figure><ul><li><strong>Prompt Performance Monitoring:</strong> Track prompt performance metrics to identify areas for fine-tuning the models</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KTt2F5F6qQdxsVhHskekhQ.png" /></figure><h3>3. BigQuery ML Generator Extension</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*Wrt4j0Diw0PNqG9hrDZfig.png" /></figure><h4>3.1. Key Values</h4><ul><li>No complex AI architecture: This integration allows Looker users to <strong>create and train machine learning</strong> models <strong><em>directly within Looker</em></strong>. Users can send data directly from Looker to BigQuery ML, train machine learning models, and retrieve predictions <strong><em>without the need for separate data movement or complex setups.</em></strong></li><li><strong>Easy Model Creation</strong>: Select input features and choose the type of model you want to train.</li><li>Real-Time Predictions: Use the generated models to perform <strong>real-time predictions</strong> and include them in your dashboards.</li></ul><h4>3.2. Example Models</h4><ul><li><strong>Logistic Classification</strong>: Predicting the return status (is_returned) of orders.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DBmqutY3pNqPlGzOPl_eGw.png" /></figure><ul><li><strong>Linear Regression</strong>: Predicting net_sales.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VJLGhrGxodiCjUKDe1I2jQ.png" /></figure><h4>3.3. Ideation Questions for Your Business</h4><ul><li>Which team in your organization could benefit from predictive analytics or classification?</li><li>What datasets are readily available in your Looker instance that could feed into a BigQuery ML model?</li><li>How would the ML models impact decision-making in your teams?</li></ul><h4><strong>3.4. Open Source Repo</strong></h4><p><a href="https://github.com/looker-open-source/bqml-actions?tab=readme-ov-file#creating-bigquery-ml-models">GitHub — looker-open-source/bqml-actions: BigQuery ML Actions using Google Cloud Functions for Looker</a></p><p><a href="https://github.com/lucy-the-marketer/fortune-teller?tab=readme-ov-file">GitHub — lucy-the-marketer/fortune-teller</a></p><h3>4. Dashboard Summarization Extension</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*RzG8ryN62DrHZnRXl45LSw.png" /></figure><h4>4.1. Who is this extension for?</h4><ul><li>New Looker users navigating complex dashboards</li><li>Professionals preparing presentations under tight deadlines</li><li>Experienced Looker users seeking actionable insights</li></ul><h4>4.2. Key Features</h4><p>The Dashboard Summarization extension can be broken down into 3 parts:</p><ul><li>Summarization<strong>: </strong>Generates <strong>concise summaries on your dashboard’s data</strong></li><li>Prescription<strong>: </strong>Grounded in your dashboard’s data, it can <strong>prescribe operational actions</strong> and point out outliers</li><li>Action<strong>: </strong>Leveraging Looker’s API,<strong> insights can be shared into the business tools</strong> your organization uses</li></ul><h4>4.3. Ideation Questions for Your Business</h4><ul><li>What dashboards are most critical to your operations?</li><li>How would concise summaries enhance their utility?</li></ul><h4><strong>4.4. Open Source Repo</strong></h4><p><a href="https://github.com/looker-open-source/dashboard-summarization">looker-open-source/dashboard-summarization</a></p><p>Are you interested in AI-powered analytics?<strong> Subscribe Now</strong> to stay ahead with Joon’s expert insights! 🚀👏</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1bfccfb2a7f6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/refined-and-refactored/looker-newsletter-unlock-ai-powered-analytics-using-genai-capabilities-in-looker-1bfccfb2a7f6">[Looker Newsletter] Unlock AI-Powered Analytics: Using GenAI Capabilities in Looker</a> was originally published in <a href="https://medium.com/refined-and-refactored">Joon Solutions</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[API Requests in Python (P3): Working with nested JSON Data]]></title>
            <link>https://medium.com/refined-and-refactored/api-requests-in-python-p3-working-with-nested-json-data-8c447763430c?source=rss-5a1ff9131477------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c447763430c</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Alice Bui]]></dc:creator>
            <pubDate>Wed, 30 Oct 2024 09:46:00 GMT</pubDate>
            <atom:updated>2024-11-06T12:22:44.558Z</atom:updated>
            <content:encoded><![CDATA[<p>JSON is the most common format for API responses. You may often need to do the following tasks:</p><ul><li>Reading and writing JSON files: Handling JSON data stored locally or remotely.</li><li>Flattening nested JSON structures: Transforming complex hierarchical data into a tabular format for easier analysis and visualization.</li><li>Extracting specific data from JSON objects: Isolating relevant information from API responses, which often contain inconsistent structure and multiple nested levels.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vu8LUKZO1vSP34rdI-7SOg.png" /></figure><h3>1. Reading and writing JSON files</h3><ul><li>r is the reading mode, w is the writing mode</li><li>json.load : convert JSON file into a Python object</li><li>json.dump : serializes a Python object into a JSON string</li></ul><pre>Read data from &#39;data.json&#39; file<br>with open(&#39;data.json&#39;, &#39;r&#39;) as file: <br> data = json.load(file)<br><br># Write data into &#39;data.json&#39; file<br>with open(&#39;data.json&#39;, &#39;w&#39;, encoding=&#39;utf-8&#39;) as f:<br>    json.dump(data, f, ensure_ascii=False, indent=4)</pre><h3>2. Flattening nested JSON structures</h3><p>When working with nested JSON data that maintains a <strong><em>consistent structure</em></strong> across records, usingpd.json_normalize is an effective way to transform it into a data frame and save it to a CSV file for further analysis.</p><pre>data = [<br>...     {<br>...         &quot;state&quot;: &quot;Florida&quot;,<br>...         &quot;shortname&quot;: &quot;FL&quot;,<br>...         &quot;info&quot;: {&quot;governor&quot;: &quot;Rick Scott&quot;},<br>...         &quot;counties&quot;: [<br>...             {&quot;name&quot;: &quot;Dade&quot;, &quot;population&quot;: 12345},<br>...             {&quot;name&quot;: &quot;Broward&quot;, &quot;population&quot;: 40000},<br>...             {&quot;name&quot;: &quot;Palm Beach&quot;, &quot;population&quot;: 60000},<br>...         ],<br>...     },<br>...     {<br>...         &quot;state&quot;: &quot;Ohio&quot;,<br>...         &quot;shortname&quot;: &quot;OH&quot;,<br>...         &quot;info&quot;: {&quot;governor&quot;: &quot;John Kasich&quot;},<br>...         &quot;counties&quot;: [<br>...             {&quot;name&quot;: &quot;Summit&quot;, &quot;population&quot;: 1234},<br>...             {&quot;name&quot;: &quot;Cuyahoga&quot;, &quot;population&quot;: 1337},<br>...         ],<br>...     },<br>... ]<br>&gt;&gt;&gt; result = pd.json_normalize(<br>...     data, &quot;counties&quot;, [&quot;state&quot;, &quot;shortname&quot;, [&quot;info&quot;, &quot;governor&quot;]]<br>... )<br>&gt;&gt;&gt; result<br>         name  population    state shortname info.governor<br>0        Dade       12345   Florida    FL    Rick Scott<br>1     Broward       40000   Florida    FL    Rick Scott<br>2  Palm Beach       60000   Florida    FL    Rick Scott<br>3      Summit        1234   Ohio       OH    John Kasich<br>4    Cuyahoga        1337   Ohio       OH    John Kasich</pre><h3>3. Extracting specific data from JSON objects</h3><h4>3.1. Extract simple nested data</h4><p>If the JSON file has a consistent structure with few layers, you can parse the value with simple lines of code as follows:</p><pre>import json<br><br># Sample nested JSON data<br>nested_json_data = &#39;{&quot;name&quot;: &quot;John&quot;, &quot;age&quot;: 30, &quot;address&quot;: {&quot;city&quot;: &quot;New York&quot;, &quot;zipcode&quot;: &quot;10001&quot;}}&#39;<br><br># Parse JSON data<br>parsed_data = json.loads(nested_json_data)<br><br># Accessing nested values<br>name = parsed_data[&#39;name&#39;]<br>age = parsed_data[&#39;age&#39;]<br>city = parsed_data[&#39;address&#39;][&#39;city&#39;]<br>zipcode = parsed_data[&#39;address&#39;][&#39;zipcode&#39;]</pre><h4>3.2. Extract multi-level JSON using recursion</h4><p>For JSON data with <strong><em>inconsistent, multi-level structures</em></strong>, the recursive extract_values function offers a powerful solution to extract values based on a <strong><em>predefined list of keys</em></strong>. Please note that the keys have to be located at the same level within the nested data hierarchy.</p><pre>import pandas as pd<br>import json<br><br>def extract_values(obj, keys):<br>  &quot;&quot;&quot;<br>  Extracts values of multiple keys from a nested JSON structure.<br>  Args:<br>    obj: The nested JSON object.<br>    keys: A list of keys to extract.<br>  Returns:<br>    A dictionary mapping each key to a list of its corresponding values.<br>  &quot;&quot;&quot;<br>  def extract(obj, keys, results):<br>    if isinstance(obj, dict):<br>      for k, v in obj.items():<br>        if k in keys:<br>          results[k].append(v)<br>        if isinstance(v, (dict, list)):<br>          extract(v, keys, results)<br>    elif isinstance(obj, list):<br>      for item in obj:<br>        extract(item, keys, results)<br><br>  results = {key: [] for key in keys}<br>  extract(obj, keys, results)<br>  return results<br><br>json_data = data = [<br>        {<br>            &quot;models&quot;: [<br>                {&quot;model_id&quot;: &quot;model1&quot;, &quot;fields&quot;: [{&quot;field_name&quot;: &quot;field1&quot;}]},<br>                {&quot;model_id&quot;: &quot;model2&quot;, &quot;fields&quot;: [{&quot;field_name&quot;: &quot;field2&quot;}]}<br>            ]<br>        },<br>        {<br>            &quot;models&quot;: {<br>                &quot;dimensions&quot;: [<br>                    {&quot;model_id&quot;: &quot;model3&quot;, &quot;fields&quot;: [{&quot;field_name&quot;: &quot;field3&quot;}]},<br>                    {&quot;model_id&quot;: &quot;model4&quot;, &quot;fields&quot;: [{&quot;field_name&quot;: &quot;field4&quot;}]}<br>                ]<br>            }<br>        }<br>    ]<br><br>lookup_keys = [&#39;model_id&#39;, &#39;field_name&#39;]<br>output = []<br><br>output = extract_values(data, lookup_keys)<br>df = pd.DataFrame(output)<br><br>print(output)<br>print(df)</pre><h3>Wrap Up</h3><p>Hope you enjoyed this blog! For more insights, check out these related articles:</p><ul><li><a href="https://medium.com/@alice_bui/api-requests-in-python-p1-api-explained-with-a-restaurant-analogy-2b54d032eb4e">API Explained with a Restaurant Analogy</a></li><li><a href="https://medium.com/@alice_bui/api-requests-in-python-p2-requests-library-basic-to-advanced-topics-b292b0195bb7">API calls using requests Library — Basic to Advanced Topics</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c447763430c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/refined-and-refactored/api-requests-in-python-p3-working-with-nested-json-data-8c447763430c">API Requests in Python (P3): Working with nested JSON Data</a> was originally published in <a href="https://medium.com/refined-and-refactored">Joon Solutions</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[API Requests in Python (P2): requests Library — Basic to Advanced Topics]]></title>
            <link>https://medium.com/refined-and-refactored/api-requests-in-python-p2-requests-library-basic-to-advanced-topics-b292b0195bb7?source=rss-5a1ff9131477------2</link>
            <guid isPermaLink="false">https://medium.com/p/b292b0195bb7</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Alice Bui]]></dc:creator>
            <pubDate>Tue, 29 Oct 2024 10:32:07 GMT</pubDate>
            <atom:updated>2024-11-06T12:23:37.361Z</atom:updated>
            <content:encoded><![CDATA[<h3>API Requests in Python (P2): requests Library — Basic to Advanced Topics</h3><p>To place an order, you communicate your request to the waiter. You and the waiter must speak the same language to ensure smooth communication. Similarly, an API request is a message sent to a server in the digital realm. And you need to speak the same language with an API.</p><p>In this blog, we’ll delve into the language of making API requests: Python requests library. Python’s requests library is a powerful tool for making HTTP requests. It streamlines the process of sending and receiving data from websites.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ImnmcKgklIgVh0wEQI0PCA.png" /><figcaption>Source: brightdata</figcaption></figure><h3>I. Basic Topics</h3><h4>1. Send a GET Request</h4><p>In this GET request:</p><ul><li>Defined the API endpoint to retrieve data from.</li><li>Used the requests.get(url) method with params and headers to retrieve the data from the defined endpoint.</li><li>We used the response.json() method to store the response data in a dictionary object; note that this only works because the result is written in JSON format – an error would have been raised otherwise.</li><li>The last step is to print the JSON response data.</li></ul><pre>import requests<br><br># Define the API endpoint<br>url = &quot;https://api.example.com/items&quot;<br><br># Send a GET request<br><br>response = requests.get(<br>    &quot;https://api.github.com/search/repositories&quot;,<br>    params={&quot;q&quot;: &#39;&quot;real python&quot;&#39;},<br>    headers={&quot;Accept&quot;: &quot;application/vnd.github.text-match+json&quot;},<br>)<br><br># Convert the response to JSON format<br>items = response.json()<br><br># Use the data<br>for item in items:<br>    print(item)</pre><h4>2. Send a POST Request</h4><p>In this POST request:</p><ul><li>We use json.dumps to convert the task_data dictionary into a JSON-formatted string.</li><li>The requests.post(url) method sends the request, including the task data in the request body.</li><li>Using response.status_code to print the status code; a status code of 201 typically indicates successful resource creation</li></ul><pre>import requests<br>import json<br><br>base_url = &quot;https://api.exampletaskmanager.com&quot;<br>endpoint = &quot;/tasks&quot;<br>task_data = {<br>    &#39;title&#39;: &#39;Grocery Shopping&#39;,<br>    &#39;description&#39;: &#39;Buy milk, eggs, and bread&#39;<br>}<br><br>response = requests.post(base_url + endpoint, data=json.dumps(task_data))<br><br>if response.status_code == 201:<br>    print(&quot;Task created successfully:&quot;, response.json())<br>else:<br>    print(f&quot;Error: {response.status_code}&quot;)</pre><h3>II. Advanced Topics</h3><h4>1. Authenticating</h4><p>API security is a critical concern. To select the right API authentication method for you, you need to weigh the pros and cons and consider the needs of your organization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*nMpFG6I__rJ2QL9v.png" /><figcaption>Source: <a href="https://www.getknit.dev/blog/api-authentication-and-authorization-methods">getknit</a></figcaption></figure><p><strong>1.1. Add API Key, Bearer Token to headers</strong>:</p><ul><li>You can add an API key, Bearer Token to your HTTP requests by passing value to the headers parameter in your request.</li><li>Note: Keep API keys isolated from the main code and away from the public eye by storing them in environmental variables!</li></ul><pre>import requests<br><br>url = &quot;https://jsonplaceholder.typicode.com/posts&quot;<br><br>headers = {<br>    &quot;Authorization&quot;: &quot;YOUR_ACCESS_TOKEN/ YOUR_API_KEY&quot;,<br>}<br><br>response = requests.get(url, headers=headers)<br>print(response.json())</pre><p><strong>1.2. Basic Auth/ OAuth</strong>:</p><ul><li>Basic Authentication:</li></ul><pre>from requests.auth import HTTPBasicAuth<br>basic = HTTPBasicAuth(&#39;user&#39;, &#39;pass&#39;)<br>requests.get(&#39;https://httpbin.org/basic-auth/user/pass&#39;, auth=basic)<br>&lt;Response [200]&gt;</pre><ul><li>OAuth 1 Authentication:</li></ul><pre>import requests<br>from requests_oauthlib import OAuth1<br><br>url = &#39;https://api.twitter.com/1.1/account/verify_credentials.json&#39;<br>auth = OAuth1(&#39;YOUR_APP_KEY&#39;, &#39;YOUR_APP_SECRET&#39;,<br>              &#39;USER_OAUTH_TOKEN&#39;, &#39;USER_OAUTH_TOKEN_SECRET&#39;)<br><br>requests.get(url, auth=auth)<br>&lt;Response [200]&gt;</pre><h4>2. Using Session Objects</h4><p>Using a Session object in the requests module provides several benefits, including:</p><ul><li><strong>Persistent Connections:</strong> Maintains a connection across multiple requests, improving performance.</li><li><strong>Session-wide Settings:</strong> Allows you to set headers, cookies, and parameters once for all requests made through the session.</li><li><strong>Cookie Persistence:</strong> Automatically handles cookies, persisting them across requests.</li></ul><p>Here’s an example:</p><pre>import requests<br><br>session = requests.Session()<br>session.headers.update({&quot;Authorization&quot;: &quot;Bearer YOUR_ACCESS_TOKEN&quot;})<br><br>response = session.get(&quot;https://jsonplaceholder.typicode.com/posts&quot;)<br>print(response.json())</pre><h4>3. Handling Request Errors</h4><ul><li><strong>raise_for_status</strong>(): If an error occurs, this method returns an HTTPError object</li></ul><pre>url = &quot;https://www.gle.com&quot;<br>  <br># code <br>try: <br>    r = requests.get(url, timeout=1, verify=True) <br>    r.raise_for_status() <br>except requests.exceptions.HTTPError as errh: <br>    print(&quot;HTTP Error&quot;) <br>    print(errh.args[0]) <br>except requests.exceptions.ReadTimeout as errrt: <br>    print(&quot;Time out&quot;) <br>except requests.exceptions.ConnectionError as conerr: <br>    print(&quot;Connection error&quot;) <br>except requests.exceptions.RequestException as errex: <br>    print(&quot;Exception request&quot;) </pre><ul><li><strong>status_code()</strong>: Status code from the original response</li></ul><pre>import requests<br><br>response = requests.get(&quot;https://api.example.com/data&quot;)<br><br>if response.status_code == 200:<br>    print(&quot;Success!&quot;)<br>elif response.status_code == 404:<br>    print(&quot;Resource not found.&quot;)<br>elif response.status_code == 500:<br>    print(&quot;Server error.&quot;)<br>elif response.status_code == 401:<br>    print(&quot;Unauthorized. Authentication required.&quot;)<br>elif response.status_code == 403:<br>    print(&quot;Forbidden. Access denied.&quot;)<br>else:<br>    print(f&quot;Error: {response.status_code}&quot;)</pre><h3>Wrap up</h3><p>In this tutorial, we covered how we can use the Python requests library to make API requests. For more insights, check out these related articles:</p><ul><li><a href="https://medium.com/@alice_bui/api-requests-in-python-p1-api-explained-with-a-restaurant-analogy-2b54d032eb4e">API Explained with a Restaurant Analogy</a></li><li><a href="https://medium.com/@alice_bui/api-requests-in-python-p3-working-with-nested-json-data-8c447763430c">Working with nested JSON Data</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b292b0195bb7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/refined-and-refactored/api-requests-in-python-p2-requests-library-basic-to-advanced-topics-b292b0195bb7">API Requests in Python (P2): requests Library — Basic to Advanced Topics</a> was originally published in <a href="https://medium.com/refined-and-refactored">Joon Solutions</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>