<?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 Fabio Barbazza on Medium]]></title>
        <description><![CDATA[Stories by Fabio Barbazza on Medium]]></description>
        <link>https://medium.com/@fbarbazza?source=rss-3f6858a428f8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*JcX5dupsz-kYcdZs7vxb3w.jpeg</url>
            <title>Stories by Fabio Barbazza on Medium</title>
            <link>https://medium.com/@fbarbazza?source=rss-3f6858a428f8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 19:26:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@fbarbazza/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[mcp-adzuna: the MCP Server for Finding your next Job]]></title>
            <link>https://blog.dataengineerthings.org/mcp-adzuna-the-mcp-server-for-finding-your-next-job-d70d0dd8fce3?source=rss-3f6858a428f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/d70d0dd8fce3</guid>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[adzuna]]></category>
            <dc:creator><![CDATA[Fabio Barbazza]]></dc:creator>
            <pubDate>Tue, 11 Aug 2026 12:56:40 GMT</pubDate>
            <atom:updated>2026-08-11T12:56:40.743Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qX74680NTcjBLXyeePdRIw.png" /><figcaption>mcp server architecture</figcaption></figure><p><em>An MCP server that wraps Adzuna’s job search and salary APIs, built to be dropped into Claude Code or Claude Desktop as a reusable dependency.</em></p><p>Let’s face it: I already had Claude open in one tab and a job board in another, doing the same manual back-and-forth — copy a search, paste it, read the results, go back and refine. As a data engineer, that kind of repetitive bridging between two tools is exactly the itch I can’t leave alone. So I built <strong>mcp-adzuna</strong>: an MCP server that exposes Adzuna’s job search and salary analytics APIs as tools any MCP-compatible agent can call directly.</p><p>This post walks through:</p><ul><li>Where this server actually sits in the MCP protocol</li><li>What tools it exposes and why the API is split the way it is</li><li>How to wire it into Claude Code without cloning the repo</li><li>How it’s tested without needing real Adzuna credentials</li></ul><h3>The Architecture</h3><p>MCP defines three roles, and it’s worth being precise about which one this repo actually is. There’s a <strong>host</strong> app that embeds an LLM — Claude Code, Claude Desktop, or your own agent stack. Inside that host lives an <strong>MCP client</strong>, which speaks the wire protocol: tool discovery, tools/call, JSON-RPC framing. And then there&#39;s the <strong>MCP server</strong>, which exposes tools and responds to protocol messages without knowing or caring who&#39;s calling it.</p><p>mcp-adzuna is only that last piece:</p><pre>LLM decides to call a tool<br>        │<br>        ▼<br>Host app (Claude Code / Claude Desktop / your agent stack)<br>        │  spawns mcp-adzuna as a subprocess, speaks MCP over stdio<br>        ▼<br>MCP Client (built into the host)<br>        │  tools/call { name: &quot;search_jobs&quot;, arguments: {...} }<br>        ▼<br>MCP Server (server.py)<br>        │  dispatches to the matching tool function<br>        ▼<br>AdzunaAPI (client.py) → Adzuna&#39;s REST API</pre><p>So why does that matter? Because it means this repo is deliberately <strong>server-only</strong>. The client half of MCP is generic — it’s already provided by whatever hosts your agent — so there’s no reason to write a bespoke client per project. Point your host at this server instead.</p><h3>The Tools</h3><p>Once wired in, an agent gets seven tools to work with:</p><ul><li><strong>search_jobs</strong>: search job listings by keyword, location, salary, category</li><li><strong>list_categories</strong>: list job category tags (it-jobs, sales-jobs, etc.)</li><li><strong>salary_histogram</strong>: salary distribution for a search, as a histogram</li><li><strong>top_companies</strong>: top 5 employers by vacancy count for a search</li><li><strong>regional_data</strong>: vacancy counts per sub-region of a location</li><li><strong>historical_salary</strong>: average salary by month, over time</li><li><strong>api_version</strong>: current Adzuna API version — useful for a quick connectivity check</li></ul><p>[IMAGE: screenshot of Claude calling search_jobs and returning results]</p><h3>Keeping the Layers Apart</h3><p>Here’s a design decision I want to call out, because it’s easy to get wrong: server.py is the <em>only</em> file that speaks MCP. It owns the stdio loop, the tool registry, and turns docstrings and type hints into JSON schemas. Everything below it — client.py&#39;s AdzunaAPI — is a plain REST wrapper around Adzuna&#39;s HTTP API. It has no idea MCP exists.</p><p>I deliberately didn’t call it AdzunaClient. That name would collide with the &quot;MCP client&quot; role from the architecture above — this is a client of Adzuna&#39;s API in the ordinary SDK sense, like httpx.Client or boto3.client(...), not an MCP client.</p><p>Why go to the trouble of the split? Because it pays off twice: AdzunaAPI is independently testable against a mocked HTTP transport with zero MCP runtime involved, and it&#39;s independently reusable — you can import it in a plain script without dragging in any MCP dependency at all.</p><h3>Wiring It Into Claude Code</h3><p>The repo isn’t published to PyPI, so how do you actually use it from another project without cloning it? uv&#39;s uvx pulls it straight from GitHub:</p><pre>{<br>  &quot;mcpServers&quot;: {<br>    &quot;adzuna&quot;: {<br>      &quot;command&quot;: &quot;uvx&quot;,<br>      &quot;args&quot;: [&quot;--from&quot;, &quot;git+https://github.com/fabioba/mcp-adzuna.git&quot;, &quot;mcp-adzuna&quot;],<br>      &quot;env&quot;: {<br>        &quot;ADZUNA_APP_ID&quot;: &quot;your-app-id&quot;,<br>        &quot;ADZUNA_APP_KEY&quot;: &quot;your-app-key&quot;<br>      }<br>    }<br>  }<br>}</pre><p>Or from the Claude Code CLI directly:</p><pre>claude mcp add adzuna --env ADZUNA_APP_ID=your-app-id --env ADZUNA_APP_KEY=your-app-key \<br>  -- uvx --from git+https://github.com/fabioba/mcp-adzuna.git mcp-adzuna</pre><p>uvx fetches and caches the package on first run, and re-fetches whenever the pinned ref changes. Once there&#39;s a tagged release, pinning to it (@v0.1.0) means consuming repos won&#39;t silently pick up breaking changes.</p><p>[IMAGE: terminal screenshot of claude mcp add running]</p><h3>Testing Without Real Credentials</h3><p>Because AdzunaAPI doesn&#39;t know MCP exists, testing it doesn&#39;t require a running MCP server or real Adzuna credentials either. tests/test_client.py runs entirely against httpx.MockTransport:</p><pre>pip install -e &quot;.[dev]&quot;<br>pytest</pre><p>That’s the whole point of the split paying off again — fast, credential-free tests for the layer that actually does the HTTP work.</p><h3>Summary</h3><p>Building mcp-adzuna was less about the Adzuna API itself and more about getting the MCP boundary right:</p><ul><li>A server should only speak MCP where it has to — everything else stays a plain, testable API client</li><li>Server-only repos are more reusable than repos that also ship a bespoke client</li><li>uvx + a git URL is enough to consume an unpublished package from another repo</li><li>Mocking the HTTP layer means tests don’t need real credentials or a running protocol stack</li></ul><h3>Explore the Project</h3><p>Source, setup instructions, and the example client are all on <a href="https://github.com/fabioba/mcp-adzuna">GitHub</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d70d0dd8fce3" width="1" height="1" alt=""><hr><p><a href="https://blog.dataengineerthings.org/mcp-adzuna-the-mcp-server-for-finding-your-next-job-d70d0dd8fce3">mcp-adzuna: the MCP Server for Finding your next Job</a> was originally published in <a href="https://blog.dataengineerthings.org/">Data Engineer Things</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beyond the Search Bar: Building an AI Engine to Optimize Job Searching]]></title>
            <link>https://blog.devgenius.io/beyond-the-search-bar-building-an-ai-engine-to-optimize-job-searching-6538b4eedc6d?source=rss-3f6858a428f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/6538b4eedc6d</guid>
            <category><![CDATA[recruiting]]></category>
            <category><![CDATA[ollama]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[ai-assistant]]></category>
            <dc:creator><![CDATA[Fabio Barbazza]]></dc:creator>
            <pubDate>Tue, 14 Jul 2026 09:43:20 GMT</pubDate>
            <atom:updated>2026-07-16T13:56:06.026Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6r-mOuwq02uKpAbAkDisYg.png" /></figure><p>Let’s face it: navigating the job market can feel like a full-time job in itself. If you are a data professional, you have probably spent countless hours scrolling through endless job boards, reading descriptions that demand a laundry list of conflicting tools, and trying to gauge whether your actual skills align with what the team needs.</p><p>As data engineers, we are wired to look at repetitive, time-consuming tasks and think: <strong><em>how can we optimize this process?</em></strong></p><p>Instead of spending hours manually filtering through postings, I wanted a more data-driven approach to narrow the noise. So, I built <strong>My Personal Recruiter</strong>: a smart, privacy-first, <strong>AI-powered assistant</strong> designed to handle the heavy lifting of parsing, searching, and evaluation — saving me massive amounts of time while drastically improving the accuracy of my matches.</p><p><strong>Keep in mind:</strong> This setup is designed as a practical, hands-on example of how you can use <strong>LLMs</strong> to develop your own custom AI assistant. As a lightweight project, it certainly has its limits — most notably, running an open-source LLM locally means trading cloud speed for privacy, which can force you to wait several seconds for results to be processed. But as a PoC, it demonstrates exactly what’s possible with a bit of Python and curiosity.</p><h4>The Vision: AI-Driven Efficiency</h4><p>Usually, hunting for a job looks like a chaotic mess of open tabs, endless copy-pasted job descriptions, and blind guesswork. You try to calculate if your engineering background aligns with what a company wants, apply anyway, and hope for the best.</p><p>What if we engineered a better pipeline? What if an AI read your actual PDF resume, grabbed your natural language preferences (e.g., <em>“Find me a senior data role in Switzerland”</em>), evaluated open web roles against your actual skills, and gave you a curated, ranked scoreboard — all while keeping your data entirely on your local machine?</p><p>By letting a local model do the initial screening, you drastically reduce time spent reading irrelevant listings and dramatically increase the accuracy of where you choose to focus your energy.</p><h3>The System Architecture</h3><p>Before we look at any code, we must talk about architecture. As data engineers, we know a pipeline is only as good as its orchestration and performance optimization. To keep the user experience snappy, the application breaks away from purely sequential bottlenecks and relies on structured local inference.</p><pre>[ 1. Web UI ] ───(Submit Resume &amp; Prefs)───► [ 2. Flask Backend ]<br>     ▲                                                │<br>     │                                         (Parse PDF &amp; Fetch Jobs)<br>     │                                                ▼<br>     └───────◄─── (Stream Match Results) ─────── [ 3. Local Ollama ]</pre><h3>The Application in Action</h3><p>To see how this architecture translates to a real-world tool, here is the visual workflow. The interface is built as a clean, 3-step wizard that keeps the process completely intuitive:</p><h4><strong>Step 1: The Input Pipeline</strong></h4><p>This is where you feed the system your core data. You simply drag and drop your standard PDF resume and type out exactly what you are looking for in natural language. No rigid drop-downs or fixed tags required — the local LLM handles the unstructured text.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hiLs_1QsXB4M3d6K00l_IQ.png" /></figure><h4><strong>Step 2: Real-Time Monitoring</strong></h4><p>Because we are dealing with a local 3B parameter model, inference takes a few seconds per job posting. Instead of leaving the user guessing with a frozen loading spinner, the frontend uses Server-Sent Events (SSE) to stream active pipeline logs right to the screen. You can watch it extract text, execute the <strong>SerpAPI</strong> web search, and evaluate listings sequentially.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E10unVsTRk_ejY5Ur8cXfg.png" /></figure><h4><strong>Step 3: The Match Scoreboard</strong></h4><p>Once the evaluation loop completes, the system generates a clean summary of your parsed profile alongside the top 5 most accurate job matches found on the web. Each job card populates with a clear 0–100 match score and a bulleted AI reasoning breakdown explaining the exact skills alignment or location fit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iEdPx8UsUJnVepdpVN1wFA.png" /></figure><h3>Explore the Project</h3><p>If you want to spin up your own local career co-pilot, check out the source code, review the backend configuration, or contribute to the project over on GitHub:</p><p>👉 <a href="https://github.com/fabioba/my-personal-recruiter"><strong>GitHub Repository: my-personal-recruiter</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6538b4eedc6d" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/beyond-the-search-bar-building-an-ai-engine-to-optimize-job-searching-6538b4eedc6d">Beyond the Search Bar: Building an AI Engine to Optimize Job Searching</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Netflix Analytics (Homemade)]]></title>
            <link>https://blog.dataengineerthings.org/netflix-analytics-homemade-05642980db39?source=rss-3f6858a428f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/05642980db39</guid>
            <category><![CDATA[data-modeling]]></category>
            <category><![CDATA[tableau]]></category>
            <category><![CDATA[airflow]]></category>
            <category><![CDATA[netflix]]></category>
            <category><![CDATA[bigquery]]></category>
            <dc:creator><![CDATA[Fabio Barbazza]]></dc:creator>
            <pubDate>Mon, 20 Jan 2025 19:07:54 GMT</pubDate>
            <atom:updated>2025-01-24T17:22:27.853Z</atom:updated>
            <content:encoded><![CDATA[<h3>Netflix Movie Analytics (Homemade)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iXWQAYD-CjUxVCU6wMBl4Q.png" /><figcaption>Data Flow</figcaption></figure><p><strong>Netflix</strong> is my go-to streaming platform, where I’ve spent countless hours enjoying movies and TV shows. As a <strong>data engineer</strong> with a passion for storytelling, I wanted to combine my love for <strong>film</strong> with my skills in <strong>data analytics.</strong><br>This project dives into my personal <strong>Netflix</strong> viewing habits, answering questions like:</p><ul><li><em>What’s my most-watched movie genre?</em></li><li><em>Which day of the week do I stream the most?</em></li></ul><h3>Data Sources</h3><p><strong>Netflix</strong> provides users the ability to download data on their viewing activity. This export includes a CSV file with two columns:</p><ul><li><strong>Title</strong>: The name of the streamed content.</li><li><strong>Date</strong>: The date the content was streamed.</li></ul><p>While this dataset is limited, it’s a great starting point. I leveraged <strong>The Movie Database (TMDB)</strong> API to enrich it, a well-known source for detailed movie information. Using TMDB’s endpoints, I extracted additional attributes such as:</p><ul><li>Release date</li><li>Genres</li><li>Popularity</li><li>Average vote score</li></ul><p>For instance, querying the <strong>API</strong> with a movie title like <em>Ford v Ferrari</em> returned the following JSON snippet:</p><p><strong><em>https://api.themoviedb.org/3/search/movie?query=</em></strong><em>Ford+v.+Ferrari</em></p><p>The response is something like this:</p><pre>&#39;results&#39;: [{&#39;adult&#39;: False,<br>   &#39;backdrop_path&#39;: &#39;&#39;,<br>   &#39;genre_ids&#39;: [XXXX, YYYY, ZZZZ],<br>   &#39;id&#39;: XXXX,<br>   &#39;original_language&#39;: &#39;&#39;,<br>   &#39;original_title&#39;: &#39;Ford v Ferrari&#39;,<br>   &#39;overview&#39;: &#39;&#39;,<br>   &#39;popularity&#39;: XXXX,<br>   &#39;poster_path&#39;: &#39;&#39;,<br>   &#39;release_date&#39;: &#39;DATE&#39;,<br>   &#39;title&#39;: &#39;Ford v Ferrari&#39;,<br>   &#39;video&#39;: False,<br>   &#39;vote_average&#39;: XXXX,<br>   &#39;vote_count&#39;: XXXX<br>}]</pre><p>From these sources, I built the foundation for my analysis:</p><ul><li><strong>Netflix Streaming Data</strong>: Raw viewing activity.</li><li><strong>Enriched Movie Details</strong>: Additional attributes retrieved from TMDB.</li></ul><h3>Data Model</h3><p>The same movie can be streamed in different days. Moreover, one movie might be labeled with 1 or more genres (eg. drama, comedy).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*MWz3pzqXrb6EB1iQ2xAfNQ.png" /><figcaption>Physical Model</figcaption></figure><p>Here is how I decided to model the <strong>Netflix</strong> streaming.</p><p>So far, so good. But where to store the data?</p><h3>Data Storage</h3><p><a href="https://www.googleadservices.com/pagead/aclk?sa=L&amp;ai=DChcSEwju8tuijYCLAxXdnoMHHUmBGgMYABAAGgJlZg&amp;co=1&amp;ase=2&amp;gclid=Cj0KCQiAv628BhC2ARIsAIJIiK-uhS1ytveU_0ZKNcAG_iHbuLRQEQhdzPQRQMhMoVgVbcfN2MfWHucaAsHPEALw_wcB&amp;ei=Pg6MZ8jEEMW1i-gPvYfiiAg&amp;ohost=www.google.com&amp;cid=CAESV-D2XE6w4ttlWyUkaiYG7eOxcbYf5nfdMZpkVZMorMGTDfXiVC4fZhDNLZJDiEUYX5uj-v-bj2gNOk7p9HDOL1OUrW23dMQ3vGbWfThAwf9w_pUaLqTmQw&amp;sig=AOD64_34oy04IISJ51BiwUZEL6h8URvwgw&amp;q&amp;sqi=2&amp;nis=4&amp;adurl&amp;ved=2ahUKEwjI29aijYCLAxXF2gIHHb2DGIEQ0Qx6BAgIEAE"><strong>Google Cloud Platform</strong></a>(GCP) offers useful data services with a free tier subscription: thank you, Big G!</p><p>The first step (the <strong>Extraction</strong> step) is to upload the <strong>Netflix</strong> streaming CSV file to a <strong>bucket</strong> in <a href="https://cloud.google.com/storage">Google Cloud Storage</a> to store the raw data without any transformation.</p><p>The <strong>bucket</strong> used to store the raw data is also used to save the raw files from the <strong>TMBD API</strong>:</p><ul><li>raw movie details</li><li>raw movie genres</li></ul><p>Below I report the tree-folder structure of the <strong>GCP</strong> <strong>Bucket</strong> I used to store the raw data and move on to the hist folders once they were ingested in the <strong>data warehouse</strong>:</p><pre>netflix-analytics (bucket)<br>├── raw_movies/<br>├── raw_movie_details/<br>├── raw_genre_details/<br>├── hist_movies/<br>├── hist_movie_details/<br>└── hist_genre_details/</pre><p>Let’s move on to the next phase of the project: model raw data into a <strong>Star Schema </strong>in the <strong>Data Warehouse</strong> on <strong>GCP</strong>: <a href="https://cloud.google.com/bigquery">Google BigQuery</a>:</p><ul><li><strong>FCT_STREAMING</strong>: Tracks each streaming event (Title, Date).</li><li><strong>DIM_MOVIE</strong>: Contains movie details (Title, Release Date, TMDB ID).</li><li><strong>DIM_GENRE</strong>: Lists movie genres.</li><li><strong>BRIDGE_MOVIE_GENRE</strong>: Resolves the many-to-many relationship between movies and genres.</li></ul><p>The last point of the Data Model is to create a data layer that contains all the movie attributes: <strong>EL_STREAMING<em>.</em></strong></p><h3>Data Orchestrator</h3><blockquote>How to implement this long sequence of actions?</blockquote><p>I decided to work with <a href="https://www.astronomer.io/"><strong>Astronomer</strong></a> locally since it’s super easy to install and run an <a href="https://airflow.apache.org/"><strong>Airflow</strong></a> instance. More in detail, I created two dags with the two different goals:</p><ol><li><strong>dag_extract_load</strong></li></ol><ul><li>Extracted <strong>new data</strong> from <strong>Netflix CSVs</strong> and <strong>TMDB APIs</strong>.</li><li>Stored the <strong>raw data</strong> in an <strong>object storage</strong> (<strong>Data Lake</strong>)</li><li>Loaded the raw data in the <strong>data warehouse</strong></li></ul><p><strong>2. dag_transform</strong></p><ul><li>Applied transformations and queries on the <strong>data warehouse</strong> to populate the star schema.</li></ul><h3>Data Visualization</h3><p>Finally, I visualized the insights using <a href="https://public.tableau.com/app/profile/fabi5755/viz/NetflixAnalytics_17372167014910/Dashboard1#1"><strong>Tableau</strong></a>. The dashboard answered key questions:</p><ul><li><strong>Most Watched Genre</strong>: Drama.</li><li><strong>Favorite Day to Stream</strong>: Saturday.</li><li><strong>Total Movies Watched in 2024</strong>: 21 movies across 15 genres.</li><li><strong>Top Streaming Day</strong>: On September 21st, I watched parts of 10 different films!</li></ul><p>Below is a snapshot of the <a href="https://public.tableau.com/app/profile/fabi5755/viz/NetflixAnalytics_17372167014910/Dashboard1#1"><strong>Tableau</strong></a> dashboard:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7OSOHkopAeO7B-L5FYBOqA.png" /><figcaption><a href="https://public.tableau.com/app/profile/fabi5755/viz/NetflixAnalytics_17372167014910/Dashboard1#2">Netflix Analytics</a></figcaption></figure><h3>Summary</h3><p>This project blended creativity and technical skills, allowing me to explore my Netflix habits while honing my data engineering expertise. Key takeaways include:</p><ul><li><strong>Streaming patterns reveal personal habits and preferences</strong>.</li><li><strong>Enriching simple datasets with external APIs</strong> unlocks valuable insights.</li><li>Building a <strong>scalable data pipeline</strong> is achievable using modern cloud platforms and orchestration tools.</li></ul><h3>Links:</h3><ul><li><a href="https://github.com/fabioba/netflix-analytics"><strong>GitHub: Netflix Analytics</strong></a></li><li><a href="https://public.tableau.com/app/profile/fabi5755/viz/NetflixAnalytics_17372167014910/Dashboard1#1"><strong>Tableau: Netflix Analytics</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=05642980db39" width="1" height="1" alt=""><hr><p><a href="https://blog.dataengineerthings.org/netflix-analytics-homemade-05642980db39">Netflix Analytics (Homemade)</a> was originally published in <a href="https://blog.dataengineerthings.org/">Data Engineer Things</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A first glance at DBT (data build tool)]]></title>
            <link>https://fbarbazza.medium.com/a-first-glance-at-dbt-data-build-tool-517e4d96d590?source=rss-3f6858a428f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/517e4d96d590</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[analytics-engineering]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[dbt]]></category>
            <dc:creator><![CDATA[Fabio Barbazza]]></dc:creator>
            <pubDate>Wed, 02 Oct 2024 10:35:41 GMT</pubDate>
            <atom:updated>2024-10-02T10:35:41.272Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*l9UrHszIni8As8Bp" /><figcaption>Photo by <a href="https://unsplash.com/@r3dmax?utm_source=medium&amp;utm_medium=referral">Jonatan Pie</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>What is DBT?</h3><p>From the official documentation:</p><blockquote>dbt is a SQL-first transformation workflow that lets teams quickly and collaboratively deploy analytics code following software engineering best practices like modularity, portability, CI/CD, and documentation. Now anyone on the data team can safely contribute to production-grade data pipelines.</blockquote><p>In simpler terms, <strong>dbt</strong> allows data teams to transform raw data in their data warehouse using SQL and version-controlled code. With <strong>dbt</strong>, the entire transformation process happens within the data warehouse, making it accessible for anyone familiar with SQL to build robust, maintainable data pipelines.</p><p>A typical <strong>dbt</strong> project is structured to help you transform your data efficiently. For instance, dbt enforces the use of a top-level structure, including a dbt_project.yml file and directories for models, snapshots, and more. Inside these directories, you can organize your project according to the needs of your organization.</p><h3>Analytics Engineer vs Data Engineer vs Data Analyst</h3><p>In a data team, different roles work together but focus on distinct aspects of the data lifecycle:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*elnN4OmuSgH5OqWEb9MUkg.jpeg" /><figcaption>data professionals</figcaption></figure><ul><li><strong>Data engineers</strong>&#39; responsibilities include extracting and loading raw data from external sources into the data warehouse (<strong>EL</strong>T process) in addition to maintaining the data platform.</li><li><strong>Analytics Engineers </strong>focus on transforming this raw data within the warehouse, using <strong>dbt</strong> for modeling and ensuring the data is ready for analysis.</li><li><strong>Data Analysts</strong> visualize this transformed data through reports and dashboards, working closely with business stakeholders to provide insights.</li></ul><h4>Data Modeling</h4><p><strong>Data modeling</strong> refers to the process of transforming raw data into well-structured datasets that can be used for analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vWoUALWyuFVFdr57F7FEHQ.jpeg" /><figcaption>Data Modeling transformation</figcaption></figure><h3>Models</h3><p>To update data, <strong>dbt</strong> lets the developers execute the transformations through <a href="https://docs.getdbt.com/docs/build/models"><strong>models</strong></a>.</p><p>In <strong>dbt</strong>, a <strong>model</strong> is essentially a SQL SELECT statement that transforms raw data into a final dataset, which is materialized as either a table or a view in the data warehouse. Each model corresponds to a single file, and a project may contain multiple models that can reference each other.</p><p>For example, a simple model that aggregates customer orders might look like this:</p><p>From the documentation:</p><blockquote>A model is a single file containing a final select statement, and a project can have multiple models, and models can even reference each other. Add to that, numerous projects and the level of effort required for transforming complex data sets can improve drastically compared to older methods.</blockquote><p>Below the <strong>models/customer.sql </strong>:</p><pre>with customer_orders as (<br>    select<br>        customer_id,<br>        min(order_date) as first_order_date,<br>        max(order_date) as most_recent_order_date,<br>        count(order_id) as number_of_orders<br><br>    from jaffle_shop.orders<br><br>    group by 1<br>)<br><br>select<br>    customers.customer_id,<br>    customers.first_name,<br>    customers.last_name,<br>    customer_orders.first_order_date,<br>    customer_orders.most_recent_order_date,<br>    coalesce(customer_orders.number_of_orders, 0) as number_of_orders<br><br>from jaffle_shop.customers<br><br>left join customer_orders using (customer_id)</pre><p>When this model is executed with dbt run, it transforms into a view or table in the data warehouse. Below the SQL code <strong>dbt</strong> compiles and runs behind the scenes:</p><pre>create view dbt_alice.customers as (<br>    with customer_orders as (<br>        select<br>            customer_id,<br>            min(order_date) as first_order_date,<br>            max(order_date) as most_recent_order_date,<br>            count(order_id) as number_of_orders<br><br>        from jaffle_shop.orders<br><br>        group by 1<br>    )<br><br>    select<br>        customers.customer_id,<br>        customers.first_name,<br>        customers.last_name,<br>        customer_orders.first_order_date,<br>        customer_orders.most_recent_order_date,<br>        coalesce(customer_orders.number_of_orders, 0) as number_of_orders<br><br>    from jaffle_shop.customers<br><br>    left join customer_orders using (customer_id)<br>)</pre><h4>Configuring models</h4><p>Configurations are “model settings” that can be set either in the dbt_project.yml file or in every model file through theconfig block. A configuration block refers to:</p><ul><li>Change the <a href="https://docs.getdbt.com/terms/materialization"><strong>materialization</strong></a> that a model uses. More in detail, <a href="https://docs.getdbt.com/docs/build/materializations">materialization</a> determines the SQL that <strong>dbt</strong> uses to create the model in your warehouse. It’s how the data is represented, and each option is defined either canonically (tables, views, incremental) or bespoke.</li><li>Build models into separate <a href="https://docs.getdbt.com/docs/build/custom-schemas">schemas</a>.</li><li>Apply <a href="https://docs.getdbt.com/reference/resource-configs/tags">tags</a> to a model.</li></ul><p>Here’s an example of a model configuration named <strong>dbt_project.yml</strong>:</p><pre>name: jaffle_shop<br>config-version: 2<br>...<br><br>models:<br>  jaffle_shop: # this matches the `name:`` config<br>    +materialized: view # this applies to all models in the current project<br>    marts:<br>      +materialized: table # this applies to all models in the `marts/` directory<br>      marketing:<br>        +schema: marketing # this applies to all models in the `marts/marketing/`` directory</pre><p>On the other hand, it’s also possible to include the configuration directly into the <strong>models/customers.sql</strong> model:</p><pre>{{ config(<br>    materialized=&quot;view&quot;,<br>    schema=&quot;marketing&quot;<br>) }}<br><br>with customer_orders as ...</pre><p>Recently, dbt introduced <strong>Python models</strong> to update data with more complex transformations.</p><h4>Relationship between models</h4><p>If you want to create relationships between <strong>models</strong>, use the <strong>ref </strong>function in place of the name of the table</p><pre>   select * from {{ ref(&#39;stg_customers&#39;) }}</pre><p>That query will be compiled as follows:</p><pre>select * from analytics.stg_customers</pre><p>Moreover, <strong>dbt</strong> uses the <strong>ref</strong> function to:</p><ul><li><strong>determine the order to run the models by creating a dependent acyclic graph (DAG).</strong></li><li>Manage separate environments — <strong>dbt</strong> will replace the model specified in the ref function with the database name for the <a href="https://docs.getdbt.com/terms/table">table</a> (or view).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UoiR_Tge3_BCeb8cY2zHGA.png" /><figcaption>Dependencies dag</figcaption></figure><h3>Source</h3><p>One other option to refer to dependencies is the <strong>source</strong> function. The main difference between <strong>ref</strong> and <strong>source</strong> functions is explained in this <a href="https://stackoverflow.com/questions/73784913/dbt-ref-vs-source#:~:text=Using%20ref%20creates%20the%20lineage,everything%20else%20should%20use%20ref%20.">thread</a>:</p><blockquote>Using <strong>ref</strong> creates the lineage for your DAG and will run the predecessor models.</blockquote><blockquote>Using <strong>source</strong> references a raw table that exisst inside of the datawarehouse.</blockquote><p><strong>Sources make it possible to name and describe the data loaded into your warehouse by your Extract and Load tools.</strong></p><p>To define sources, create a <strong>.yml</strong> file in the <strong>models</strong> folder:</p><pre>version: 2<br><br>sources:<br>  - name: jaffle_shop<br>    database: raw  <br>    schema: jaffle_shop  <br>    tables:<br>      - name: orders<br>      - name: customers<br><br>  - name: stripe<br>    tables:<br>      - name: payments</pre><p>Then, use those <strong>sources</strong> in a model:</p><pre>select<br>  ...<br><br>from {{ source(&#39;jaffle_shop&#39;, &#39;orders&#39;) }}<br><br>left join {{ source(&#39;jaffle_shop&#39;, &#39;customers&#39;) }} using (customer_id)</pre><p>it will be compiled as follows:</p><pre>select<br>  ...<br><br>from raw.jaffle_shop.orders<br><br>left join raw.jaffle_shop.customers using (customer_id)</pre><p>In addition to that, sources can be updated regularly declaring the <strong>freshness</strong> block inside the .yml file:</p><pre>version: 2<br><br>sources:<br>  - name: jaffle_shop<br>    database: raw  <br>    schema: jaffle_shop  <br>    freshness: <br>      warn_after: {count: 12, period: hour}<br>      error_after: {count: 12, period: hour}<br>    # column name that returns a timestamp indicating freshness<br>    loaded_at_field: updated_timestamp <br><br><br>    tables:<br>      - name: orders<br>        freshness:<br>          warn_after: {count: 6 period: hour}<br>          error_after: {count: 12, period: hour}<br>      - name: customers<br><br>  - name: stripe<br>    tables:<br>      - name: payments</pre><p>This block is a sort of SLA with your organization about the frequency of source data updated.</p><h3>Tests</h3><blockquote>dbt allows developers to run data tests across your project data flows. This helps developers detect any issues before they occur in the production environment.</blockquote><p>There are two types of data tests:</p><ol><li><strong>singular</strong>: this type of test can be applied to very few specific models (either one or two models at most)</li><li><strong>generic</strong>: this type of test can be applied to almost all of the models of the project</li></ol><h4>Generic Tests</h4><p>More in detail, the generic tests are made of the following options:</p><ol><li><strong>unique</strong>: it checks unique values</li><li><strong>not_null</strong>: it checks of any NULL values</li><li><strong>accepted_values</strong>: it checks whether or not the column includes the specified values</li><li><strong>relationships</strong>: it checks that the values of one column are included in another table column</li></ol><p>To define <strong>generic tests</strong>, update the <strong>.yml</strong> file including the models:</p><pre>version: 2<br><br>models:<br>  - name: stg_customers<br>    columns: <br>      - name: customer_id<br>        tests:<br>          - unique<br>          - not_null<br><br>  - name: stg_orders<br>    columns:<br>      - name: order_id<br>        tests:<br>          - unique<br>          - not_null<br>      - name: status<br>        tests:<br>          - accepted_values:<br>              values:<br>                - completed<br>                - shipped<br>                - returned<br>                - return_pending<br>                - placed</pre><p>Finally, to run tests from the terminal:</p><pre>dbt test --select MODEL_NAME</pre><h4>Singular Tests</h4><p>Singular data tests are custom tests for specific data models. To define this type of test, create the query in the test folder: <strong>test/assert_positive_total_for_payment.sql</strong></p><pre>select<br>    order_id,<br>    sum(amount) as total_amount<br>from {{ ref(&#39;stg_stripe__payments&#39;) }}<br>group by 1<br>having total_amount &lt; 0</pre><p>The singular test should return records that do NOT match the assertion.</p><p>The following commands to run <strong>dbt</strong> tests:</p><ul><li>Execute dbt test to run all <strong>generic</strong> and <strong>singular</strong> tests in your project.</li><li>Execute dbt test --select test_type:generic to run only <strong>generic </strong>tests in your project.</li><li>Execute dbt test --select test_type:singular to run only <strong>singular </strong>tests in your project.</li></ul><p>Finally, it’s also possible to apply tests to <strong>sources by </strong>adding the <strong>tests</strong> block in the table source section<strong>:</strong></p><pre>version: 2<br><br>sources:<br>  - name: jaffle_shop<br>    database: raw<br>    schema: jaffle_shop<br>    tables:<br>      - name: customers<br>        columns:<br>          - name: id<br>            tests:<br>              - unique<br>              - not_null<br>            <br>      - name: orders<br>        columns:<br>          - name: id<br>            tests:<br>              - unique              <br>              - not_null<br>        loaded_at_field: _etl_loaded_at<br>        freshness:<br>          warn_after: {count: 12, period: hour}<br>          error_after: {count: 24, period: hour}</pre><h3>Documentation</h3><p><strong>dbt</strong> allows you to document your models and sources using descriptions in the .yml files. This ensures that your data pipeline is well-documented and easily understandable by team members:</p><pre><br>version: 2<br><br>models:<br>  - name: my_first_dbt_model<br>    description: &quot;A starter dbt model&quot;<br>    columns:<br>      - name: id<br>        description: &quot;The primary key for this table&quot;<br>        tests:<br>          - unique<br>          - not_null<br><br>  - name: my_second_dbt_model<br>    description: &quot;A starter dbt model&quot;<br>    columns:<br>      - name: id<br>        description: &quot;The primary key for this table&quot;<br>        tests:<br>          - unique<br>          - not_null</pre><h3>Conclusion</h3><p><strong>dbt</strong> is a game-changer for data teams. By enabling SQL-based data transformations that follow software engineering best practices, it simplifies the data pipeline process and ensures high-quality, production-ready data. Whether you’re an Analytics Engineer, Data Engineer, or Data Analyst, dbt provides powerful tools to manage your data pipeline with confidence and clarity.</p><h4>References</h4><ul><li><a href="https://www.getdbt.com/product/what-is-dbt">dbt</a></li><li><a href="https://docs.getdbt.com/docs/build/models">dbt models</a></li><li><a href="https://docs.getdbt.com/docs/build/projects">dbt projects</a></li><li><a href="https://docs.getdbt.com/docs/build/sources">dbt sources</a></li><li><a href="https://stackoverflow.com/questions/73784913/dbt-ref-vs-source#:~:text=Using%20ref%20creates%20the%20lineage,everything%20else%20should%20use%20ref%20.">dbt source vs dbt ref</a></li><li><a href="https://learn.getdbt.com/learn/course/dbt-fundamentals/tests-30min/building-tests?page=5">dbt test</a></li><li><a href="https://docs.getdbt.com/docs/build/documentation">dbt documentation</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=517e4d96d590" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Airflow DAGs must-have]]></title>
            <link>https://medium.com/apache-airflow/airflow-dags-must-have-81bcfbeec7aa?source=rss-3f6858a428f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/81bcfbeec7aa</guid>
            <category><![CDATA[analytics-engineering]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[airflow]]></category>
            <category><![CDATA[pytest]]></category>
            <dc:creator><![CDATA[Fabio Barbazza]]></dc:creator>
            <pubDate>Wed, 24 Apr 2024 11:33:13 GMT</pubDate>
            <atom:updated>2024-05-22T17:05:46.730Z</atom:updated>
            <content:encoded><![CDATA[<h3>Airflow check DAG must-have parameters</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*A-nbsRraPGQt01Ac" /><figcaption>Photo by <a href="https://unsplash.com/@morganhousel?utm_source=medium&amp;utm_medium=referral">Morgan Housel</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Would you trade X minutes of your time by including a single TEST in your pipeline? This is the starting point of this topic: saving time (and consequently money) is one side goal of each company.</p><h3>The Analytics Engineering department</h3><p>As an Analytics Engineer, how often did you forget to set up a<strong> must-have </strong>attribute in the new DAG just deployed? Do you have a list of which attributes each DAG should include?</p><p>Let’s start with a brief use case:</p><p>The Analytics Engineering department has a <strong>GCP</strong> project where to run <strong>Airflow</strong>. They are currently working on a new <strong>DAG</strong> that needs some <strong>.SQL</strong> files stored in an external folder on <strong>Cloud Storage</strong>.</p><p>What happens if they <strong>forget</strong> to set up the correct <strong>template_searchpath</strong>? This is an example of how including the <strong>DAG parameters Test</strong> can save them time.</p><h3>DAG parameters Test</h3><p>The image below represents a quick example of implementing this test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Vh6Xt9uOCtwwzSxN1dE8g.png" /></figure><p>The goal of this use case is to test if <strong>each DAG</strong>, which is extracted through the <a href="https://airflow.apache.org/docs/apache-airflow/stable/_api/airflow/models/dagbag/index.html#airflow.models.dagbag.DagBag">DagBag</a> class (it allows developers to extract the DAGs from a specific folder), contains the following parameters:</p><ul><li><strong>tags</strong></li><li><strong>schedule_interval</strong></li><li><strong>start_date</strong></li><li><strong>default_args</strong></li></ul><p>Finally, the type of test above can also be run locally through:</p><pre>pytest -v tests/dags/test_dag.py</pre><h3>Conclusion</h3><p>Finally, this test is helpful for those who want support in developing reliable code that relies on their memory and a set of rules. This leads to create standardized DAGs based on a pre-defined set of parameters.</p><p>From now on, let’s save more time!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81bcfbeec7aa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/apache-airflow/airflow-dags-must-have-81bcfbeec7aa">Airflow DAGs must-have</a> was originally published in <a href="https://medium.com/apache-airflow">Apache Airflow</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why should I log?]]></title>
            <link>https://blog.dataengineerthings.org/why-should-i-log-698afa5de416?source=rss-3f6858a428f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/698afa5de416</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[logging]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Fabio Barbazza]]></dc:creator>
            <pubDate>Wed, 27 Dec 2023 19:38:51 GMT</pubDate>
            <atom:updated>2024-02-14T15:42:15.575Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why Should I Log?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lffMzc76OtVD0Qko" /><figcaption>Photo by <a href="https://unsplash.com/@etiennegirardet?utm_source=medium&amp;utm_medium=referral">Etienne Girardet</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Let’s say that your current project is active in PROD and you need to monitor its execution.</p><p>Moreover, let’s also assume that one log message is a trunk</p><blockquote>How would you find it in a stack of thousands of similar pieces?</blockquote><p>What about labeling every type of trunk with a STATUS and appending a specific message? In this way, it would be easy to find the right one.</p><p>However, the most common question is:</p><blockquote>Should I not continue using print statements in all the modules of my application?</blockquote><p>Of course, you can. <br>Then, you can also avoid using <strong>git</strong> and rename every version of your file starting from: <em>test1.py, test11.py, …</em></p><h3>Reason to log</h3><p>It’s not about using one or another tool, it’s about <strong>standardizing the work</strong> over all the modules of the same project, or even better on each project.</p><p>Replacing print statements with logging gives the developers the ability to define standards throughout the entire application.</p><p>It’s fundamental to have a standard logging configuration in order to support both users and developers during the usage of the tool.</p><h3>Logging use case</h3><p>Let’s imagine that you’re the developer that has just fixed a bug. Unfortunately, the application raises some errors in the TEST stage and you need to find the root that causes the errors. Imagine debugging thousands of lines of code looking for the right print statement! In order to achieve the same result you should put the name of the file and the type of the print every single time.</p><p>Logging supports developers in monitoring the execution of the tool through easy-understanding messages:</p><pre>2005-03-19 15:10:26,620 - FILE_NAME - LEVEL - message</pre><p>From the documentation:</p><blockquote><a href="https://docs.python.org/3/library/logging.html">Logging module </a>defines functions and classes which implement a flexible event logging system for applications and libraries.</blockquote><blockquote>The key benefit of having the logging API provided by a standard library module is that all Python modules can participate in logging, so your application log can include your own messages integrated with messages from third-party modules.</blockquote><p>The easiest example:</p><pre>&gt;&gt;&gt; import logging<br>&gt;&gt;&gt; logging.warning(&#39;Watch out!&#39;)<br>WARNING:root:Watch out!</pre><p>The <strong>logging</strong> library is integrated in <strong>Python</strong>, so it’s easy to coordinate the logger of your project with others.</p><p>The basic classes defined by the module, together with their functions, are below:</p><ul><li><strong>Loggers</strong> expose the interface that application code directly uses.</li><li><strong>Handlers</strong> send the log records (created by loggers) to the appropriate destination.</li><li><strong>Filters</strong> provide a finer-grained facility for determining which log records to output.</li><li><strong>Formatters</strong> specify the layout of log records in the final output.</li></ul><h3>The Logger objects</h3><p>Note that <strong>Loggers</strong> should <em>NEVER</em> be instantiated directly, but always through the module-level function logging.getLogger(name). Multiple calls to <a href="https://docs.python.org/3/library/logging.html#logging.getLogger">getLogger(&#39;parent_folder.child_folder.file&#39;)</a> with the same name will always return a reference to the same Logger object. The name presented in that first example refers to the path to get to the Python module. On the other hand to avoid explicitly defining the path, just use the notation <strong>__name__ </strong>which refers to the module:</p><pre>import logging<br><br>logger = logging.get_logger(__name__)</pre><h3>Handlers</h3><p><strong>Handlers</strong> are those components that effectively write or store logs. Let’s assume that the current logging prints logging on the console, so there must be a <strong>StreamHandler</strong> that permits this behavior. It’s important to emphasize that the users can create as many Handlers as they need, each of them with custom Logging Levels and Formatters.</p><blockquote>Handlers send the log records (created by loggers) to the appropriate destination.</blockquote><pre>handlers:<br><br>  console:<br>    class: logging.StreamHandler<br>    level: DEBUG<br>    formatter: simple<br>    stream: ext://sys.stdout</pre><h3>Logging Levels</h3><p>The table below refers to the default logging levels, but you can also add your own level defining the position using the<strong> Numeric Value</strong>. So, <strong>DEBUG</strong> is less relevant than <strong>INFO</strong>, which is then less relevant than <strong>WARNING,</strong> and so on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Bya_insQYusli05RCE1Gg.png" /><figcaption>This table refers to the default logging levels</figcaption></figure><h3>Formatter</h3><blockquote>Formatters specify the layout of log records in the final output.</blockquote><pre>formatters:<br>  simple:<br>    format: &#39;%(asctime)s - %(name)s - %(levelname)s - %(message)s&#39;</pre><p>Eventually, the .yaml file below represents an example of the logging configuration file that might be ingested and used to depict the rules for the current project:</p><pre>version: 1<br><br>formatters:<br>  simple:<br>    format: &#39;%(asctime)s - %(name)s - %(levelname)s - %(message)s&#39;<br><br>handlers:<br><br>  console:<br>    class: logging.StreamHandler<br>    level: DEBUG<br>    formatter: simple<br>    stream: ext://sys.stdout<br>  <br>root:<br>  level: DEBUG<br>  handlers: [console]</pre><h3>Conclusion</h3><p>One of the hardest parts of using logging is using logging! Once you decide the string that an INFO message should print and the time that might be YYYY-MM-DD or YYYY-DD-MM it’s time to include the logging in every module. Replacing print statements with proper logging it’s essential to keep the entire set of projects consistent.</p><p>It does not matter which tool or standardization you will apply, the most important thing is that you will use log in your day-to-day job!</p><p>You will find out that logging can save you lots of time.</p><h4>References</h4><ul><li><a href="https://docs.python.org/3/library/logging.html">Logging</a></li><li><a href="https://docs.python.org/3/howto/logging.html">Simple Logging example</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=698afa5de416" width="1" height="1" alt=""><hr><p><a href="https://blog.dataengineerthings.org/why-should-i-log-698afa5de416">Why should I log?</a> was originally published in <a href="https://blog.dataengineerthings.org/">Data Engineer Things</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hooked by a Sea of (git)Thoughts]]></title>
            <link>https://blog.dataengineerthings.org/hooked-by-a-sea-of-git-thoughts-ab7ae3468abf?source=rss-3f6858a428f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab7ae3468abf</guid>
            <category><![CDATA[pre-commit]]></category>
            <category><![CDATA[hooks]]></category>
            <category><![CDATA[pre-commit-hook]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Fabio Barbazza]]></dc:creator>
            <pubDate>Tue, 28 Nov 2023 13:51:06 GMT</pubDate>
            <atom:updated>2023-11-30T21:36:44.786Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-3qWm8lzxZzJYLKF" /><figcaption>Photo by <a href="https://unsplash.com/@polarmermaid?utm_source=medium&amp;utm_medium=referral">Anne Nygård</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Being part of a data/software engineering team implies developing applications along with other developers with different coding styles. This may require having some best practices to facilitate maintenance and readability.</p><blockquote>How can I automatically check whether or not my code follows the best practices shared by the entire team? <a href="https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks">Git Hooks</a> can help you!</blockquote><h3>Git hooks</h3><blockquote>Git hooks are scripts that run automatically every time a particular event occurs in a Git repository.</blockquote><p>There are two types of these hooks:</p><ul><li><strong>client-side</strong> <strong>hooks</strong> are triggered by operations on the user machine (eg. commit, merging, …)</li><li><strong>server-side</strong> <strong>hooks</strong> are triggered by operations that occur on the network side (eg. receiving a pushed commit)</li></ul><p>Any git folder includes the hook subfolder which has a set of <strong>.sample</strong> files. These files are not active unless the user removes the <strong>.sample</strong> suffix.</p><p>Let’s talk a bit about the most used git hook: <strong>pre-commit</strong>. This hook is responsible for verifying the snapshot that is about to be committed. So, it might be used to check some syntax errors or code quality.</p><h3>pre-commit</h3><blockquote>Git hook scripts are useful for identifying simple issues before asking a code review by other developers. Most common hooks are triggered on every commit to automatically point out any issues, such as: missing semicolons, trailing whitespace, and debug statements.</blockquote><p><a href="https://pre-commit.com/"><strong>pre-commit</strong></a> is a multi-language package manager for pre-commit hooks. You specify a list of hooks you need and pre-commit manages the installation and execution of any hooks. Furthermore, <strong>pre-commit</strong> is specifically designed not to require root access.</p><p><a href="https://pre-commit.com/#install">To install the library</a>, from the console run the following command:</p><pre>pip install pre-commit</pre><p>Then, create at the root of the project the <strong>.pre-commit-config.yaml</strong> configuration file which includes the hooks that will be run:</p><pre>repos:<br>-   repo: https://github.com/pre-commit/pre-commit-hooks<br>    rev: v2.3.0<br>    hooks:<br>    -   id: check-yaml<br>-   repo: https://github.com/psf/black<br>    rev: 22.10.0<br>    hooks:<br>    -   id: black<br>- repo: https://github.com/astral-sh/ruff-pre-commit<br>  # Ruff version.<br>  rev: v0.1.4<br>  hooks:<br>    # run the ruff linter<br>    - id: ruff<br>    # run the ruff formatter<br>    - id: ruff-format</pre><p>After that, <strong>to set up the git hook scripts,</strong> from the terminal run:</p><pre>pre-commit install</pre><p>Every time the configuration file is updated, <em>it’s recommended to re-run the hooks manually</em> through:</p><pre>pre-commit run --all-files</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/579/1*iVgyD5X5RQSfxGj-kNOpUA.png" /><figcaption>This image refers to the output of: pre-commit run — all-files</figcaption></figure><h3>Ruff</h3><p><strong>ruff</strong> is a Python library that re-implements some of the most famous code quality tools such as <strong>black</strong> and <strong>flake8. </strong>It has become more and more popular in recent months because of its impressive fast execution and the vast features provided.</p><h3>Ruff config</h3><p>Let’s assume that the development team aims only to detect unused import libraries. To achieve this goal <strong>ruff</strong> allows creating a configuration file where to specify those requirements:<strong> </strong><strong>ruff.toml</strong></p><p>The example below excludes all those <strong>Python</strong> files that begin with OLD and the <strong>[lint]</strong> section includes only those anomalies to detect:</p><pre># Assume Python 3.8<br>target-version = &quot;py38&quot;<br><br># exclude all files that start with &quot;OLD_&quot;<br>extend-exclude = [&quot;OLD_*.py&quot;]<br>[lint]<br># Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`)  codes by default.<br># Unlike Flake8, Ruff doesn&#39;t enable pycodestyle warnings (`W`) or<br># McCabe complexity (`C901`) by default.<br>select = [&quot;F401&quot;]<br>ignore = []</pre><h4>Conclusion</h4><p>In conclusion, the <strong>pre-commit</strong> library supports most of the widely used linter and formatters (ruff, black, etc.) in order to help developers reduce the tons of commits without impacting the remote repo.</p><p>From the <strong>pre-commit</strong> documentation:</p><blockquote>By pointing these issues out before code review, this allows a code reviewer to focus on the architecture of a change while not wasting time with trivial style nitpicks.</blockquote><p>Finally, even though the <strong>pre-commit </strong>hook is the most popular one, it’s not the only one! Below a couple of others:</p><ul><li>the <strong>post-commit </strong>hook is usually used to notify after the commit process is completed</li><li>the <strong>pre-push </strong>hook runs during <strong>git</strong> push after the remote refs have been updated but before any objects have been transferred. It can be used to validate a set of ref updates before a push occurs</li></ul><h4>References</h4><ul><li><a href="https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks">Git Hooks</a></li><li><a href="https://www.atlassian.com/git/tutorials/git-hooks">Git Hooks lifecycle</a></li><li><a href="https://www.google.com/search?q=ruff+python&amp;sca_esv=579660944&amp;rlz=1C5CHFA_enIT1067IT1067&amp;sxsrf=AM9HkKlAnAsVYFGEzLiRQuRXGbJjmbA5og%3A1699217882824&amp;ei=2gFIZdD-MfmQxc8PlIGM4As&amp;ved=0ahUKEwjQ07Ty362CAxV5SPEDHZQAA7wQ4dUDCBA&amp;uact=5&amp;oq=ruff+python&amp;gs_lp=Egxnd3Mtd2l6LXNlcnAiC3J1ZmYgcHl0aG9uMgUQABiABDIIEAAYywEYgAQyCBAAGMsBGIAEMggQABjLARiABDIIEAAYywEYgAQyCBAAGMsBGIAEMggQABjLARiABDIIEAAYywEYgAQyCBAAGMsBGIAEMggQABjLARiABEiUD1ChAljNDXABeAGQAQCYAcYBoAHnCKoBAzAuN7gBA8gBAPgBAcICChAAGEcY1gQYsAPCAgwQABiKBRiwAxgKGEPCAhYQLhjHARjRAxiKBRjIAxiwAxhD2AEBwgIQEC4YigUYyAMYsAMYQ9gBAcICFhAuGIoFGMcBGK8BGMgDGLADGEPYAQHCAgoQABiABBgUGIcCwgILEAAYgAQYsQMYgwHCAgcQABiKBRhDwgIHEC4YigUYQ8ICCxAuGIAEGMcBGK8B4gMEGAAgQYgGAZAGDLoGBAgBGAg&amp;sclient=gws-wiz-serp">Ruff</a></li><li><a href="https://pre-commit.com/">Pre-commit</a></li><li><a href="https://docs.astral.sh/ruff/configuration/#__tabbed_1_2">ruff.toml configuration</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab7ae3468abf" width="1" height="1" alt=""><hr><p><a href="https://blog.dataengineerthings.org/hooked-by-a-sea-of-git-thoughts-ab7ae3468abf">Hooked by a Sea of (git)Thoughts</a> was originally published in <a href="https://blog.dataengineerthings.org/">Data Engineer Things</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Object Oriented Programming (OOP) for Data Scientists]]></title>
            <link>https://fbarbazza.medium.com/object-oriented-programming-oop-for-data-scientists-c8996c7651b5?source=rss-3f6858a428f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8996c7651b5</guid>
            <category><![CDATA[abstraction]]></category>
            <category><![CDATA[inheritance]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[oop]]></category>
            <category><![CDATA[polymorphism]]></category>
            <dc:creator><![CDATA[Fabio Barbazza]]></dc:creator>
            <pubDate>Fri, 27 Oct 2023 09:27:35 GMT</pubDate>
            <atom:updated>2024-10-03T19:39:44.305Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ELbCjNh3kZWm_dnf5RCb3Q@2x.jpeg" /><figcaption>Photo by Oskar Yildiz on Unsplash</figcaption></figure><p>Once upon a time, there was a bunch of data scientists investigating how to develop reusable modules for their <strong>Python</strong> legacy <strong>pipelines</strong>. <br>In detail, they were working on multiple data pipelines with a common architecture, so could they create and reuse the same template?</p><p>Since they had been working on those projects long ago before the advent of <a href="https://airflow.apache.org/">Airflow</a> and other <strong>pipeline orchestrators</strong>, they needed to find a valid alternative.</p><blockquote>How could they develop something reusable?</blockquote><p>Each pipeline is made up of a sequence of steps that share some properties (eg. all of them have a name). Moreover, the ML lifecycle may include both a training pipeline and a prediction pipeline which share some properties (eg. all of them have a list of steps).</p><p>To create something reusable let’s have a look at the properties below!</p><h3>Object Oriented Programming</h3><p>Some of the most misleading and evasive definitions are:</p><blockquote>- The combination of data and function.</blockquote><blockquote>- A way to model the real world.</blockquote><p><strong>Object Oriented Programming </strong>is a programming paradigm based on the concept of <em>objects</em>. <br><strong>Objects</strong> are made up of two important parts:</p><ul><li><strong>attributes</strong>: indicates the properties of the object</li><li><strong>methods</strong>: defines the behavior of the object</li></ul><p><strong>OOP</strong> is sometimes defined as the mixture of the following concepts:</p><ul><li><strong>Encapsulation</strong></li><li><strong>Polymorphism</strong></li><li><strong>Inheritance</strong></li><li><strong>Abstraction</strong></li></ul><p>Let’s dive deep into them!</p><h3>Encapsulation</h3><p>Encapsulation is a mechanism of wrapping variables and methods together as a single unit. In encapsulation, the variables of a class will be hidden from other classes and can be accessed only through the methods of their current class.</p><p>You may encounter the concept of <strong>protected</strong> members. In a class, a protected member is either a variable or method that is not accessible from outside itself. However, all the subclasses can access them.</p><p>Moving on to another concept: <strong>private </strong>members. In this case, those private methods and variables are not accessible from subclasses.</p><pre><br>class Base: <br>    def __init__(self): <br>        self.a = &quot;First Variable&quot;<br>        self._b= &quot;Second Variable&quot;<br>        self.__c = &quot;Third Variable&quot;<br>  <br># Creating a subclass <br>class Derived(Base): <br>    def __init__(self): <br>  <br>        # Calling constructor of the Base class <br>        Base.__init__(self) <br>        print(&quot;Calling private member of base class: &quot;) <br>        print(self._b)<br>        print(self.__c)<br><br>&quot;&quot;&quot;<br>Output:<br><br>Calling private member of base class: <br>Second Variable<br><br>AttributeError: &#39;Derived&#39; object has no attribute &#39;c&#39;<br><br>&quot;&quot;&quot;<br></pre><h3>Polymorphism</h3><p>Polymorphism refers to the ability of a named function to be declared with multiple forms. So, the same function can be declared with the same name but accepting different parameters. Then, at the execution time, the program will decide which function to pick up.</p><pre>len([&quot;test&quot;])<br>len(&quot;Python&quot;)<br>len({&quot;key_1&quot; : &quot;value_1&quot;, &quot;key_2&quot; : &quot;value_2&quot;})<br><br>&quot;&quot;&quot;<br>Output:<br><br>1<br>6<br>2<br>&quot;&quot;&quot;</pre><p>As you may see from the example above, the same function <strong><em>len </em></strong>has been invoked by passing different parameter types.</p><h3>Inheritance</h3><p>Inheritance is the ability to base a new class on another one, deriving all its properties and methods.</p><pre># superclass<br>class Person(object):<br><br>  def __init__(self, name):<br>    self.name = name<br> <br>  # To check if this person is an employee<br>  def display(self):<br>    print(&quot;name: {name}&quot;.format(name = self.name))<br><br><br>class Employee(Person):<br>   <br>  def print(self):<br>    print(&quot;Employee invoked&quot;)<br>     <br>employee_detail = Employee(&quot;Fabio&quot;)<br> <br># calling Person method<br>employee_detail.display()<br> <br># classing Employee method<br>employee_detail.print()<br><br>&quot;&quot;&quot;<br>Output:<br><br>name: fabio<br>Employee invoked<br>&quot;&quot;&quot;</pre><h3>Abstraction</h3><p>This property is fundamental to hide complexity from users. One of the most common examples regards the car: people can drive a car without knowing all the internal components. In accordance with this definition, abstract classes may contain abstract methods which refer to the structure of that method that will contain the implementation.</p><pre>from abc import ABC, abstractmethod<br><br>class Person(ABC):<br><br>  def __init__(self, name):<br>    self.name = name<br>   <br>  @abstractmethod<br>  def get_name(self):<br>    pass<br><br>class Employee(Person):<br>  def get_name(self):<br>    return self.name<br><br><br>employee = Employee(&quot;fabio&quot;)<br><br>employee_name = employee.get_name()<br><br>print(employee_name)<br><br>&quot;&quot;&quot;<br>Output:<br><br>fabio<br><br>&quot;&quot;&quot;</pre><p>In order to summarize all the OOP concepts presented above, the code below refers to an hypothetical manual Pipeline and Step structure. This is for sure not enough to develop an entire application from scratch, but it’s a starting point for newbie programmers 🤓.</p><p>Here below there’s an example of how a pipeline and a step abstract class can be created and inherited.</p><pre>from abc import ABC, abstractmethod<br><br>class Pipeline(ABC):<br><br>    @abstractmethod<br>    def __init__(self, name):<br>        pass<br><br>    @abstractmethod<br>    def run_pipeline(self):<br>        pass<br><br>class Step(ABC):<br><br>    @abstractmethod<br>    def __init__(self, name):<br>        pass<br><br>class TrainingPipeline(Pipeline):<br>  <br>    def __init__(self, name):<br>      self.name = name<br><br>    def run_pipeline(self):<br>        print(&quot;Run training pipeline...&quot;)<br><br>    <br>class TrainModelStep(Step):<br><br>    def __init__(self, name):<br>        self.name = name<br><br>    def train_model(self):<br>        print(&quot;Train a model...&quot;)<br><br><br><br><br><br>train_pipeline = TrainingPipeline(name = &quot;weekly_training_pipeline&quot;)<br>train_pipeline.run_pipeline()<br><br>train_model = TrainModelStep(name = &quot;weely_train_model_step&quot;)<br>train_model.train_model()<br><br><br><br>&quot;&quot;&quot;<br>Output:<br><br>Run training pipeline...<br>Train a model...<br>&quot;&quot;&quot;</pre><h4>References</h4><ul><li><a href="https://datagy.io/python-object-oriented-programming/">OOP with Python</a></li><li><a href="https://www.amazon.it/Clean-Architecture-Craftsmans-Software-Structure/dp/0134494164/ref=asc_df_0134494164/?tag=googshopit-21&amp;linkCode=df0&amp;hvadid=194982380299&amp;hvpos=&amp;hvnetw=g&amp;hvrand=279854433395862688&amp;hvpone=&amp;hvptwo=&amp;hvqmt=&amp;hvdev=c&amp;hvdvcmdl=&amp;hvlocint=&amp;hvlocphy=1008463&amp;hvtargid=pla-174178522330&amp;psc=1">Clean Architecture: A Craftsman’s Guide to Software Structure and Design</a></li><li><a href="https://www.freecodecamp.org/news/what-is-object-oriented-programming/">What is OOP?</a></li><li><a href="https://en.wikipedia.org/wiki/Object-oriented_programming">OOP (Wikipedia)</a></li><li><a href="https://www.tutorialspoint.com/what-is-encapsulation-in-python">Encapsulation</a></li><li><a href="https://www.geeksforgeeks.org/encapsulation-in-python/">Encapsulation (code)</a></li><li><a href="https://www.programiz.com/python-programming/polymorphism">Polymorphism</a></li><li><a href="https://www.geeksforgeeks.org/inheritance-in-python/">Inheritance</a></li><li><a href="https://www.scaler.com/topics/python/data-abstraction-in-python/">Abstraction</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8996c7651b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apache Airflow: Behind the Scene]]></title>
            <link>https://fbarbazza.medium.com/apache-airflow-behind-the-scene-fd9731164ff7?source=rss-3f6858a428f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd9731164ff7</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[airflow]]></category>
            <dc:creator><![CDATA[Fabio Barbazza]]></dc:creator>
            <pubDate>Thu, 28 Sep 2023 19:06:36 GMT</pubDate>
            <atom:updated>2024-03-28T20:16:55.869Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iPF_70zBWvdhV_G5Ft41Wg.png" /></figure><blockquote>In order to run a DAG, do you need to know how the Airflow skeleton is composed?</blockquote><blockquote>No.</blockquote><blockquote>Would you drive a car made by someone who does not know the reason of are so many wheels inside it?</blockquote><blockquote>There it is! I know you see where I’m heading.</blockquote><p><strong>Data Pipeline Orchestration</strong> is one of the hottest <strong>data engineering</strong> topics of the last few years.</p><p>Why did <strong>Data Pipeline Orchestrations</strong> become so famous among <strong>Data Engineers</strong>?</p><h3>Data Pipeline Orchestration</h3><p>Why should data engineers need a <strong>pipeline orchestrator</strong>? Can’t they just run the pipelines from a bash command?</p><p>But, before diving deep into the core concept, let’s explain briefly what a <strong>Data Pipeline</strong> is:</p><blockquote>A data pipeline is a sequence of steps with the aim of obtaining clean data. These steps usually starts with ingested data from the source and manipulating them towards the target storage.</blockquote><p>So, what happens when the data engineering team grows and needs to handle multiple data pipelines? Here comes to help: <strong>Data Pipeline Orchestration</strong></p><blockquote>Data Pipeline Orchestration is a solution that DataOps teams use to centralize the management and control of end-to-end data pipelines.</blockquote><p>Among all the advantages of using a <strong>Data Pipeline Orchestration,</strong> it’s impossible not to mention:</p><ul><li>the ability to monitor the execution of all the data pipelines</li><li>the ability to execute programmatically multiple data pipelines</li><li>including a standard template for developing data pipelines</li></ul><p>Eventually, what is <strong>Apache Airflow</strong>?</p><h3>Apache Airflow</h3><p>From the documentation:</p><blockquote><a href="https://airflow.apache.org/docs/apache-airflow/stable/index.html">Airflow</a> is an open-source platform for developing, scheduling, and monitoring batch-oriented workflows. Airflow’s extensible Python framework enables you to build workflows connecting with virtually any technology. A web interface helps manage the state of your workflows.</blockquote><p>In simple terms:</p><blockquote>Apache airflow is a platform to develop, schedule and monitor data workflows.<br>Monitoring data workflows is essential to detect which task may fail and debug to fix the issues.</blockquote><p>Before explaining the architecture of the components that made up Airflow, let’s summarise a few essential vocabularies about the tools:</p><ul><li><strong>DAG (Directed Acyclic Graph)</strong>: is the core concept of Airflow, collecting <strong>Tasks</strong> together, organized with dependencies and relationships to say how they should run</li><li>A<strong> Task</strong> is the most basic unit of execution. A sequence of multiple tasks defines a <strong>DAG</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/0*BwK_hwfy-HvVRtal.png" /><figcaption>The sequence of Tasks that composed a DAG</figcaption></figure><h3>What’s behind Airflow?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/0*nPpByyH3k9wfnsVD" /><figcaption>Airflow architecture</figcaption></figure><p>The core components behind the tool:</p><ul><li><strong>webserver</strong>: it’s the user interface of the data orchestrator platform. It allows developers to monitor, trigger, and debug data pipeline executions</li><li><strong>scheduler</strong>: it’s responsible for triggering scheduled DAGs and submitting tasks to the <strong>executor</strong> to run. More in detail, it essentially reads from the <strong>metadata</strong> <strong>database</strong> to check on the status of each task and decide what needs to get done and when.</li><li><strong>metadata database (metastore)</strong>: it includes all the metadata information about <strong>Airflow</strong></li><li><strong>executor</strong>: it is responsible for answering the question of <em>How are the tasks of the DAG performed? <br>T</em>here are two types of executors — those that run tasks <em>locally</em> (inside the scheduler process), and those that run their tasks <em>remotely</em> (usually via a pool of <em>workers</em>). <br>It works closely with the <strong>scheduler</strong> to determine what resources will actually complete those tasks (using a <strong>worker</strong> process or otherwise) as they&#39;re queued.</li><li><strong>worker</strong>: it is responsible of executing the tasks</li></ul><h3>Tasks Journey</h3><h4>How do those components interact with each other?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*vbNwPb3TpF4O6SPzPvXP0w.jpeg" /><figcaption>DAG execution on one single node</figcaption></figure><p>The <strong>Web server </strong>interacts with the <strong>Metastore</strong> to retrieve all the information about the DAG run. So, any information that you can retrieve from the UI comes from the <strong>Metastore</strong>.</p><p>Moving on to the <strong>Scheduler</strong>: if a task needs to be run, that component changes the status of that task in the <strong>Metastore</strong>. Then, the <strong>task instance</strong> is created and sent from the <strong>Scheduler</strong> into the <strong>Executor</strong>: into the Q<strong>ueue.</strong></p><p><strong>The Queue</strong> includes those tasks that will be fetched by the <strong>Worker</strong> and then executed. Finally, the <strong>Executor</strong> changes the status of the <strong>task instance</strong> and updates it on the <strong>Metastore</strong>.</p><p>Finally, the intent of this story is to provide a brief overview of how <strong>Airflow</strong> operates. The argument related to the architecture, which is treated in the second part, could support developers in understanding how to perform better <strong>DAG</strong> runs.</p><h4>Resources</h4><ul><li><a href="https://academy.astronomer.io/astronomer-certification-apache-airflow-fundamentals-preparation">Astronomer Certification: Apache Airflow Pre-Course</a></li><li><a href="https://streamsets.com/learn/data-pipelines/?gclid=CjwKCAjw44mlBhAQEiwAqP3eVp_UrcLE6jXsMqsdxt5JJVFDXCm1ofH9RDT7L0jo_fH8tQG1ZRyuuxoC1ioQAvD_BwE">Data Pipeline</a></li><li><a href="https://www.stonebranch.com/blog/what-is-a-data-pipeline#:~:text=Data%20Pipeline%20Orchestration%20is%20a,%2Dto%2Dend%20data%20pipelines.">Data Pipeline Orchestration</a></li><li><a href="https://airflow.apache.org/">Apache Airflow</a></li><li><a href="https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/overview.html">Airflow architecture</a></li><li><a href="https://docs.astronomer.io/learn/airflow-executors-explained">Airflow executor</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd9731164ff7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up a Python Environment (for non-tech people)]]></title>
            <link>https://python.plainenglish.io/setting-up-a-python-environment-for-non-tech-people-8399aa24c5a7?source=rss-3f6858a428f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/8399aa24c5a7</guid>
            <category><![CDATA[analyst]]></category>
            <category><![CDATA[virtual-environment]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[conda]]></category>
            <category><![CDATA[vscode]]></category>
            <dc:creator><![CDATA[Fabio Barbazza]]></dc:creator>
            <pubDate>Wed, 30 Aug 2023 18:30:45 GMT</pubDate>
            <atom:updated>2023-09-01T07:08:35.415Z</atom:updated>
            <content:encoded><![CDATA[<h3>Setting Up a Python Environment (for Non-Tech People)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L3-LHdOVmgTBQnk0yDgwUg.jpeg" /><figcaption>Isolated virtual environments</figcaption></figure><p>Let’s start this article by introducing this friend who works for a big bank in Zurich. <br>Ok, I know what you are thinking right now: working in a bank in one of the most livable cities in the world, where is the catch? Don’t rush, in a moment all the knots come home to roost.</p><p>Being part of the Finance department in a bank is far from being a free-stress job, especially if you need to manage large amounts of money for several clients.<br>Even though the work is challenging, he enjoys working with numbers and plots, as many of his colleagues do. Thanks to his ability with Excel colleagues have named him: <em>EXCELlence of Pivots</em>.</p><p>Suddenly one day his new boss stepped into the office and asked him to monitor the market on a daily basis and advise him of any anomalies. How could he do that?</p><p>Every day, my friend could monitor the market, save the result in an Excel file, and then send it to his boss. How many of you would like to do this manual job every single day???</p><p>Since the process looks so simple to automate, my suggestion to him was to use Python to perform that analysis. Then, as I expected he came to me with this question:</p><blockquote><strong><em>Where do I start?</em></strong></blockquote><p>This task is not so rare in a finance department and automating this type of manual operation can save loads of time and also avoid human errors. So, let’s try to answer this question by introducing a couple of concepts:</p><ul><li><strong>Virtual environment</strong></li><li><strong>Code Editor</strong></li></ul><h3>Virtual Environment</h3><p><strong>Python</strong> <strong>documentation </strong>includes the following definition for a Python environment:</p><blockquote>A cooperatively isolated runtime environment that allows Python users and applications to install and upgrade Python distribution packages without interfering with the behaviour of other Python applications running on the same system.</blockquote><p>Essentially, a <strong>Python</strong> virtual environment is a directory that contains a specific version of Python and other libraries.</p><p>Creating multiple Python environments on a laptop is essential when a developer needs to work on several projects each of them with different characteristics. Let’s explain this need with an example:</p><p>The developer M. worked on a new data science project whose main goal was to analyze a cluster of users to explain the main characteristics that differ from each group. <br>So, they install <strong>Python 3.11</strong> since it’s the latest version of the language, and a couple of libraries for analyzing the data such as <strong>Pandas 2.0.3</strong> and <strong>scikit-learn 0.2</strong>.</p><p>Finally, the outcome of the analysis was insightful and the stakeholders were happy.</p><p>Then, after a few days, their boss asked them to create a web app to expose the output of the analysis. Unfortunately, the latest <strong>Django</strong> release had conflicts with scikit-learn dependencies.</p><blockquote>How could they solve that?</blockquote><p>One solution to that problem is to create as many virtual environments as projects. So, it comes to help: <strong>Conda</strong>.</p><h3>Conda</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SRCZPj83JMI6yO3yOPh8Fw.png" /><figcaption>Conda Logo</figcaption></figure><p>From the <a href="https://conda.io/projects/conda/en/latest/index.html">documentation</a>:</p><blockquote>Conda is an open-source package management system and environment management system that runs on Windows, macOS, and Linux. Conda quickly installs, runs, and updates packages and their dependencies. Conda easily creates, saves, loads, and switches between environments on your local computer.</blockquote><h4>Conda Environment</h4><p>A <strong>conda environment</strong> is a directory that contains a specific collection of conda <strong>packages</strong> and a <strong>Python</strong> version.</p><p>To create a conda environment, from the terminal follow these steps:</p><pre>conda create -n myenv python=3.10 scipy=1.10.1</pre><p>Where <em>myenv</em> is the name of the environment and it’s also possible to specify the Python version 3.9 and a package to install (scipy=0.17.3).</p><p>After that, activate the environment to start working on it:</p><pre>conda activate myenv</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tMNLm9CaoAe5wryC3YdpNg.png" /><figcaption>(myenv) is the active environment</figcaption></figure><p>From this moment on, all the libraries installed through <strong>pip</strong> or <strong>conda</strong> will be installed in myenv environment and won’t be accessible from other virtual environments.</p><p>After completing the tasks on the project, deactivate the environment:</p><pre>conda deactivate</pre><h3>Where to code?</h3><p>Starting programming might be challenging not only for the action itself but for the choice to make. One of the most important choices, in the beginning, is picking up the right code editor.</p><p>In my view, <a href="https://code.visualstudio.com/">Visual Studio Code</a> is the best option for starting programming as newbies. Its user-friendly GUI allows programmers to not struggle so much to run their first <em>hello_world.py</em> script.</p><p>So, let’s start programming!</p><p>Before developing the first script, open a <strong>Terminal</strong> and activate the new conda environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_9VvxF-SaTL9BUkpgJLStg.png" /><figcaption>From the toolbar on the top, open: Terminal &gt; New Terminal</figcaption></figure><p>Then, from the terminal activate the <em>myenv</em> environment:</p><pre>conda activate myenv</pre><p>To check if the <em>myenv</em> environment is active, the developer can check whether or not the (myenv) label is at the beginning of the new line:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tMNLm9CaoAe5wryC3YdpNg.png" /><figcaption>(myenv) is the active environment</figcaption></figure><p>After activating the environment, create an <em>hello_world.py</em> script, and from the terminal execute it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4I6wjrxMe5dhv7V81xeHmA.png" /><figcaption>Execute hellow_world.py script inside myenv environment</figcaption></figure><h4>References</h4><ul><li><a href="https://docs.python.org/3/glossary.html#term-virtual-environment">Virtual Environment definition</a></li><li><a href="https://conda.io/projects/conda/en/latest/user-guide/concepts/environments.html">Conda environments</a></li></ul><h3>In Plain English</h3><p><em>Thank you for being a part of our community! Before you go:</em></p><ul><li><em>Be sure to </em><strong><em>clap</em></strong><em> and </em><strong><em>follow</em></strong><em> the writer! 👏</em></li><li><em>You can find even more content at </em><a href="https://plainenglish.io/"><strong><em>PlainEnglish.io</em></strong></a><strong><em> 🚀</em></strong></li><li><em>Sign up for our </em><a href="http://newsletter.plainenglish.io/"><strong><em>free weekly newsletter</em></strong></a><em>. 🗞️</em></li><li><em>Follow us on </em><a href="https://twitter.com/inPlainEngHQ"><strong><em>Twitter</em></strong></a><strong><em>(X</em></strong>), <a href="https://www.linkedin.com/company/inplainenglish/"><strong><em>LinkedIn</em></strong></a>, <a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong><em>YouTube</em></strong></a>, and <a href="https://discord.gg/GtDtUAvyhW"><strong><em>Discord</em></strong></a><strong><em>.</em></strong></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8399aa24c5a7" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/setting-up-a-python-environment-for-non-tech-people-8399aa24c5a7">Setting up a Python Environment (for non-tech people)</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>