<?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 Rajesh Ku. Rout on Medium]]></title>
        <description><![CDATA[Stories by Rajesh Ku. Rout on Medium]]></description>
        <link>https://medium.com/@routr5953?source=rss-2385f1e2ebc9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ZI7uz_DIbnl5kzkOUpHAew.jpeg</url>
            <title>Stories by Rajesh Ku. Rout on Medium</title>
            <link>https://medium.com/@routr5953?source=rss-2385f1e2ebc9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 11:23:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@routr5953/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[The Serverless Barrier: Why Your Data Quality Pipeline Crashes on Databricks Spark Connect]]></title>
            <link>https://medium.com/@routr5953/the-serverless-barrier-why-your-data-quality-pipeline-crashes-on-databricks-spark-connect-33d6cb0766fa?source=rss-2385f1e2ebc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/33d6cb0766fa</guid>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[apache-spark]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[data-quality]]></category>
            <dc:creator><![CDATA[Rajesh Ku. Rout]]></dc:creator>
            <pubDate>Mon, 13 Apr 2026 09:38:51 GMT</pubDate>
            <atom:updated>2026-04-13T09:38:51.788Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CT8MwdckuJfWuby__R80fw.png" /></figure><p>In the world of modern Data Engineering, we live and die by the “Bronze to Gold” pipeline. Data flows in, gets refined, and becomes the lifeblood of our Dashboards and AI models. But there is a silent guardian that determines if that data is an asset or a liability: <strong>Data Quality (DQ)</strong>.</p><p>For years, we’ve relied on robust frameworks to validate our data. Power users eventually find their way to <strong>Databricks Labs DQX</strong> — a high-performance, open-source library built by <strong>Databricks</strong> experts to handle complex validations at scale.</p><p>But then, the world shifted.</p><h3>The 2 AM Spark Connect Crisis</h3><p>The “Lakehouse” is moving toward <strong>Serverless Compute</strong> and <strong>Spark Connect</strong>. This is the future: faster, cheaper, and zero-infra. But there’s a catch.</p><p>Many DQ tools (and even DQX 0.12.0 out of the box) were built for a world where shared code had direct access to the JVM (Java Virtual Machine). On Spark Connect, that access is gone.</p><p>If you’ve ever tried to run a mature DQ pipeline on a Serverless cluster only to see your logs fill with AttributeError: &#39;_jvm&#39; not found or serialization failures in Python 3.10+, you’ve hit the <strong>Serverless Barrier</strong>.</p><p><strong>This is why we built DQ-Nitro.</strong></p><h3>DQ-Nitro: The Engine Rebuild for the Modern Lakehouse</h3><p>DQ-Nitro isn’t just another library. It’s an orchestration framework designed to bridge the gap between legacy Spark DQ and the future of Serverless compute.</p><h3>🚀 1. Solving the JVM Riddle (The Serverless Fix)</h3><p>The industry-standard Databricks Labs DQX is powerful, but it wasn’t originally designed for the restricted environments of Spark Connect.</p><ul><li><strong>The Fix</strong>: DQ-Nitro proactively “<strong>monkey-patches</strong>” internal serialization bugs and introduces a <strong>Pure PySpark Fallback Engine</strong>.</li><li><strong>The Result</strong>: When the framework detects a Serverless environment, it translates DQ rules into native PySpark expressions. You get the power of DQX validation without the JVM baggage. It just works.</li></ul><h3>🛡️ 2. Smart Quarantine: Beyond Pass/Fail</h3><p>Validated data is only half the battle. What happens to the “dirty” data? DQ-Nitro introduces a sophisticated <strong>Isolation Logic</strong> through a simple split_valid_invalid flag:</p><ul><li><strong>Isolation Mode</strong>: Failed records are shunted to a <strong>Quarantine Table</strong> with a complete JSON audit trail.</li><li><strong>Audit Mode</strong>: Keeps everything in one table but appends _errors and _warnings columns to every row, allowing you to track quality trends without breaking downstream pipelines.</li></ul><h3>🧩 3. Zero-Redeploy Custom Checks</h3><p>In most frameworks, a new business rule means a code change and a cluster restart. We’ve decoupled the rules from the engine. Add your custom Spark logic to a simple Python file, reference it in your YAML, and DQ-Nitro loads it dynamically at runtime. <strong>Zero redeployments. Zero downtime.</strong></p><h3>Turning Validation into Visibility</h3><p>You can’t manage what you can’t see. DQ-Nitro doesn’t just validate; it narrates. Along with the framework, we’ve included a <strong>SQL Insight Engine</strong> that provisions unified monitoring views in Unity Catalog.</p><p>This powers a <strong>13-KPI Dashboard</strong> that gives your business users a real-time trust gauge:</p><ul><li><strong>Anomaly Detection</strong>: Alerts you when quality drops 2 standard deviations below the mean.</li><li><strong>Table Health Cards</strong>: Instant Red/Amber/Green status for every dataset.</li><li><strong>SLA Tracking</strong>: Absolute visibility into the reliability of your data assets.</li></ul><h3>Conclusion: Data You Can Trust, Anywhere</h3><p>DQ-Nitro was born to solve the “last mile” of Data Quality — making it resilient enough for Serverless and flexible enough for the enterprise. Whether you are using DQX today or just looking for a way to stop “dirty” data from reaching your Gold layer, DQ-Nitro is the engine that keeps your pipeline moving.</p><p><strong>Ready to supercharge your Lakehouse? </strong><a href="https://github.com/rajeshrout97/DQ_Nitro.git"><strong>Check out the DQ-Nitro GitHub Repo here</strong></a></p><p><a href="https://github.com/rajeshrout97/DQ_Nitro">GitHub - rajeshrout97/DQ_Nitro: DQ-Nitro: A configuration-driven Data Quality framework for Databricks. Powered by DQX, it solves the &quot;Serverless Gap&quot; with a unique Pure PySpark engine for 100% Spark Connect compatibility. Features Smart Quarantine (Isolation vs Audit), dynamic custom checks, and a unified 13-KPI observability dashboard. Stop debugging, start validating!</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33d6cb0766fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Robust SendGrid Email Event Tracking Pipeline: A Deep Dive]]></title>
            <link>https://medium.com/@routr5953/building-a-robust-sendgrid-email-event-tracking-pipeline-a-deep-dive-f40cd4282ffb?source=rss-2385f1e2ebc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/f40cd4282ffb</guid>
            <category><![CDATA[scalable-data-pipeline]]></category>
            <category><![CDATA[apache-airflow]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[sendgrid]]></category>
            <category><![CDATA[email-tracking]]></category>
            <dc:creator><![CDATA[Rajesh Ku. Rout]]></dc:creator>
            <pubDate>Sun, 23 Mar 2025 16:25:39 GMT</pubDate>
            <atom:updated>2025-03-23T16:25:39.947Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pDuJb5QVvO3dERz9" /></figure><p>Ever wondered what it takes to track millions of emails flowing through your system? Grab a coffee, and let me take you through the journey of how we built a scalable, fault-tolerant data pipeline that processes massive amounts of email event data with precision and efficiency.</p><h3>The Challenge: Handling a Sea of Email Events</h3><p>Imagine monitoring an ocean of email activity — every email sent, opened, clicked, or bounced — flowing through SendGrid. The numbers were staggering: millions of events every hour, each containing valuable insights into customer engagement.</p><p>The stakes were high:</p><ul><li>Miss an event? We lose critical analytics on email campaign performance.</li><li>Process data too slowly? We fall behind real-time insights.</li><li>Hit API rate limits? Our data pipeline gets temporarily blocked.</li></ul><p>We needed a solution that was scalable, resilient, and adaptive — one that could dynamically adjust to fluctuating data volumes, handle API constraints, and recover gracefully from failures.</p><h3>The Roadblocks: Challenges We Faced</h3><p>As we dove deeper into building this system, we encountered several hurdles that made the task more complex:</p><h4>1. The Rate Limit Dance</h4><p>APIs like SendGrid enforce strict rate limits, allowing only a certain number of requests per second. If we exceed this, we get temporarily blocked — just like a bouncer stopping us at a club entrance when it’s at full capacity.</p><p>📌 <strong>The Challenge:</strong></p><ul><li>Exceeding rate limits results in blocked API requests.</li><li>Too many retries can worsen the issue.</li><li>Need a way to pace requests efficiently.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*FsoHyPyEaSGp_lnX" /></figure><h4>2. Unpredictable Data Volume</h4><p>Email traffic is not constant. Some periods flood us with events, while others trickle in slowly. A fixed time window for fetching data is inefficient — it’s like using the same bucket to collect both a light drizzle and a heavy downpour.</p><p>📌 <strong>The Challenge:</strong></p><ul><li>Fixed time intervals fail to adapt to data surges.</li><li>Either too much data is fetched, hitting API limits, or too little is captured, missing critical insights.</li><li>A more dynamic, volume-based approach is needed.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*jVkPARAf73-TeyMF" /></figure><h4>3. Network Failures &amp; Reliability Issues</h4><p>APIs sometimes fail — whether due to server timeouts, network disruptions, or internal errors. A simple retry isn’t enough; we need an intelligent mechanism that balances persistence with API stability.</p><p>📌 <strong>The Challenge:</strong></p><ul><li>API failures are unpredictable.</li><li>Too many retries can overload the API, making failures worse.</li><li>Need a smart retry system to handle failures gracefully.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*JsGAB-wyv_MWbqyE" /></figure><h3>Architecture Overview: End-to-End Orchestration with Apache Airflow</h3><p>To illustrate the seamless data flow and automation, the following architecture diagram shows how Apache Airflow orchestrates and monitors the entire process:</p><ul><li>Phase 1: Apache Airflow triggers a Python-based extraction process to fetch data from SendGrid and store it in Azure Blob Storage.</li><li>Phase 2: Airflow manages the movement of data from Blob Storage to Snowflake, where Snowpark processes and loads it into a RAW database.</li><li>Phase 3: Processed data is made available for reporting in Power BI, while automated alerts and updates are sent to Microsoft Teams.</li></ul><p>Throughout this pipeline, Apache Airflow ensures smooth scheduling, execution, and monitoring, making the automation efficient and reliable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wCLqFlGwAdzCcUpx" /></figure><p>This visual representation highlights how Airflow orchestrates every step, ensuring efficient execution and seamless integration across tools.</p><h3>The Solution: A Smart, Self-Adjusting Data Pipeline</h3><p>To overcome these challenges, we built an adaptive, scalable, and fault-tolerant pipeline using Python and Apache Airflow. Here’s how it works:</p><h4>1. Adaptive Time Windows for Efficient Data Retrieval</h4><p>Instead of using fixed intervals, our pipeline dynamically adjusts based on the data volume:</p><ul><li>Starts with a 30-minute window.</li><li>If 1000+ events are found, it shrinks to 10 minutes.</li><li>If needed, it can go down to 2-minute intervals.</li><li>If the number of records still exceeds 1000, the time window is further divided by 2 until the count falls below 1000.</li><li>As volume decreases, the window automatically expands back.</li></ul><p>This ensures that we capture all events without hitting API limits, optimizing efficiency.</p><h4>2. Intelligent Retry System for Reliability</h4><p>APIs aren’t always reliable, so we implemented an exponential backoff retry system:</p><ul><li>Starts with a short delay between retries.</li><li>Doubles the wait time after each failure.</li><li>Adds random jitter to prevent multiple retries from happening simultaneously.</li><li>Caps the delay to prevent excessive waiting.</li></ul><p>This approach prevents API overload while ensuring successful data retrieval.</p><h4>3. Azure Blob Storage Integration for Data Safety</h4><p>To make our pipeline resilient and recoverable, we stored all event data in Azure Blob Storage before further processing. This:</p><ul><li>Ensured no data loss even if an API request failed.</li><li>Used timestamp-based naming for easy tracking.</li><li>Allowed for parallel processing of stored data.</li></ul><h4>4. Real-Time Monitoring &amp; Alerts</h4><p>To stay on top of failures, we set up Microsoft Teams notifications, which provide:</p><ul><li>Detailed error messages.</li><li>Direct links to logs for troubleshooting.</li><li>Task-specific information with execution timestamps.</li></ul><p>This allows for quick issue resolution and minimizes downtime.</p><h3>The Outcome: From Chaos to Clarity</h3><p>With this approach, we transformed a potentially chaotic process into a smooth, reliable operation:</p><ul><li>✅ Processes millions of email events without missing a beat.</li><li>✅ Handles API rate limits intelligently.</li><li>✅ Recovers automatically from failures.</li><li>✅ Stores clean, structured data for downstream analytics in Snowflake.</li></ul><h3>Reusability: More Than Just an Email Pipeline</h3><p>Although we built this pipeline for SendGrid email events, its design is reusable for any high-volume API integration, including:</p><ul><li>IoT sensor data streams.</li><li>Social media data ingestion.</li><li>E-commerce transaction monitoring.</li></ul><p>The key patterns — adaptive time intervals, intelligent retries, and reliable storage — are universally applicable to many data engineering challenges.</p><h3>Key Technologies Used</h3><p>For those who love the technical nitty-gritty, here are the core components:</p><ul><li><a href="https://airflow.apache.org/">Apache Airflow</a> for workflow orchestration.</li><li><a href="https://www.python.org/downloads/">Python</a> for API interactions and data processing.</li><li><a href="https://azure.microsoft.com/en-us/products/storage/blobs">Azure Blob Storage</a> as a staging area.</li><li><a href="https://docs.snowflake.com/">Snowflake</a> for warehousing and analytics.</li><li><a href="https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook?tabs=newteams%2Cdotnet">Microsoft Teams Webhooks</a> for real-time monitoring.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TG6RZNs7julZ0WmC" /></figure><h3>Explore the Code: GitHub Repositories</h3><p>For those who want to dive into the implementation details, check out the GitHub repositories where we’ve open-sourced the core components of this pipeline:</p><p>🔹<strong> Airflow DAG for Orchestration </strong>— The complete DAG script handling scheduling, retries, and data flow. View on <a href="https://github.com/rajeshrout97/Airflow/tree/main/SendGrid"><strong>GitHub</strong></a></p><p>🔹<strong> Python Script for SendGrid API</strong> — The API integration logic, including adaptive time windows and intelligent retries. View on <a href="https://github.com/rajeshrout97/SendGrid"><strong>GitHub</strong></a></p><p>Feel free to explore, contribute, or raise questions! 🚀</p><h3>Lessons Learned</h3><p>Throughout this project, we gained valuable insights:</p><ol><li>Expect variable data volumes and build flexibility into your pipeline.</li><li>Design for resilience — failures are inevitable, but recovery should be seamless.</li><li>Monitor everything — visibility into failures helps resolve issues quickly.</li><li>Adaptability beats rigidity — fixed rules often fail in dynamic environments.</li><li>Plan for failures from the start — proactive strategies prevent data loss.</li></ol><h3>Looking Ahead</h3><p>This pipeline isn’t just about collecting email data — it’s a blueprint for handling high-volume, real-time API integrations with reliability and efficiency. Whether you’re dealing with email events, IoT sensor data, or social media feeds, the principles and patterns we used can help build robust, scalable solutions.</p><p>If you’re working with high-volume APIs, how do you handle rate limits, data variability, and failures? Let’s discuss in the comments!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f40cd4282ffb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unleashing the Power of Datasets in Airflow: Revolutionize Your DAG Scheduling]]></title>
            <link>https://medium.com/@routr5953/unleashing-the-power-of-datasets-in-airflow-revolutionize-your-dag-scheduling-d3f01b840bb9?source=rss-2385f1e2ebc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3f01b840bb9</guid>
            <category><![CDATA[airflow]]></category>
            <category><![CDATA[apache-airflow]]></category>
            <category><![CDATA[orchestration]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[scheduling]]></category>
            <dc:creator><![CDATA[Rajesh Ku. Rout]]></dc:creator>
            <pubDate>Thu, 12 Oct 2023 18:48:35 GMT</pubDate>
            <atom:updated>2023-10-16T14:14:43.064Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*va9mhz29e1QNbYUtjimH-g.png" /></figure><p>In the realm of modern data engineering, orchestrating intricate workflows seamlessly and efficiently is paramount. Apache Airflow, a stalwart in the field, has been empowering developers with its robust capabilities. Now, the introduction of datasets as a core feature brings an unprecedented level of reactivity and intelligence to your Directed Acyclic Graphs (DAGs). Imagine a world where your data pipelines adapt dynamically to changes in data availability or updates, minimizing unnecessary executions and maximizing resource utilization. Welcome to the era of using datasets in Airflow.</p><p>In this blog post, we embark on a journey to uncover the boundless potential of leveraging datasets in Airflow. We’ll explore the nuts and bolts of <strong>data-aware scheduling</strong>, configure dataset sensors, orchestrate DAGs, and unlock the true power of adaptive workflows. Prepare to elevate your data engineering endeavors as we dive into the realm of datasets, where your DAGs evolve from static routines into dynamic and responsive data engines. The link to the official <a href="https://airflow.apache.org/docs/apache-airflow/stable/authoring-and-scheduling/datasets.html#data-aware-scheduling">Airflow documentation</a> serves as a guiding beacon throughout this exciting exploration. Let’s revolutionize the way we schedule and trigger DAGs with datasets in Airflow.</p><h3>What is Data Aware Scheduling in Airflow?</h3><p>The game-changing aspect of datasets is their ability to trigger DAGs in response to changes. Imagine a scenario where you’re processing user logs, and a new <strong>log file</strong> becomes available. Traditionally, you might run your pipeline on a schedule, regardless of whether new data exists. With data-aware scheduling, your pipeline can be primed to execute only when the dataset — in this case, the new <strong>log file</strong> — is updated. This eliminates redundant processing, ensuring your computational resources are allocated optimally.</p><h4><strong><em>Let’s understand how Datasets can be useful ?</em></strong></h4><p>Datasets can help resolve common issues. For example, consider a data engineering team with a DAG that creates a dataset and an analytics team with a DAG that analyses the dataset. Using datasets, the data analytics DAG runs only when the data engineering team’s DAG publishes the dataset.</p><p>Datasets pave the way for advanced coordination among DAGs. By configuring DAGs to listen for changes in specific datasets, you can craft master DAGs that orchestrate the flow of tasks intelligently. When a producer task updates a dataset, the master DAG can trigger consumer DAGs that depend on this fresh data. This orchestrated handover ensures that tasks are executed only when prerequisites are met, fostering efficient data flow across your pipelines.</p><h3><strong>Understanding Datasets in Airflow</strong></h3><p>An Airflow dataset is a stand-in for a logical grouping of data. Datasets may be updated by upstream “<strong>producer</strong>” tasks, and dataset updates contribute to scheduling downstream “<strong>consumer</strong>” DAGs.</p><p>A dataset is defined by a <strong>Uniform Resource Identifier (URI)</strong>:</p><pre>from airflow.datasets import Dataset<br>&#39;&#39;&#39; s3://dataset-bucket/example.csv :- Path of the file which will be used for <br> scheduling. &#39;&#39;&#39;<br>example_dataset = Dataset(&quot;s3://dataset-bucket/example.csv&quot;)</pre><p>Airflow makes no assumptions about the content or location of the data represented by the URI. It is treated as a string, so any use of regular expressions (eg input_\d+.csv) or file glob patterns (eg input_2022*.csv) as an attempt to create multiple datasets from one declaration will not work.</p><p>We must pass the specific path of the file which you want to be modified, once the Parent DAG succeeded. If file doesn’t exist then it will create a new file at the same location you passed in the URI.</p><h3>Why use datasets?</h3><p>Datasets allow you to define explicit dependencies between DAGs and updates to your data. This helps you to:</p><ul><li>Standardize communication between teams. Datasets can function like an API to communicate when data in a specific location has been updated and is ready for use.</li><li>Reduce the amount of code necessary to implement <strong>cross-DAG dependencies</strong>. Even if your DAGs don’t depend on data updates, you can create a dependency that triggers a DAG after a task in another DAG updates a dataset.</li><li>Get better visibility into how your DAGs are connected and how they depend on data. The Datasets tab in the Airflow UI shows a graph of all dependencies between DAGs and datasets in your Airflow environment.</li><li>Reduce costs, because datasets do not use a worker slot in contrast to sensors or other implementations of cross-DAG dependencies.</li></ul><h3><strong><em>Putting Theory into Practice: Step-by-Step Implementation</em></strong></h3><p><strong><em>Follow below steps to schedule your DAG using Datasets.</em></strong></p><p>If you have not yet installed Airflow on your Windows computer, <a href="https://blog.devgenius.io/installing-airflow-on-windows-without-docker-in-5-mins-21d16091ebc5">click this link</a> to follow the instructions and connect to an instance of Airflow using the Visual Studio code provided below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D8prCDFz4kHM84JHyMgewQ.png" /><figcaption>Connected to Ubuntu using remote server</figcaption></figure><ol><li><strong>Lets create our first DAG — </strong>parent_dataset_dag<strong><em> </em>under DAG folder</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*QUf1R0snzE9k9gjLcjvlmQ.png" /><figcaption>Create <strong>parent_dataset_dag.py</strong> file</figcaption></figure><p>I have a source file<strong><em> </em></strong>source_file.txt at path<strong><em> “/home/raj/airflow”. </em></strong>We can mention any file as per our use case.</p><blockquote><strong>Example:-<em> </em></strong>If the purpose of your parent DAG is to retrieve data from the APIs, you can write the data down and include the file’s location in the URI so that, once the file is edited, the child DAGs can be triggered.</blockquote><p><strong>2. Copy below code in </strong>parent_dataset_dag.py<strong><em> </em>file</strong></p><pre>from airflow import Dataset, DAG, task<br>from datetime import datetime, timedelta<br>import requests<br><br># Variable to store the source file path. We can use Variables or secret variables to store the location of the file for more security.<br>my_file = Dataset(&#39;/home/raj/airflow/source_file.txt&#39;)<br><br>default_args = {<br>    &#39;owner&#39;:&#39;Rajesh&#39;,<br>    &#39;retries&#39;: 1,<br>    &#39;start_date&#39;:datetime(2023, 1, 2),<br>    &#39;email&#39;: &#39;routr5953@gmail.com&#39;,<br>    &#39;email_on_failure &#39;: False,<br>    <br>}<br><br>with DAG(<br>    &#39;Parent Dataset DAG&#39;,<br>    default_args=default_args,<br>    description=&#39;Parent DAG for Datasets&#39;,<br>    schedule_interval=None,<br>    tags=[&#39;Datasets&#39;],<br>) as dag:<br>    <br>    @task<br>    def print_task():<br>        print(&#39;This is my first task&#39;)<br><br>&#39;&#39;&#39;  OUTLETS -  This parameter is passed to indicate that this <br>     task will update the Dataset once completed.<br>&#39;&#39;&#39;<br>    @task(outlets = [my_file])   <br>    def get_data_from_api():<br>        url = &#39;https://api.publicapis.org/entries&#39;  # public API<br><br>        response = requests.get(url).json()   <br><br>        with open(my_file.uri, &quot;a+&quot;) as file: # my_file.uri is the dataset name and .uri is the extension for datasets<br>            file.write(str(response))  # Updating the Source File<br>        <br>        print(&#39;\nData from the API is written in the Source file\n&#39;)</pre><p>In the above code:-</p><ul><li>outlets — You can reference the dataset in a task by passing it to the task’s outlets parameter. outlets is part of the BaseOperator, so it&#39;s available to every Airflow operator. This operator indicates that the task it is assigned to, will be updating the dataset once its executed successfully.</li><li>my_file.uri — Its the dataset name and <strong><em>.uri</em></strong> is the extension for dataset.</li></ul><p>The DAG code above retrieves data from a public API, converts it to JSON, and writes it to the source file. The outletsargument, which we gave, indicates that the dataset will be updated following the execution of get_data_from_api() task.</p><p>For the purpose of scheduling further dependent DAGs, we generated a dataset using the Dataset method and specified the location of a file that will be updated later and will be used for scheduling other dependent DAGs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*pvBSsBNWfqS7-V99HPVzrw.png" /><figcaption>Dataset created — <strong>my_file</strong></figcaption></figure><p><strong>3. Save the file and refesh Airflow UI to see the Dag.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PVynRNRVmYaFBAZACfbveQ.png" /><figcaption>Parent Dataset Dag</figcaption></figure><p><strong>4. Similarly, we will create another DAG —<em> </em></strong>Child_Dataset_dag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*_VAfr4gnEnQGZnBCXAOtgQ.png" /><figcaption>Create <strong>child_dataset_dag.py</strong> file</figcaption></figure><p><strong>5. Copy below code in </strong>child_dataset_dag.py<strong><em> </em>file</strong></p><pre>from airflow import Dataset, DAG<br>from airflow.decorators import task<br>from datetime import datetime, timedelta<br>import requests<br><br># Variable to store the source file path which will be updated by the Parent DAG.<br>my_file = Dataset(&#39;/home/raj/airflow/source_file.txt&#39;)<br><br>default_args = {<br>    &#39;owner&#39;:&#39;Rajesh&#39;,<br>    &#39;retries&#39;: 1,<br>    &#39;start_date&#39;:datetime(2023, 1, 2),<br>    &#39;email&#39;: &#39;routr5953@gmail.com&#39;,<br>    &#39;email_on_failure &#39;: False,<br>    <br>}<br><br>with DAG(<br>    &#39;Child_Dataset_DAG&#39;,<br>    default_args=default_args,<br>    description=&#39;A Child DAG for Datasets&#39;,<br>    schedule = [my_file],    # we are adding [my_file] dataset as the schedule for the Child DAG<br>    tags=[&#39;Datasets&#39;],<br>) as dag:<br>    <br>    @task<br>    def print_task():<br>        print(&#39;This is my child task&#39;)<br><br>    @task()<br>    def read():  <br><br>        with open(my_file.uri, &quot;r+&quot;) as file:  <br>            print(file.read())</pre><ul><li>Schedule : [my_file]— It schedules everything according to the dataset we have produced. The DAG will only be run in the event that the dataset is changed or modified.</li></ul><p>In the above code, We have created the same dataset with the same file location as we will be scheduling the child DAG as per the dataset updates/modification from Parent DAG.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*ppdPBCqsrq3ixjdKIsjuAw.png" /></figure><p>In the schedule parameter, we are passing dataset name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*Sjtr5yNGXZeKzrQbwEj0CQ.png" /><figcaption>schedule = [my_file]</figcaption></figure><blockquote>In both Parent and Child DAG, we need to define the dataset before using it as shown below.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*AlaH-2IJ7GeKjU9TYPQc4w.png" /></figure><p><strong>6. Save the file and refresh Airflow UI to see both the DAGs</strong></p><p>For the Child_Dataset_DAG, scheduling is based on Dataset as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tvuJTojmWLOpepDz-aRP1A.png" /><figcaption>Child DAG schedule is set to Dataset</figcaption></figure><p>Child_Dataset_DAG will be executed after Parent_Dataset_DAG has modified the file/Dataset. We can define a schedule for the Parent DAG based on our needs. At the moment, I have it set to <strong>None</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*1Bdo0NxAer58khUKAfrN8g.png" /><figcaption>Parent DAG schedule set to None</figcaption></figure><p><strong>7. Now lets trigger the Parent DAG and see how its executes the Child DAG.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uPw9pb1YC_iFpFhvNc66eQ.png" /><figcaption>Parent DAG triggered at <strong>19:17:16</strong></figcaption></figure><p>Child DAG also got triggered due to the modification of the dataset as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i_v8XxBr4PK0pK-68DGlRQ.png" /><figcaption>Child DAG executed at 19:17:22</figcaption></figure><p>For the Child DAG, we can see the logs for read() task as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fBmOCFqAqMNSxdI4gZ86zw.png" /><figcaption>It read the API data from the source file we had created at the beginning.</figcaption></figure><p>To check the dependency of DAGs, click on Datasets in the Airflow UI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6rbQlP9xvEszBn40B_KcEA.png" /><figcaption>Dependency of DAGs with Dataset</figcaption></figure><p>In the above figure, we can see that Parent Dag will get executed first and modify the Dataset after successful execution. Modification of the file will lead to execution of the Child DAG.</p><p>In conclusion, this blog has taken us on a journey through the remarkable world of datasets in Apache Airflow, shedding light on the revolutionary concept of data-aware scheduling for Directed Acyclic Graphs (DAGs). We’ve explored how this feature empowers data engineers to build workflows that are not only robust and efficient but also responsive and adaptive.</p><p>By leveraging datasets, we have learned how to orchestrate data pipelines that dynamically respond to changes in data availability, reducing unnecessary executions and maximizing resource utilization. This shift from static routines to dynamic, intelligent DAGs opens up a new realm of possibilities in the field of data engineering.</p><h4><strong>Stay Connected on LinkedIn</strong></h4><p>For more exciting updates, discussions, and deeper dives into the world of data engineering and technology, I invite you to connect with me on LinkedIn. Follow me on <a href="https://www.linkedin.com/in/rajeshrout97/"><strong>LinkedIn</strong></a><strong> </strong>for the latest news, articles, and discussions on data engineering, Airflow, and related topics. Thank you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3f01b840bb9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Streamlining Airflow Deployment: Automating CI/CD with GitHub Actions]]></title>
            <link>https://medium.com/apache-airflow/streamlining-airflow-deployment-automating-ci-cd-with-github-actions-5602f1062783?source=rss-2385f1e2ebc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/5602f1062783</guid>
            <category><![CDATA[airflow]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[ec2]]></category>
            <dc:creator><![CDATA[Rajesh Ku. Rout]]></dc:creator>
            <pubDate>Tue, 16 May 2023 08:12:00 GMT</pubDate>
            <atom:updated>2024-11-27T11:06:37.005Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sSZMZFvczn15uFmKw9dJZg.png" /></figure><p>Are you tired of manually deploying your Airflow code changes to your EC2 instance? Look no further than GitHub Actions for continuous integration and deployment (CI/CD) automation. In this blog, I’ll walk you through how to set up GitHub Actions to automate the deployment of your Airflow code to your EC2 instance.</p><p>I’ll guide you through the steps to set up a GitHub Action workflow for your Airflow code, including creating a new workflow, defining the necessary environment variables, and configuring the deployment steps.</p><p>With my detailed instructions and examples, you’ll be able to seamlessly integrate GitHub Actions into your Airflow development process and easily deploy your code changes to your EC2 instance. Say goodbye to manual deployments and hello to more efficient and streamlined development with GitHub Actions.</p><p>By following the steps outlined below in this blog, you can create an SSH key pair, securely store your private key as a secret in GitHub, and configure your EC2 instance to accept the public key. With this setup in place, you can leverage the power of GitHub Actions to copy your Airflow code files to your EC2 instance using secure SSH authentication.</p><h3>Creating an SSH Key Pair</h3><ol><li>Open up your terminal or command prompt and type ssh-keygen the command.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*LNSUn1ZpOI2V9JUZagCEbA.png" /><figcaption><strong>ssh-keygen</strong> command</figcaption></figure><p><em>Follow the prompts to generate a new SSH key pair.</em></p><p>2. Press <strong>ENTER</strong> in every prompt to create <strong>ssh-keygen</strong> in the default location.</p><p><em>In case you want to specify a custom location by providing a file path or want to add Passphrase then add it after the respective prompt.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*0DLDfF0qUEHQNCpYZvD0eA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*PYpSwpaEbib4ReH-K9PgRg.png" /><figcaption><strong>Press ENTER after each prompt for the default location and No passphrase</strong></figcaption></figure><h3>Adding the Private Key to GitHub Secrets</h3><ol><li>Go to the repository in which you have kept your Airflow code or want to make that repository for Airflow Code.</li><li>Click on “Settings” at the top of the page, then click on “Secrets” in the left-hand sidebar.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*op5J_4SFhsOE1909q7NtQw.png" /><figcaption>Go to your <strong>Repository </strong>→ <strong>Settings</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oCA9Mh923HwVmw1Pi-e2UA.png" /><figcaption>Click → <strong>Secrets and variables</strong></figcaption></figure><p>3. Click on <strong>Actions </strong>→ <strong>New Repository Secret</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IOhFy0FORxPbjb6Y9c1cZw.png" /></figure><p>4. Enter a name for your secret (e.g., SSH_PRIVATE_KEY) and paste the contents of your private key into the &quot;Value&quot; field.</p><p>a) Open your <strong>Windows Explorer</strong>, and paste the below path to get the <strong>id_rsa.pub</strong> file as shown below.</p><pre>C:\Users\rajes\.ssh   -- &#39;rajes&#39; : Replace your username </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*ZmZoJrM8uGjGQFxl1nbBoA.png" /><figcaption><strong>Paste the path:</strong> C:\Users\rajes\.ssh</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*QuWI43vxm4_ZO8K25gZ2kw.png" /><figcaption>Open the<strong> id_rsa.pub file</strong></figcaption></figure><p>b) Copy the content of the <strong>id_rsa.pub</strong> file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*k2bUGWSNFcD-X1zhwJ53qQ.png" /><figcaption>Copy the Content of the File</figcaption></figure><p>c) Paste the contents of your private key into the “Value” field of the Secret Variable (SSH_PRIVATE_KEY)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mjLvo3yAswCblZwUOQm_Fw.png" /><figcaption>Paste your ssh private key → Click <strong>Add Secret</strong></figcaption></figure><p>d) Click “Add secret” to save the secret.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*0pp_QRMH2jQ701w72awbBw.png" /><figcaption><strong>SSH_PRIVATE_KEY</strong></figcaption></figure><p>We have successfully added a repository secret.</p><h3>Configuring the Public Key on EC2 Instance</h3><ol><li>Log in to your EC2 instance using SSH.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*2W4r1MhUjdXEOQG3R135OQ.png" /><figcaption><strong>Login to EC2 using SSH</strong></figcaption></figure><p><em>You can log in to AWS EC2 using different ways. I have done it using the ssh command.</em></p><p>2. Run mkdir ~/.ssh the command to create a new ~/.ssh directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*eAFmhb5YdliHcIKJDyCq3A.png" /><figcaption>Create new folder:- <strong>mkdir ~/.ssh</strong></figcaption></figure><p>3. Run touch ~/.ssh/authorized_keys the command to create a new authorized_keys file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*Gd3WzGQB1vHsLcrU1G5WNQ.png" /></figure><p>4. Open the authorized_keys file with your preferred text editor.</p><pre>vim authorized_keys        --( I am using VIM editor to edit the file )<br><br><br>-- In case you dont have vim installed, then you can install it by:- <br><br>sudo apt install vim      --(Change your linux user to root user and install it)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*vqnq-xioj1DxQwBKXVlbrA.png" /><figcaption><strong>cd .ssh</strong> → <strong>ls </strong>→ <strong>authorized_keys</strong></figcaption></figure><p>Copy the ssh public key and paste it into the authorized_keys file on your EC2 instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*4YM5SoQnJoyiXPIrqH6wOg.png" /><figcaption>Open the id_rsa file and copy the content and paste it into your EC2 authorized_keys file</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PBMuMoExvR81r-fRXVr98Q.png" /><figcaption>Paste it into:- <strong>vim authorized_key</strong></figcaption></figure><p>To save and close the file, enter</p><pre>Click on ESC button --&gt; Type :wq! --&gt; Then Enter</pre><p>5. Set the appropriate file permissions on the ~/.ssh directory and authorized_keys file with the following commands:</p><pre>chmod 700 ~/.ssh<br>chmod 600 ~/.ssh/authorized_keys</pre><h3>Configuring GitHub Actions to use SSH Key</h3><ol><li>Create a new GitHub Action workflow file or modify an existing one that needs to add files to your EC2 instance via SSH.</li></ol><p><em>To create a new workflow file, follow the below steps:</em></p><p><strong>Click on Actions → Click on Set up a workflow yourself</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ray-lwna4SF7t6uKqyV-uQ.png" /><figcaption><strong>Actions → set up a workflow yourself</strong></figcaption></figure><p>Give a <strong>name</strong> to your workflow file and <strong>commit the changes</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W_dKUe4y7ocXc4-Oig-cwg.png" /><figcaption><strong>Give a name</strong> to the File → <strong>Commit changes</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*jNZWJtD-JzxxJahMYEZ2XA.png" /><figcaption>Add a commit message → Commit Changes</figcaption></figure><p>Once we commit the changes, we can see a new folder <strong>“<em>.github/workflows</em>”</strong> has been created with <strong>“<em>airflow_env.yml”</em> </strong>file inside it as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*hvTq3K_87cQU-nY8hrVX1g.png" /></figure><p>2. Create a new folder <strong>‘airflow-scripts’</strong> in your Repository at the root location</p><p>→ Click on <strong>Add File</strong> → <strong>Create New File</strong></p><p><em>We are creating this folder to keep our Airflow Scripts</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u4o_eVSvyk4Q0bSSAwUBHQ.png" /><figcaption>Add File → Create new File</figcaption></figure><p>Enter <strong><em>airflow-scripts/Sample_ETL_Dag.py</em></strong></p><p>We have created a new folder and added a new file named <strong><em>“Sample_ETL_Dag.py”</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tt85tXO6wfhqpHIiher7iA.png" /></figure><p>Then <strong>commit the new changes.</strong></p><p>3. Copy and paste the following code snippet into the <strong><em>airflow_env.yml</em></strong> workflow file:</p><pre>name: Deploy to EC2 Instance <br><br><br># Controls when the action will run. <br><br>on:<br>  push: <br>    <br>    branches:  <br>      - main<br>    <br>    paths: <br>      - &#39;airflow-scripts/**&#39;  # this is our Folder name we created for Airflow<br><br>    # Allows you to run this workflow manually from the Actions tab<br>  workflow_dispatch:<br><br>jobs:<br>  deploy:<br>    runs-on: ubuntu-latest<br><br>    steps:<br>        <br>      <br>      - name: Checkout repository<br>        uses: actions/checkout@v2<br><br>      - name: copy file via ssh key<br>        uses: appleboy/scp-action@v0.1.4<br>        with:<br>          host: ec2-11-111-111-111.compute-1.amazonaws.com  # Your EC2 Host name<br>          username: airflow  # Your EC2 Username<br>          key: ${{ secrets.SSH_PRIVATE_KEY }}  # Secret Variable we created<br>          source: Sample_ETL_Dag.py  # This is our Source File name placed in Airflow-scripts Folder<br>          target: /home/airflow/airflow/dags/  # Your target folder in EC2 where you want to create the file</pre><p>The given code is a GitHub Actions workflow named “<strong>Deploy to EC2 Instance</strong>” that is triggered under specific conditions and performs a file copy operation to an EC2 instance using SSH key authentication. Here is an explanation of the code in a structured format:</p><blockquote><strong>on</strong>:</blockquote><ul><li><strong>push</strong>: Specifies that the workflow will run when a push occurs in the specified branches.</li><li><strong>branches</strong>: Defines the branch name(s) for which the workflow will be triggered (e.g., <strong>main</strong>).</li><li><strong>paths</strong>: Specifies the folder path(s) that, if modified, will trigger the workflow (e.g., &#39;<strong>airflow-scripts/**</strong>&#39;).</li><li><strong>workflow_dispatch</strong>: Allows manual triggering of the workflow from the Actions tab in the GitHub repository.</li></ul><blockquote><strong>jobs</strong>:</blockquote><ul><li><strong>deploy</strong>: Defines a job named “<strong>deploy</strong>” that will run the steps within it.</li><li><strong>runs-on:</strong> Specifies the operating system for the job (e.g., <strong>ubuntu-latest</strong>).</li></ul><blockquote><strong>steps</strong>:</blockquote><ul><li><strong>Checkout repository:</strong> Uses the <strong>actions/checkout</strong> action to fetch the repository content.</li><li><strong>copy file via ssh key:</strong> Uses the <strong>appleboy/scp-action</strong> action to copy a file to the EC2 instance via SSH.</li><li><strong>host:</strong> Specifies the EC2 instance hostname or IP address.</li><li><strong>username:</strong> Specifies the username used to authenticate with the EC2 instance.</li><li><strong>key: </strong>Refers to the <strong>SSH_PRIVATE_KEY</strong> secret variable created in GitHub Secrets.</li><li><strong>source: </strong>Specifies the source file to be copied, with the branch name appended as a suffix.</li><li><strong>target: </strong>Specify the target folder on the EC2 instance where the file will be created.</li></ul><p>By configuring this workflow, any changes pushed to the specified branch ( <strong>main </strong>) or folder ( <strong>airflow_scripts </strong>) will trigger the workflow. It will then copy the specified file to the target folder on the EC2 instance using SSH key authentication.</p><p>Certainly! When you push something into the airflow-scripts folder, the workflow will be triggered, and it will copy the sample_ETL_Dag.py file to the specified target folder on your EC2 instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eauJnNBWDNnLy2JymPkEdw.png" /><figcaption><strong>Deploy to EC2 Instance </strong>Workflow is running</figcaption></figure><p>Once, it&#39;s successfully executed, a copy of the sample_ETL_Dag.py file will be created at the specified target folder on your EC2 instance as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*hFwTHY5HKRQqJAkOEb0FpA.png" /></figure><p>This workflow allows for seamless deployment of the Airflow DAG file to the remote server for execution. By automating this process, you can ensure that the latest version of your DAG is always available on the EC2 instance, enabling efficient and up-to-date task scheduling and workflow management in Airflow.</p><p>In conclusion, utilizing GitHub Actions for CI/CD of Airflow code in an EC2 instance can greatly streamline your development process. By automating the deployment of your Airflow code changes, you can save valuable time and effort that would otherwise be spent on manual deployments. GitHub Actions provides a powerful and flexible platform for creating workflows that integrate seamlessly with your repository, allowing you to trigger deployments based on specific events, such as pushes to relevant branches or modifications to specific folders.</p><p>Embrace the potential of GitHub Actions for CI/CD of Airflow code in your EC2 instance, and unlock a world of streamlined development and efficient deployment, empowering you to take your Airflow projects to new heights.</p><p>As an aspiring data engineer, take your skills to the next level with the Udemy SnowPro Core Certification Practice Set for 2023. Designed to help you excel in the SnowPro Core Certification exam, this practice set provides real-world scenarios and hands-on exercises to enhance your understanding of Snowflake data warehousing. Don’t miss this opportunity to gain practical experience, reinforce your knowledge, and pave the way for a successful career in data engineering. Enroll today and unlock your full potential!</p><blockquote><a href="https://www.udemy.com/course/snowflake-snowpro-core-certification-2023-practice-sets/?referralCode=D9755936C300A61FA7A4">https://www.udemy.com/course/snowflake-snowpro-core-certification-2023-practice-sets/?referralCode=D9755936C300A61FA7A4</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5602f1062783" width="1" height="1" alt=""><hr><p><a href="https://medium.com/apache-airflow/streamlining-airflow-deployment-automating-ci-cd-with-github-actions-5602f1062783">Streamlining Airflow Deployment: Automating CI/CD with GitHub Actions</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[Integrating Slack with Airflow: Step-by-Step Guide to Setup Alerts]]></title>
            <link>https://awstip.com/integrating-slack-with-airflow-step-by-step-guide-to-setup-alerts-1dc71d5e65ef?source=rss-2385f1e2ebc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/1dc71d5e65ef</guid>
            <category><![CDATA[airflow]]></category>
            <category><![CDATA[alerts-management]]></category>
            <category><![CDATA[slack-apps]]></category>
            <category><![CDATA[slack-tips-and-tricks]]></category>
            <category><![CDATA[slack]]></category>
            <dc:creator><![CDATA[Rajesh Ku. Rout]]></dc:creator>
            <pubDate>Tue, 04 Apr 2023 23:27:48 GMT</pubDate>
            <atom:updated>2023-04-07T18:08:02.320Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hr26HSZJdjpW4E1YHWxcYg.png" /></figure><p>As data pipelines become more complex, it’s important to monitor them closely to ensure they are running smoothly. One way to do this is to send alerts when certain events occur, such as a task failing or taking longer than expected to complete. In this blog post, we’ll show you how to use Airflow to send alerts to Slack, a popular messaging platform, so you can stay on top of your data pipeline performance.</p><h3><strong>Section 1: Setting Up Slack Integration</strong></h3><p>The first step in sending alerts to Slack is to set up a Slack integration in Airflow. This involves creating a new Slack app and setting up a webhook URL that will be used to send messages to Slack. We’ll walk you through the process of creating a Slack app and setting up a webhook URL, and show you how to configure Airflow to use the URL to send alerts to Slack.</p><ol><li><strong>Click on the URL:-</strong></li></ol><p><a href="https://api.slack.com/apps">https://api.slack.com/apps</a></p><p>2. Click on <strong>Create an App → From Scratch</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9df0pV5zjLT1deHrsMLhkA.png" /><figcaption><strong>app.slack.com/apps</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*IlqkLuvQ45P9NhWDaiItJA.png" /></figure><p>3. Give a <strong>name </strong>to your App and select the<strong> Workspace</strong> <strong>→ Create App</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*L5_LMXc7r3TH6z4lfJ9pzw.png" /><figcaption><strong>App Name → Pick a Workspace</strong></figcaption></figure><p>4. Active Incoming Webhooks</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FE67cYKRicfWoo2niyciIg.png" /><figcaption><strong>Select Incoming Webhooks</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*dDJck4DGjMiKylFJgYSNlQ.png" /><figcaption><strong>Turn it On</strong></figcaption></figure><p>5. Add this Webhook to a Workspace</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-wZYuTbTM0Xb39xcFCoc1A.png" /><figcaption><strong>Click on Add as highlighted</strong></figcaption></figure><blockquote><strong>Select a channel where you want to send alerts. If you don’t have then create a public/private channel as per your requirement. Both channel type will work with the webhook.</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*no0Yx3V65XkiljtYbxJEzg.png" /><figcaption><strong>Select a channel → Click Allow</strong></figcaption></figure><p>6. Copy the Webhook URL</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*24ME10nqfX6Lr-G0L92f6w.png" /><figcaption><strong>Copy the URL</strong></figcaption></figure><h3>Section 2: Setting up Slack on Airflow</h3><p>Once the Slack integration is set up, the next step is to create a Slack connection that will be used to connect to Slack. I’ll show you how to create a connection in Airflow that will be used to send messages to a Slack channel, and how to install Airflow Slack Provider in your instance to use Airflow Slack, in-built Operators.</p><ol><li>Install Slack Provider on your Airflow Instance</li></ol><pre>pip install apache-airflow-providers-slack</pre><p>2. Create a Slack connection using Airflow UI</p><p>Click <strong><em>Admin </em></strong>→<strong><em> Connections</em></strong> → <strong><em>+ Icon</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z3WF7kCIfweKSr7ZGgDp5Q.png" /><figcaption><strong>Admin → Connections → Add Icon</strong></figcaption></figure><p>connection_id: Connection name that will be used to connect to Slack in the Script.</p><p>connection Type: Select HTTP</p><p>host: Copy this URL and paste it <strong><em>( </em></strong><a href="https://hooks.slack.com/services/"><strong><em>https://hooks.slack.com/services/</em></strong></a><strong><em> )</em></strong></p><p>password: From the Webhook URL we copied using Step 6 from Section 1, paste the remaining section of it apart from the <strong>host</strong>.</p><blockquote><strong><em>Example:-</em></strong></blockquote><blockquote><strong><em>( </em></strong><a href="https://hooks.slack.com/services/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"><strong><em>https://hooks.slack.com/services/T02SUB76Y9E/B051LPTEBKQ/Aq4JX</em></strong></a><strong><em> )</em></strong></blockquote><blockquote><em>Password </em>— <a href="https://hooks.slack.com/services/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"><strong><em>T02SUB76Y9E/B051LPTEBKQ/Aq4JX</em></strong></a></blockquote><p>3. Create a variable to store the Slack connection ID name</p><p>Click <strong><em>Admin </em></strong>→<strong><em> variables</em></strong>→ <strong><em>+ Icon</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eOqpcUOH3HFnnIaLXkyPFA.png" /><figcaption><strong>Add your Slack Connection Name in the Val section</strong></figcaption></figure><blockquote>We are adding a variable to store the Slack connection name we created using Step 2. This variable will be referred to in the DAG code to create a connection to Slack. This variable contains slack connection as a dictionary which can be used later.</blockquote><h3>Section 3: Creating an Alert Task</h3><p>Once the Slack integration is set up, the next step is to create an Airflow function that will send alerts to Slack when certain events occur. We’ll show you how to create a Python function that uses the Slack operator to send messages to a Slack channel.</p><p>Here, we are sending Slack alerts on task failure</p><pre># Import this operator to use it for creating slack task<br>from airflow.providers.slack.operators.slack_webhook import SlackWebhookOperator<br><br>### Slack Alert Function #####<br>def slack_alert(context):<br>    <br>    # we are retrieving our Slack Variable<br>    SLACK_CONN_ID = Variable.get(&#39;slack_conn&#39;)<br><br>    &#39;&#39;&#39;Owner - Rajesh <br>    &#39;&#39;&#39;<br>    # we are fetching Slack connection Password <br>    slack_webhook_token = BaseHook.get_connection(SLACK_CONN_ID).password<br><br>    # We are getting the object after making connection to Slack using Basehook<br>    channel = BaseHook.get_connection(SLACK_CONN_ID).login<br>    <br>    # Here you can customize the message as per your need.<br><br>    slack_msg = f&quot;&quot;&quot;<br>        :x: Task Failed.<br>        *Task*: {context.get(&#39;task_instance&#39;).task_id}<br>        *Dag*: {context.get(&#39;task_instance&#39;).dag_id}<br>        *Execution Time*: {convert_datetime(context.get(&#39;execution_date&#39;))}<br>        &lt;{context.get(&#39;task_instance&#39;).log_url}|*Logs*&gt;<br>    &quot;&quot;&quot;<br><br>    # its a sub task which will be executed whenever the function is called <br><br>    slack_alert = SlackWebhookOperator(<br>        task_id=&#39;slack_fail&#39;,<br>        webhook_token=slack_webhook_token,<br>        message=slack_msg,<br>        channel=channel,<br>        username=&#39;airflow&#39;,<br>        http_conn_id=SLACK_CONN_ID<br>    )<br><br>    # execute method to run this task<br>    slack_alert.execute(context=context)</pre><p>Here, we have created a Python function that can be triggered by different events.</p><h3>Section 4: Defining Alert Triggers</h3><p>To send alerts at the right time, you need to define triggers that will activate the alert task when certain events occur. For example, you may want to send an alert when a task fails, or when a DAG fails. I’ll show you how to define triggers using Airflow’s default arguments.</p><p>I will add the slack_alert function as a parameter to the dag default arguments as shown below:</p><pre>default_args = {<br>    &#39;owner&#39;:&#39;Rajesh&#39;,<br>    &#39;retries&#39;: 0,<br>    &#39;start_date&#39;:datetime(2023, 3, 2),<br><br># &#39;If any task or DAG fails this function will get trigerred automatically<br><br>    &#39;on_failure_callback&#39;: slack_alert  # its our function name<br><br>}</pre><blockquote>This code can also be easily modified to <strong>send alerts on task success</strong> or other states. If you want to send <strong>Slack alerts on task success </strong>then add the below parameter to your dag default arguments:</blockquote><pre>default_args = {<br>    &#39;owner&#39;:&#39;Rajesh&#39;,<br>    &#39;retries&#39;: 0,<br>    &#39;start_date&#39;:datetime(2023, 3, 2),<br><br># &#39;If any task or DAG fails or succeeds then slack_alert function will get trigerred automatically<br><br>    &#39;on_failure_callback&#39;: slack_alert  # its our function name<br>    &#39;on_success_callback&#39;: slack_alert  # <br><br>}</pre><p>We will receive a notification in our Slack channel whenever a task is executed. By adding a condition to the slack_alert method, we can tailor the Slack message based on the tasks’ current status. <strong><em>(Failed/Success)</em></strong></p><h3>Section 5: Customizing Alerts</h3><p>To make the most of Slack alerts, it’s important to customize them so they provide the right level of detail and context. I’ll show you how to customize the Slack messages sent by the alert task, including how to include information about the task that triggered the alert, and how to format the messages to make them easy to read.</p><pre>def slack_alert(context):<br>    <br>    ti = context[&#39;ti&#39;] # to get the Task Instance<br>    task_state = ti.state # To get the Task state<br>    <br>     # Task state = Success <br><br>    if task_state == &#39;success&#39;:<br>        slack_msg = f&quot;&quot;&quot;<br>        :green_circle: Task Succeeded.<br>        *Task*: {context.get(&#39;task_instance&#39;).task_id}<br>        *Dag*: {context.get(&#39;task_instance&#39;).dag_id}<br>        *Execution Time*: {convert_datetime(context.get(&#39;execution_date&#39;))}<br>        &quot;&quot;&quot;<br>    # Task state = Failed <br>    <br>    elif task_state ==&#39;failed&#39;:<br>        slack_msg = f&quot;&quot;&quot;<br>        :x: Task Failed.<br>        *Task*: {context.get(&#39;task_instance&#39;).task_id}<br>        *Dag*: {context.get(&#39;task_instance&#39;).dag_id}<br>        *Execution Time*: {convert_datetime(context.get(&#39;execution_date&#39;))}<br>        &lt;{context.get(&#39;task_instance&#39;).log_url}|*Logs*&gt;<br>        &quot;&quot;&quot;</pre><p>In this case, we are verifying the <strong><em>task state</em></strong> because we are utilizing the same slack_alert method to send alerts in various task states.</p><p>For various task statuses, you can use various alert functions as per your requirements as well. But in this example, I am reusing my code.</p><h3>Section 6: Test out our DAG</h3><p>Let’s test our code now. We should receive the success message we defined in the Slack alert function in the event of success and the failure message in the event of failure.</p><h4><strong>In case of Success:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*gbtplVMxvxTGLtjQRRDiBw.png" /><figcaption><strong>DAG executed Successfully</strong></figcaption></figure><p><em>You should get the Success Message in the Slack Alert</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*-id7lq6ti3hSMXROTV3mlw.png" /><figcaption><strong>Airflow Alerts is the App name we defined while creating Webhook</strong></figcaption></figure><h4>In case of Failure:</h4><p>To test, intentionally write in an error to your code to verify that airflow will send messages upon task failure.</p><p>Create a task fail_task using Python Operator and intentionally failing it to check for the Failure Notification.</p><pre>from airflow.operators.python import PythonOperator<br>from airflow.exceptions import AirflowFailException<br><br># We are raising a failure using AirflowFailException class<br><br>def fail_func():<br>        raise AirflowFailException(&#39;Testing&#39;) # It will fail the task<br><br>with dag:<br><br> <br>    fail_task = PythonOperator(<br>        task_id = &#39;fail-task&#39;,<br>        python_callable = fail_func<br>    )</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*fI-YAfLPBVsXZPAbish4YQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*7KStOww4lQkKe_RUP9APSA.png" /><figcaption><strong>Failure Alert</strong></figcaption></figure><p>Next time you experience a failure in your dag workflow or your tasks ran successfully, you will be notified via Slack with the name of the task and a direct link to the logs so you can begin the debugging process in case of failure.</p><p>With Airflow and Slack integration, you can quickly set up alerts for your data pipeline and stay on top of your pipeline performance. By following the steps outlined in this blog post, you can easily set up Slack alerts in your Airflow environment and customize them to suit your needs.</p><p>If you’re interested in exploring the code further, you can find it on GitHub at <a href="https://github.com/rajeshrout97/Airflow.git"><strong><em>GITHUB PROFILE</em></strong></a><strong><em>.</em></strong> This repository contains all the files and resources used in the project and can be a valuable resource for anyone looking to learn more about the implementation details.”</p><p>I hope you found this blog useful. If it did, please share your thoughts and show your appreciation by sharing it with others and giving it a thumbs up ☺️. Thank you</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1dc71d5e65ef" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/integrating-slack-with-airflow-step-by-step-guide-to-setup-alerts-1dc71d5e65ef">Integrating Slack with Airflow: Step-by-Step Guide to Setup Alerts</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Orchestrate Airbyte using Apache Airflow]]></title>
            <link>https://medium.com/apache-airflow/orchestrate-airbyte-using-apache-airflow-f410e7c8eb02?source=rss-2385f1e2ebc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/f410e7c8eb02</guid>
            <category><![CDATA[orchestration]]></category>
            <category><![CDATA[airflow]]></category>
            <category><![CDATA[airbyte]]></category>
            <category><![CDATA[airflow-2]]></category>
            <category><![CDATA[airflow-sensors]]></category>
            <dc:creator><![CDATA[Rajesh Ku. Rout]]></dc:creator>
            <pubDate>Tue, 04 Apr 2023 12:29:56 GMT</pubDate>
            <atom:updated>2024-11-27T11:07:26.154Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4WpaqESw31SzkCsOTJeAeg.png" /></figure><p>In today’s data-driven world, there are numerous data sources, each with its structure, frequency, and format. Extracting and transferring data from these sources to a data warehouse can be a challenging and time-consuming process. That’s where Airbyte comes in as an open-source data integration platform that makes it easy to connect to various data sources and replicate data in a standardized format to a target destination.</p><p>However, scheduling Airbyte jobs manually can be tedious, error-prone, and time-consuming. This is where Apache Airflow comes in. Airflow is a platform to programmatically author, schedule, and monitor workflows. It lets you define your workflows as code, execute them automatically, and monitor their progress.</p><p>In this blog summary, we will discuss how to orchestrate Airbyte with Airflow to create a reliable and automated data integration pipeline. We will cover the following steps:</p><ol><li>Setting up Airbyte: We will cover how to set up Airbyte and how to create a connection to the desired data source(s) and destination(s).</li><li>Setting up Airflow: We will cover how to set up Airflow and how to create an Airflow DAG (Directed Acyclic Graph) to schedule the Airbyte job.</li><li>Creating the DAG: We will walk through the process of creating an Airflow DAG that uses an Airbyte operator to execute an Airbyte job.</li><li>Configuring the DAG: We will discuss how to configure the DAG with parameters such as scheduling frequency, time zone, and email notifications.</li><li>Monitoring the DAG: We will cover how to monitor the DAG using the Airflow web interface and how to troubleshoot any issues.</li></ol><p>Following these steps, you can orchestrate Airbyte with Airflow to create a reliable and automated data integration pipeline that saves time, reduces errors, and simplifies the data integration process.</p><h4><strong>Step 1:- Create a Connection using Airbyte UI</strong></h4><ul><li>I am assuming that you have installed Airbyte on your system and started the webserver and scheduler.</li></ul><p><strong>Open Browser → Type Localhost:8000 → New connection</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ELx7hnO4WnA6DkBuZJKF7g.png" /><figcaption><strong>Airbyte Homepage</strong></figcaption></figure><h4>Step 2:- Add a Source</h4><ul><li>I have added ‘<em>Chargebee</em>’ as the source</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pkE0bQwavaI7zHAAY_NNqQ.png" /><figcaption><strong>Chargebee Configuration</strong></figcaption></figure><h4>Step 3:- Add a Destination</h4><ul><li>I took “AWS <em>S3” </em>as my destination</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cGhwEnr4d6nYwviHa9d9gg.png" /><figcaption><strong>AWS S3 Configuration</strong></figcaption></figure><h4>Step 4:- Start the Sync</h4><p>→ Click on<strong> sync now</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8iLyZ9MhFpe2d3mJIPmc7Q.png" /><figcaption><strong>Connection created successfully</strong></figcaption></figure><h4>Step 5:- Set up the Frequency</h4><ul><li>Set up the frequency of this connection to sync as per your requirement.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MPfaqBjOsh6dRMG3_IaNWw.png" /><figcaption><strong>Replication Frequency</strong></figcaption></figure><p>Great job on successfully setting up the Airbyte connection!👌Now, by orchestrating it with Airflow, you can automate the process of data extraction, transformation, and loading. With Airflow, you can easily schedule and monitor the data pipeline to ensure smooth and reliable data transfers. So let’s get started and streamline your data pipeline with Airflow.</p><p>Before we proceed, please make sure that Airflow is installed on your system. If you haven’t installed it yet, you can follow the below documentation to install Airflow locally on your System to get it set up.</p><p><a href="https://medium.com/@routr5953/installing-airflow-on-windows-without-docker-in-5-mins-21d16091ebc5">Install Airflow on Windows without Docker or Virtual Box in 5 mins</a></p><p>Once you have Airflow installed, we can move forward with setting up the orchestration of the Airbyte connection.</p><h4>Step 1:- Create an Airbyte connection in Apache Airflow</h4><p><em>A) Open </em><strong><em>Airflow UI</em></strong><em> → Click </em><strong><em>Admin </em></strong><em>→ Click </em><strong><em>Connections</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ii58W4Yo_Jrii1E07SkRog.png" /><figcaption><strong>Airflow UI</strong></figcaption></figure><p><em>B) Add a connection</em></p><ul><li>Choose the <strong>Connection type:- HTTP</strong></li></ul><blockquote>The Airbyte API uses HTTP, so we’ll need to create an HTTP Connection.</blockquote><ul><li><strong>Host:- </strong>Enter the URL of your Airbyte Instance</li><li><strong>Port:-</strong> 8001 (8000)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*Op9z0liO34lnfsVDQl2Utg.png" /><figcaption><strong>Choose Connection type — HTTP</strong></figcaption></figure><h4>Step 2:- Retrieving the Airbyte Connection ID</h4><p>We’ll need the Airbyte Connection ID so our Airflow DAG knows which Airbyte Connection to trigger.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0aSwRTnkmthvmdCWNMHBbw.png" /><figcaption><strong>Copy the Connection ID as highlighted</strong></figcaption></figure><h4><strong>Step 3:- Create a simple Airflow DAG to run an Airbyte Sync Job</strong></h4><p>I am using Sensor to monitor my Airbyte sync as Sensors do not occupy an Airflow worker slot, so this helps reduce Airflow load.</p><p><strong><em>a) Install Airbyte Provider on your instance</em></strong></p><p>→ Run</p><pre>pip install apache-airflow-providers-airbyte[http]</pre><p><strong><em>b) DAG script</em></strong></p><pre>from airflow import DAG<br>from airflow.utils.dates import days_ago<br>from airflow.providers.airbyte.operators.airbyte import AirbyteTriggerSyncOperator<br><br>with DAG(dag_id=&#39;Airbyte-Dag&#39;,<br>         default_args={&#39;owner&#39;: &#39;Rajesh&#39;},<br>         schedule_interval=&#39;@daily&#39;,<br>         start_date=days_ago(1)<br>    ) as dag:<br><br>    trigger_sync= AirbyteTriggerSyncOperator(<br>        task_id=&#39;airbyte_money_json_example&#39;,<br>        airbyte_conn_id=&#39;airbyte_conn&#39;,  # this is the ID we created on Airflow<br>        connection_id=&#39;Your Connection ID&#39;, # Get this ID by following Step 2<br>        asynchronous=True,<br>    )<br><br>    monitor_sync = AirbyteJobSensor(<br>        task_id=&#39;airbyte_sensor_money_json_example&#39;,<br>        airbyte_conn_id=&#39;airbyte_conn&#39;, # this is the ID we created on Airflow<br>        airbyte_job_id= trigger_sync.output<br>    )<br>    <br>    trigger_sync &gt;&gt; monitor_sync</pre><ul><li>airbyte_conn_id: Name of the Airflow HTTP Connection pointing at the Airbyte API. Tells Airflow where the Airbyte API is located. <strong><em>(airbyte_conn)</em></strong></li><li>connection_id: The ID of the Airbyte Connection to be triggered by Airflow. <strong><em>( ID which we copied from the Airbyte UI in Step 2 )</em></strong></li><li>asynchronous: Determines how the Airbyte Operator executes. When true, Airflow will monitor the Airbyte Job using an AirbyteJobSensor. Default value is false. <strong><em>( I want my Airbyte sensor to monitor the sync process. So set asynchronous = True )</em></strong></li></ul><p>In conclusion, connecting Airflow and Airbyte to create an automated data pipeline can help you assure seamless data transfer. You can easily manage your data pipeline and make sure that your data is delivered reliably and effectively with Airflow’s robust scheduling and monitoring features. You may orchestrate your Airbyte connection with Airflow and optimize your data pipeline by following the instructions in this article. So, utilizing Airflow to coordinate your Airbyte connection will help you save time and effort while maintaining the dependability of your data pipeline, regardless of whether you’re working on a small project or a large-scale enterprise-level data pipeline. Thank you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f410e7c8eb02" width="1" height="1" alt=""><hr><p><a href="https://medium.com/apache-airflow/orchestrate-airbyte-using-apache-airflow-f410e7c8eb02">Orchestrate Airbyte using Apache Airflow</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[Orchestrate Fivetran using Apache Airflow]]></title>
            <link>https://medium.com/apache-airflow/orchestrate-fivetran-with-apache-airflow-d0e927a3fa87?source=rss-2385f1e2ebc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/d0e927a3fa87</guid>
            <category><![CDATA[orchestration]]></category>
            <category><![CDATA[fivetran]]></category>
            <category><![CDATA[airflow]]></category>
            <category><![CDATA[etl]]></category>
            <dc:creator><![CDATA[Rajesh Ku. Rout]]></dc:creator>
            <pubDate>Wed, 15 Mar 2023 19:50:43 GMT</pubDate>
            <atom:updated>2024-09-09T16:58:13.459Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9mPW9sUZVU8NqwqahDV_GA.png" /></figure><p>In today’s data-driven world, it’s essential to have a robust data pipeline that can handle large volumes of data and automate the ETL process. Fivetran is a cloud-based ETL tool that can help you extract data from various sources and load it into your data warehouse. Airflow, on the other hand, is a platform to programmatically author, schedule, and monitor workflows. In this blog, we’ll explore how to orchestrate Fivetran with Airflow to create a seamless data pipeline. We’ll cover the basics of Fivetran and Airflow, how to set up Fivetran as a source in Airflow, and how to schedule and monitor the data pipeline. By the end of this blog, you’ll have a clear understanding of how to use Fivetran and Airflow together to create a scalable and reliable data pipeline.</p><h3>Running Fivetran in Airflow with operators, sensors, and hooks</h3><p>Airflow defines data pipelines as directed acyclic graphs, or DAGs, that are built mostly of tasks called Operators and Sensors. The Fivetran provider enables the creation of FivetranOperators and FivetranSensors. All that is needed to run Fivetran in Airflow is the API Key, API Secret, and connector ID(s) from Fivetran and the Fivetran provider from the Astronomer registry. The API Key and API secret are configured as an Airflow Connection and the connector ID(s) are configured as Airflow Variables.</p><h3>FivetranOperator</h3><p>In Airflow, an operator represents a single, ideally idempotent, task. Operators determine what actually executes when your DAG runs. The FivetranOperator validates that the connector ID supplied exists and is valid for the API Key and Secret given, changes the connector’s schedule type to run on a schedule defined by Airflow instead of Fivetran, and finally calls for the start of a Fivetran sync.</p><h3>FivetranSensor</h3><p>Sensors are a special kind of operator. When they run, they will check to see if certain criteria are met before they complete and let their downstream tasks execute. A FivetranSensor will monitor the status of a Fivetran sync and allow the DAG to progress as soon as data has been fully loaded into a warehouse.</p><h3>FivetranHook</h3><p>The FivetranHook is included in our provider but should be accessed and modified by advanced users only. This code is where Airflow interacts with Fivetran REST API so that complicated logic to start and monitor Fivetran jobs is abstracted away from the FivetranOperator and FivetranSensors in order to make them as readable and easy to use as possible.</p><h3>Follow the below steps to create a DAG that will orchestrate your Fivetran Connectors</h3><h4>Step 1: Download the Fivetran provider</h4><p>To get started, install the Fivetran provider package in your Airflow environment by running <strong><em>pip install airflow-provider-Fivetran </em></strong>on your airflow Instance.</p><pre>pip install airflow-provider-Fivetran</pre><h4>Step 2: Restart Airflow Webserver and Scheduler <strong>( Optional )</strong></h4><p>If you are using Docker, Kubernetes, or Airflow Managed Services like AWS, Azure, or GCP, then <strong>skip this step</strong>.</p><p><strong><em>Webserver:-</em></strong></p><pre>airflow webserver -p 8080</pre><ul><li>8080 is port no.</li></ul><p><strong><em>Scheduler:-</em></strong></p><pre>airflow scheduler</pre><h4>Step 3: Create API Keys in your Fivetran Account</h4><p>Click on your <strong><em>Account Name</em></strong> → <strong><em>API Key</em></strong> → <strong><em>Generate Key</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*mqzJ-z4fRP9d-6JKgkB_qA.png" /><figcaption><strong>Fivetran Homepage → API Key Generation</strong></figcaption></figure><blockquote>If you will see your Fivetran Connector, sync_frequency is managed by Fivetran UI. We can arrange the frequency as per our need by scrolling it.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VxYqquivwpiKMzjo7RnykQ.png" /><figcaption><strong>Sync Frequency is managed by Fivetran UI</strong></figcaption></figure><p>Now we will orchestrate this with Airflow.</p><h4>Step 4: Create a Connection through your Airflow UI</h4><p>Go to your <strong>Airflow UI</strong> → Click on <strong><em>Admin </em></strong>→ <strong><em>Connections </em></strong>→ Click on <strong>+ </strong>Icon as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*NvR0EfF45Ci19XTBfhgiEA.png" /><figcaption><strong>Click Admin → Connections</strong></figcaption></figure><p>In the Edit Connection Page, Enter the <strong>API key</strong> and <strong>Secret Key</strong> you generated in the Fivetran Dashboard by step 3 as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*oduX8B4uYWxEX1cdcs3JAw.png" /><figcaption><strong>Test the Connection</strong></figcaption></figure><p>Give this connection a name that you will refer to later in the DAG to call Fivetran Connector through <strong>Airflow Fivetran Operator</strong>.</p><h4>Step 5: Create a DAG</h4><p>We will use Fivetran Operator and Sensor to create tasks in Airflow.</p><p>a) Import <strong>FivetranOperator </strong>and <strong>FivetranSensor </strong>in your DAG code</p><pre>from fivetran_provider.operators.fivetran import FivetranOperator<br>from fivetran_provider.sensors.fivetran import FivetranSensor</pre><p><strong>b) Pass the Connection ID we gave for the Fivetran Connection made on Airflow UI</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*OpiWCr7opyE5gbPxU99meg.png" /><figcaption><strong><em>Fivetran_Con_ID</em> is the connection name for Fivetran Connection</strong></figcaption></figure><p>Here, <strong>‘fivetran_conn_id’ </strong>is the default parameter for the connection id Fivetran will look for. We can pass this in the default args and in the individual task as well. But as per the best practice, if you have more than one task for a specific provider, then pass the connection ID for that provider (Fivetran, AWS, Snowflake, etc.) in the default args.</p><blockquote><strong>Default args parameters are passed to all the tasks by default</strong></blockquote><p><strong>c) Create two tasks</strong></p><p>Two jobs would be required since the connector will be started by the <strong>Fivetran Operator</strong>, while the<strong> Fivetran Sensor</strong> will keep track of the sync and run the downstream task or take some other action after the successfully loaded data reaches the destination.</p><pre>dag = DAG(<br>    dag_id=&quot;Airflow-Fivetran-DAG&quot;,<br>    default_args=default_args,<br>    schedule_interval=timedelta(days=1),<br>    catchup=False,<br>)<br><br>with dag:<br>    <br>    fivetran_op = FivetranOperator(<br>        task_id=&quot;Fivetran-Operator&quot;,<br>        connector_id=&quot;Your connector ID&quot;,<br>    ) # This task will trigger the Fivetran Connector<br><br>    fivetran_sensor = FivetranSensor(<br>        task_id=&quot;Fivetran-Sensor&quot;,<br>        connector_id=&quot;Your connector ID &quot;,<br>        poke_interval = 5<br>        <br>    ) # This task will monitor the sync process of that connector untill it<br>      # gets a condition as Failed or Success<br><br>    fivetran_op &gt;&gt; fivetran_sensor</pre><p><strong><em>Connector_id:-</em></strong> Go to your <strong>Fivetran Account</strong> → Click on the <strong>Connector</strong> you want to trigger through Airflow → Click <strong>Setup </strong>→ <strong>Copy the Connector ID</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*CXvcEsP2oR8siw5a5p0MXw.png" /><figcaption><strong>Connector ID for the Google Sheet Connector</strong></figcaption></figure><p>As we have passed the Connection ID in the default args, Fivetran will catch the connection ID in the back end and make a connection to your Fivetran account.</p><p><strong>d) Trigger the DAG</strong></p><p>Unpause the DAG to run automatically. We have set up a scheduled interval that will make DAG run automatically when you unpause it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*YhnSXoISio7u-VNAkpFt-Q.png" /><figcaption><strong>Unpause the DAG</strong></figcaption></figure><p>You can see both Tasks in the DAG</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*FqFY97E2JY3eHLdOzftR-w.png" /></figure><p>When DAG runs, we can see our connector also starts syncing. Check your Fivetran Account for the same.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2guGRfCcJY1k1p9PTlwSPQ.png" /><figcaption><strong>Google Sheet Connector starts syncing</strong></figcaption></figure><p>Before, the <strong>sync_frequency</strong> was managed by the <strong>Fivetran UI.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VxYqquivwpiKMzjo7RnykQ.png" /><figcaption><strong>Sync Frequency is managed by Fivetran UI</strong></figcaption></figure><p>But now, the connector’s sync frequency is managed by the <strong>Fivetran API</strong>. This means that to initiate sync for this connector, <strong>Airflow uses the Fivetran API.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*9qsN_oUT9Ad4sW_thMwFtQ.png" /><figcaption>Sync_frequency → Controlled by Fivetran API</figcaption></figure><p>In conclusion, I would say orchestrating Fivetran with Airflow can help you create a robust and scalable data pipeline that automates the ETL process. By using Fivetran as a source in Airflow, you can easily extract data from various sources and load it into your data warehouse, while Airflow helps you schedule and monitor the entire process. With this integration, you can save valuable time and resources, reduce errors, and ensure that your data pipeline is always up-to-date. I hope this blog has provided you with a clear understanding of how to use Fivetran and Airflow together to create a seamless data pipeline. So, go ahead and try it out for yourself, and see how it can simplify your data management process. Thank you!</p><p>Check out my blog on connecting AWS services and orchestrating them through Airflow. <a href="https://medium.com/aws-tip/how-to-use-apache-airflow-to-upload-data-to-an-s3-bucket-on-aws-529643695867">Click here</a></p><p>— — — — —Snowflake Core Certification 2023 Practice Sets Course -— — — —</p><p>If you’re looking to advance your knowledge and skills in data warehousing and analytics, consider enrolling in the Udemy Snowflake Core Certification course. Snowflake is rapidly becoming one of the most popular cloud-based data warehousing platforms available today. As businesses increasingly rely on data to make critical decisions, having the skills and expertise to manage and analyze that data effectively is more important than ever.</p><p><a href="https://www.udemy.com/course/snowflake-snowpro-core-certification-2023-practice-sets/?referralCode=D9755936C300A61FA7A4">https://www.udemy.com/course/snowflake-snowpro-core-certification-2023-practice-sets/?referralCode=D9755936C300A61FA7A4</a></p><p>Clearing the Snowflake Core Certification is a great way to demonstrate your expertise in using Snowflake to manage and analyze data. It is a globally recognized certification that is highly valued by employers, and having it on your resume can help you stand out in a crowded job market.</p><p>By taking this course and clearing the Snowflake Core Certification, students can not only demonstrate their expertise to potential employers but also gain the skills needed to succeed in a data-driven world. So if you’re looking to advance your career in data warehousing and analytics, consider enrolling in my Udemy Snowflake Core Certification course today.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d0e927a3fa87" width="1" height="1" alt=""><hr><p><a href="https://medium.com/apache-airflow/orchestrate-fivetran-with-apache-airflow-d0e927a3fa87">Orchestrate Fivetran using Apache Airflow</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[How to use Apache Airflow to upload Data to an S3 bucket on AWS]]></title>
            <link>https://awstip.com/how-to-use-apache-airflow-to-upload-data-to-an-s3-bucket-on-aws-529643695867?source=rss-2385f1e2ebc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/529643695867</guid>
            <category><![CDATA[s3-bucket]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[airflow]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Rajesh Ku. Rout]]></dc:creator>
            <pubDate>Mon, 13 Mar 2023 13:53:39 GMT</pubDate>
            <atom:updated>2023-04-24T19:06:17.672Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ucc31xW-jCOf8-35Y_SP3g.png" /></figure><p>In today’s world, businesses rely heavily on cloud-based solutions to manage their operations. Amazon Web Services (AWS) is one such cloud platform that offers a wide range of services for computing, storage, database management, analytics, and more. However, managing these services and orchestrating them can be challenging, especially when it comes to complex workflows involving multiple services. That’s where Apache Airflow comes in.</p><p>Apache Airflow is an open-source platform that allows you to programmatically author, schedule, and monitor workflows. It provides a simple and flexible way to connect and orchestrate different AWS services to build complex data pipelines and workflows. In this blog, we will explore how Airflow can be used to connect and orchestrate AWS services to build data pipelines, process data, and automate tasks. We will also look at some best practices for designing and managing Airflow workflows in AWS. By the end of this blog, you will have a good understanding of how to leverage Airflow to manage your AWS S3 Service efficiently and effectively.</p><p>In this blog, we will explore how to upload API data from a Python task to AWS S3 using Apache Airflow. AWS S3 is a highly scalable and reliable object storage service, and Apache Airflow is an open-source platform that allows you to programmatically author, schedule, and monitor workflows. We will start by providing a brief overview of AWS S3, Apache Airflow, and how to access an API in Python. Then, we will dive into how to use Airflow to download data from an API and upload it to S3. We will cover topics such as setting up an S3 bucket, configuring an Airflow connection to S3, creating a Python task to access the API, and creating an Airflow DAG to upload data to S3. By the end of this blog, you will have a good understanding of how to use Apache Airflow to automate the process of uploading API data from a Python task to AWS S3, which can save you time and effort in your data management workflows.</p><p>If you haven’t installed Airflow locally yet, <a href="https://medium.com/@routr5953/installing-airflow-on-windows-without-docker-in-5-mins-21d16091ebc5">click here</a> to do so.</p><h4>Step 1:- Install the Amazon Provider on your Airflow instance</h4><p>→ Run</p><pre>pip install apache-airflow-providers-amazon</pre><h4>Step 2:- Restart your Airflow webserver and Scheduler</h4><p>If you are using Docker, Kubernetes, or Airflow Managed Services like AWS, Azure, or GCP, then <strong>skip this step</strong>.</p><p><strong><em>Webserver:-</em></strong></p><pre>airflow webserver -p 8080</pre><ul><li>8080 is port no.</li></ul><p><strong><em>Scheduler:-</em></strong></p><pre>airflow scheduler</pre><h4>Step 3:- Create a Connection on Airflow UI</h4><p>→ Click on <strong>Admin </strong>→ <strong>Connections</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Rg9KpVi3P2SVAu-1" /><figcaption><strong>Airflow UI</strong></figcaption></figure><p>→ Click on the <strong><em>+</em></strong> Icon to add a connection</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/0*AMFj8O9_1nTUTL3Z" /></figure><p>→ Edit the Connection with your AWS User details</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*wu7glD1C5cU64NMA1Q2OnQ.png" /><figcaption><strong>Choose Amazon Web Services as the Connection Type</strong></figcaption></figure><p><strong>Arguments:-</strong></p><ul><li><strong><em>Connection ID: </em></strong>Name of this Connection</li><li><strong><em>Connection Type:</em> </strong>Amazon Web Services for S3 and other Services</li><li><strong><em>AWS Access Key ID:</em></strong> Access Key ID of your AWS user.</li><li><strong><em>AWS Secret Access Key:</em></strong><em> </em>Secret Key of your AWS User</li></ul><blockquote>If you don’t have an AWS Access Key ID and AWS Secret Key, then go to your AWS Account, click <strong>I AM </strong>→ <strong>Users</strong>,” and then “<strong>Generate Access and Secret Key.</strong>”</blockquote><h4>Step 4:- Create a Python Task to call the public API</h4><pre>from datetime import datetime, timedelta<br>from airflow import DAG<br>from airflow.operators.python_operator import PythonOperator<br><br># Python Function to call Public API <br>def api_call(**kwargs):<br>    <br>    ti = kwargs[&#39;ti&#39;]<br>    url = &#39;https://api.publicapis.org/entries&#39;<br>    response = requests.get(url).json()<br>    df = pd.DataFrame(response[&#39;entries&#39;])<br>    ti.xcom_push(key = &#39;final_data&#39; , value = df.to_csv(index=False))<br><br># We are using xcom to transfer the data from python task to S3 task <br><br>with dag:<br><br><br>    api_hit_task = PythonOperator(<br>        task_id = &#39;API-Call&#39;,<br>        python_callable = api_call,<br>        provide_context = True,<br>        <br>    )<br> </pre><p>Here, we are using XCOM to transfer the API data from the Python task to the S3 task. Our data size is very small, which is why we are using Xcom to do this. In case you want to transfer large amounts of data, instead of using XCOM, use boto3 and other Python modules to upload the data directly into the S3 bucket using the same Python function, or we can use S3 operators in the same function to do so.</p><h4><strong>Step 5:- Create a Task to upload Data to the S3 bucket</strong></h4><pre>from datetime import datetime, timedelta<br>from airflow import DAG<br># Import below module to work with S3 operator<br>from airflow.providers.amazon.aws.operators.s3 import S3CreateObjectOperator<br><br>with dag:<br> <br>    Upload_to_s3 = S3CreateObjectOperator(<br>        task_id=&quot;Upload-to-S3&quot;,<br>        aws_conn_id= &#39;AWS_CONN&#39;,<br>        s3_bucket=&#39;airflow-s3-bucket&#39;,<br>        s3_key=&#39;rajesh/Api_Data.csv&#39;,<br>        data=&quot;{{ ti.xcom_pull(key=&#39;final_data&#39;) }}&quot;,    <br>    )<br><br>    api_hit_task &gt;&gt; Upload_to_s3</pre><ul><li><strong><em>aws_conn_id: </em></strong>The connection we created in the Airflow UI, we have to give that connection Id</li><li><strong><em>S3_bucket:</em></strong> S3 bucket name</li><li><strong><em>S3_key:</em></strong> File Name <em>(</em><strong><em>API_Data.csv</em></strong><em> is the File name to be uploaded)</em></li><li><strong><em>data: </em></strong>Data we want to upload in the file (We are using XCOM to pull the API data from the API python Task)</li><li><strong><em>replace:</em></strong></li></ul><p><strong><em>a) True: — </em></strong>If in case we already have the file then it will replace the old file with the new one.</p><p><strong><em>b) False: — </em></strong>It will create a new file in the Bucket</p><h4>Step 5:- Trigger the DAG</h4><p>After a successful DAG run, we can see our ‘ Api_Data.csv ’ file has been uploaded to our S3 bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l_zal_gceTtHg2EnKpxkcQ.png" /><figcaption><strong>API_Data.csv is uploaded</strong></figcaption></figure><p>If you download the file and open it. I can see the Data I passed through Airflow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eRt0SvBbR2zRVhqwzU7dSA.png" /><figcaption><strong>API data we got from the Public API</strong></figcaption></figure><p>In conclusion, using Apache Airflow to upload API data from a Python task to AWS S3 can be a powerful tool in your data management workflows. By automating the process of accessing an API, downloading data, and uploading it to S3, you can save time and effort while ensuring your data is stored in a reliable and scalable object storage service. In this blog, we covered the basic steps for setting up an S3 bucket, configuring an Airflow connection to S3, creating a Python task to access the API, and creating an Airflow DAG to upload data to S3. We hope that this blog has provided you with a good understanding of how to use Apache Airflow to streamline the process of uploading API data from a Python task to AWS S3, and that it will help you in your future data management projects.</p><p>— — — — — — Snowflake Core Certification 2023 Practice Sets Course — — — —</p><p>If you’re looking to advance your knowledge and skills in data warehousing and analytics, consider enrolling in the Udemy Snowflake Core Certification course. Snowflake is rapidly becoming one of the most popular cloud-based data warehousing platforms available today. As businesses increasingly rely on data to make critical decisions, having the skills and expertise to manage and analyze that data effectively is more important than ever.</p><p><a href="https://www.udemy.com/course/snowflake-snowpro-core-certification-2023-practice-sets/?referralCode=D9755936C300A61FA7A4">https://www.udemy.com/course/snowflake-snowpro-core-certification-2023-practice-sets/?referralCode=D9755936C300A61FA7A4</a></p><p>Clearing the Snowflake Core Certification is a great way to demonstrate your expertise in using Snowflake to manage and analyze data. It is a globally recognized certification that is highly valued by employers, and having it on your resume can help you stand out in a crowded job market.</p><p>By taking this course and clearing the Snowflake Core Certification, students can not only demonstrate their expertise to potential employers but also gain the skills needed to succeed in a data-driven world. So if you’re looking to advance your career in data warehousing and analytics, consider enrolling in my Udemy Snowflake Core Certification course today.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=529643695867" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/how-to-use-apache-airflow-to-upload-data-to-an-s3-bucket-on-aws-529643695867">How to use Apache Airflow to upload Data to an S3 bucket on AWS</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fix Ubuntu on WSL that failed to boot after reinstalling]]></title>
            <link>https://medium.com/@routr5953/fix-ubuntu-on-wsl-that-failed-to-boot-after-reinstalling-d8041450ab71?source=rss-2385f1e2ebc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8041450ab71</guid>
            <dc:creator><![CDATA[Rajesh Ku. Rout]]></dc:creator>
            <pubDate>Mon, 13 Mar 2023 12:02:29 GMT</pubDate>
            <atom:updated>2023-03-13T12:02:29.738Z</atom:updated>
            <content:encoded><![CDATA[<p>While Installing Ubuntu on WSL, the following error messages may appear and it may not boot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*1FiPenUtHDSZ8JPkla-GRA.png" /></figure><p>This can be fixed by performing the initialization process that Ubuntu on WSL performs on the first boot. Reinstalling Ubuntu will not perform the initialization process because the registration information in the system is still there.</p><p>Follow the below steps to Fix this Issue</p><h4>Step 1:- Launch Windows <strong><em>Powershell</em></strong></h4><p>→ Run the below Command to get the registered Ubuntu</p><pre>wsl -l</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*BqX1sp0Q6FgU3X8luN3Xng.png" /><figcaption><strong>We can see all registered distributions on our system</strong></figcaption></figure><h4><strong>Step 2:- Unregister Ubuntu</strong></h4><pre>PS C:\Users\User&gt; wsl --unregister Ubuntu<br><br>Unregistering.<br>The operation completed successfully.</pre><h4><strong>Step 3:- Launch Ubuntu</strong></h4><p>→ Perform the Initialization process</p><ul><li><em>Search for </em><strong><em>Ubuntu </em></strong><em>on </em><strong><em>Search Bar</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*NZHjHBNqX-zJAMiOokQpBw.png" /><figcaption><strong>Click on Ubuntu App</strong></figcaption></figure><ul><li><em>Enter your </em><strong><em>Username </em></strong><em>and </em><strong><em>Password </em></strong><em>to complete the Initialization</em></li></ul><pre>Installing, this may take a few minutes...<br>Please create a default UNIX user account. The username does not need to match your Windows username.<br>For more information visit: https://aka.ms/wslusers<br>Enter new UNIX username:</pre><p>That’s it. You should be logged in to your ubuntu instance successfully.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rsQQUxVCw3AYmFXBHxP2fQ.png" /></figure><p>If you want to install <strong>Airflow </strong>on it then click the below link to read my blog on it.</p><p><a href="https://medium.com/@routr5953/installing-airflow-on-windows-without-docker-in-5-mins-21d16091ebc5">Install Airflow on Windows without Docker or Virtual Box in 5 mins</a></p><p>Please Like and follow my account for more such interesting content regarding Data Engineering. Thank you</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8041450ab71" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solved “WslRegisterDistribution failed with error: 0x80370114”]]></title>
            <link>https://medium.com/@routr5953/solved-wslregisterdistribution-failed-with-error-0x80370114-99c82076244f?source=rss-2385f1e2ebc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/99c82076244f</guid>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[wsl-2]]></category>
            <dc:creator><![CDATA[Rajesh Ku. Rout]]></dc:creator>
            <pubDate>Fri, 10 Mar 2023 17:20:53 GMT</pubDate>
            <atom:updated>2023-03-11T02:58:48.045Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GnegqX7WO8hWt4Aw9ajr8w.png" /><figcaption>Error Screenshot</figcaption></figure><p>In this article, we will see how to solve the WslRegisterDistribution failure with error: 0x80370114 if you are also getting this error in your System. Sometimes when you are trying to install Linux on WSL then you might have observed this WslRegisterDistribution failed with error: <strong>0x80370114</strong>. This error usually occurs when the Hyper-V service is blocked during the Linux installation. Without the <a href="https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v">Hyper-V</a> service up and running, Linux installation won’t start. There could be a few reasons for the Hyper-V service not running in your System. We will see all those reasons along with the steps to solve the error.</p><p>So in some cases when we try to install Ubuntu, we may end up getting WslRegisterDistribution failed with error: 0x80370114 error as you can see below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YauRwb0FX0OMdejQugoIvg.png" /><figcaption>Error Prompt while installing Ubuntu on CMD</figcaption></figure><p>The above error could occur due to multiple reasons, one of the most frequent reasons is that Hyper-V is currently not enabled in your System. This means Hyper-V Host Compute Service, aka vmcompute.exe which is responsible for making the Hyper-V service up and running is currently not enabled. Along with this, Virtual Machine Worker Processaka vmwp.exe which is responsible for running the instances in Hyper-V hosts is also not enabled. So here we are going to enable both features using CLI mode and then we will verify the enabled feature in Program settings.</p><h4>Step 1:- Enable-Feature</h4><p>In the first step, you need to enable Microsoft Windows Subsystem the feature. To enable this feature, open the <strong>CLI</strong> terminal in administrator mode and run the command as shown below.</p><pre>dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PUxjkeLHQhn0eQMmX9wKQA.png" /></figure><p>Next, you need to enable another feature called VirtualMachinePlatform using the below command.</p><pre>dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RtI20zVu8tkZwjSSwH4bjA.png" /></figure><p>Now, <strong><em>Restart your system,</em></strong> and once restarted, follow the below step.</p><h4>Step 2:- Verify Exploit Protection Settings</h4><p>First, Search for Turn Windows features on or off on Search Bar</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*VYj4ElGjaEflJ5V32Ip_pA.png" /></figure><p>Make sure Hyper V the feature is checked on Turn Windows features on or off as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*0-CP_C9GtKHiObcZQTQ1qA.png" /></figure><p>Then you need to search Windows Security in the search bar as shown below. Once it shows up, tap on it to open.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*ifH0JCsB9aWXXb04GRhEng.png" /></figure><p>→ You need to click on App &amp; browser control Icon</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*nvlwMo7mGeqiaJ_oIP1wfA.png" /></figure><p>→ Now click on Exploit protection settings under Exploit protection as highlighted below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*Lvm7ybOQEQ52D6KCnUstCw.png" /></figure><p>→ Make sure under System settings → <strong>Control Flow Guard (CFG) </strong>should be <strong><em>‘ ON ’ </em></strong>by default.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*h3ItZbbTexOAwCvoLhR0xQ.png" /><figcaption>.</figcaption></figure><p>→ Under Program settings, you need to make sure both vmcompute.exe and vmwp.exe are available with the Control Flow guard set to below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*KLNBMCLBTxBifQVP23t_nw.png" /></figure><p>If in case, You can&#39;t see these two programs then follow the below steps to add both programs:</p><p>a) Click on Add Program to customize→ Choose exact file path</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*tGvAhrU6d_134WmxpexbmQ.png" /></figure><p>b) <strong>Go to the path:- </strong>C:\Windows\System32→ Add both programs as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*JswCBakmI0HkhrFFPX_-KA.png" /><figcaption>Both highlighted programs need to be added</figcaption></figure><blockquote>In this step, for some users, this may not be available. In that case, go to the path C:\Windows\System32 and add all the programs starting with a prefix <strong>vm</strong> as shown below:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/1*m0fuXd_Vkbw0yLmnt5MNog.png" /><figcaption>Add all highlighted programs</figcaption></figure><p>c) After adding each program, you will see the Program settings prompt. Make sure under CFG, all options are checked in as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*hiyB3RW7kFZ1bJjHgyRNGg.png" /></figure><p>d) Do these steps for all the programs.</p><p>After validating the programs under system settings and program settings, if you now try to start installing Ubuntu again, you will notice that it will start successfully as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*S6zwCwOtPq2l2NpeL2P74Q.png" /></figure><p>If after following the above steps, you are still getting the same error then you need to check your default WSL version. You need to<strong> set your default </strong><strong>WSL version to </strong><strong>2</strong> and then <strong>restart the system </strong>one more time to see if it now fixed the issue.</p><p><strong>→ Run</strong></p><pre>wsl --set-default-version 2</pre><p>This is it! I hope this will help you to successfully install Ubuntu on your system using WSL. In case you are still stuck somewhere then please let me know your queries in the comment box !! Thank you…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99c82076244f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>