<?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 Amos Eda on Medium]]></title>
        <description><![CDATA[Stories by Amos Eda on Medium]]></description>
        <link>https://medium.com/@amos.eda?source=rss-8c2b759efa9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*MoVGYaqkOP9G0c3x</url>
            <title>Stories by Amos Eda on Medium</title>
            <link>https://medium.com/@amos.eda?source=rss-8c2b759efa9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 14:46:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amos.eda/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[Talking to Data — Building a Conversational Layer to your Database using Telegram]]></title>
            <link>https://medium.com/@amos.eda/talking-to-data-building-a-conversational-layer-to-your-database-using-telegram-b17ccd046e31?source=rss-8c2b759efa9------2</link>
            <guid isPermaLink="false">https://medium.com/p/b17ccd046e31</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[telegram]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[stock-market]]></category>
            <dc:creator><![CDATA[Amos Eda]]></dc:creator>
            <pubDate>Sun, 08 Feb 2026 19:24:37 GMT</pubDate>
            <atom:updated>2026-02-08T19:33:09.939Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Talking to Data — Building a Conversational Layer to your Database using Telegram</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*ezJN9UpRXXTDntgKq5A46g.jpeg" /></figure><p>You ever tried asking ChatGPT, Gemini, Claude or for that matter any AI agent about the stock market?<br>If your questions are similar to the following:</p><blockquote>Hey ChatGPT, can you tell me the current price of the stock market. <br>Hey ChatGPT, what’s the current volatility for NVDA. <br>Hey ChatGPT, what’s the current analyst rating for AAPL.</blockquote><p>Then you’d have decent luck. You would get a response that’s fitting.</p><p><strong>Let’s turn up the gears.</strong><br>Let’s ask more nuanced questions.</p><blockquote>Hey ChatGPT, can you get me the number of times stock Coca-Cola and Pepsi hit 52-week highs and can you get me the correlation between the strike rate of both stocks</blockquote><p>It would probably return you a blank stare</p><p>ChatGPT will probably either:<br>1) Evade the question by responding in text, or<br>2) Spit out a Python script (which technically does the job, but not for you).</p><p>Even if you use agent mode, you’d still have little to no luck — because you’d need an API key.<br>And even if ChatGPT (or any other AI agent) tries to pull this data from an open-source dataset, it’s likely to hit rate-limit errors. Most open-source finance datasets come with strict API limitations.<br>This leaves very little room for analysts to actually play around — especially when they already have their own data, curated through their own research, that they want to talk to</p><p>With the increasing evolution of LLMs, It has become more and more easier for someone to “talk” with data, as opposed to querying information by having niche knowledge of query syntax.</p><p>To overcome that barrier — of communicating with data — was the core idea behind this project.</p><p>The goal was simple:</p><p>To be able to draft ideas and use any mode of communication possible to talk with your database, and get answers that aid decision-making or analysis.</p><blockquote>I want to load stock market data into my database</blockquote><p>Great. There’s an MCP server for that.</p><blockquote>I want to understand why my stock is falling while the S&amp;P 500 is rising? <br>What’s causing the negative correlation? <br>And I want those answers quick?</blockquote><p>Great. There’s an MCP server for that.</p><p>This project is going to cover the key architecture behind a platform that enables users to interact with their database — just as if they were having a chat with their friends.</p><p>So let’s get into the implementation.</p><h3>Core Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*2NY8rJi5rWpy68Ef5zGk5g.png" /></figure><h3>Prerequisites</h3><p>Installing node js : Ensure you have npm installed on your desktop . In order to install this you can check out this website <a href="https://nodejs.org/en/download">https://nodejs.org/en/download</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b7pVQ0lqE5Ai6SRoHLw91w.png" /></figure><p>Now for the implementation</p><h4>Step 1: Installing Openclaw</h4><p>Once installed check if npm gets installed . You can check this by trying the following command</p><pre>npm --version</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/1*1VzniFr2wf7W1JTMoJ5Sng.png" /></figure><p>Once npm is installed . Open cmd as adminstrator</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*tPrCacy5RzsSFD5lAijZFA.png" /></figure><p>And install openclaw using the following command</p><pre>npm install -g openclaw@latest</pre><p>Register openclaw service as background service .</p><pre>openclaw onboard --install-daemon</pre><p>During the quick setup , set the following . This is very important</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*YQHLnOKFDlE5giPeowBTgA.png" /></figure><p>Also ensure that you are using chatGPT codex . Unfortunately this requires paid subscription . <br>20 dollars a month . My reccomendation ? Get it if you can . The scope of codex is not limited to this project and can be expanded to lot more use cases .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/1*xY6yEpkt1pWIR0cQD7Mcjg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/1*FCa06z_I_0D-875dGodadA.png" /></figure><p>Sign in using your gmail (Or whichever platform you have used to register on chatGPT)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*o5_7v1uPHaWJ6dHCB_LuTQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*jkkx3eOV0mx6_juMG-3S5g.png" /></figure><p>Once authenticated you should see a page similar to the following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wa8IrW6C-AwbBDyqhAkqoA.png" /></figure><p>Copy that link at the top and paste it in your cmd (If the command prompt hasnt authenticated and proceeded already . Sometimes , command prompt will have tough time to getting feedback from webbrowser in which case you can assist by providing the authenticated URL yourself. I burnt my hands twice with this one)</p><p>You should now get a messge the resembles the following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*uHnkvXh_0mP27PiXeT6ywA.png" /></figure><p>Awesome! You have just configured two services with your clawdbot! OpenAI(ChatGPT) and Telegram . Lets move on</p><p>Start openclaw start service</p><pre>openclaw gateway --port 18789</pre><p>Start dashboard service</p><pre>openclaw dashboard</pre><p>Once thes dashboard starts you should see the following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2ZabWgImY70l7339yRfxxg.png" /></figure><p>Awesome you are now done with openclaw setup on your local desktop</p><h4>Step 2: Setting Up Telegram as the Interaction Layer</h4><ol><li>Install Telegram on your mobile device (Android / iOS)</li><li>Sign in using your phone number</li><li>Make sure your account is verified and active</li><li>In Telegram search, type: BotFather</li><li>Open the verified account (blue check)</li><li>Tap “Start”</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n_zjIb7J-m5Ts5pyFsNGGg.jpeg" /></figure><p>7. In the BotFather chat, send: `/newbot`</p><p>8. BotFather will ask for:<br>9. Bot name → friendly name (e.g., `OpenClaw Agent`)<br>10. Bot username → must end with `bot` <br> Example: Clawdbot</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zp9smD7DM5wmFgv18kXk-A.jpeg" /></figure><p>You should get a reponse like the following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*YwlkL7ZnSdOB-Ci8xcn1Lw.png" /></figure><p>Save this token securely<br>- This is the password for your bot<br>- Anyone with this can control it</p><p>11. To integrate your bot with openclaw , Go to the UI and add the token at following location</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vUl_PklcX14BjoC5kg1kJA.png" /></figure><p>After this , the telegram channel will get integrated .</p><p>You can test this by sending a message on telegram .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zSxLyFBUw_MeYFAN7nXMPg.png" /></figure><p>You will find the same message in the chat session</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EecSoO9SFIwchaDROq397w.png" /></figure><h4>Step 3: Local Database Setup (MySQL + DBeaver)</h4><ol><li>Before pulling market data, I needed a local database.</li></ol><p>I installed:<br>- MySQL as the database engine<br>- DBeaver as the GUI</p><p>There are many ways to skin a cat . My personal favorite : Using choclatey<br>Chocolatey is installation manager for powershell . It aids in installation and requires minimum intervention from users.</p><p>Open powershell as admin</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*SxgN9hnpRQe1D-z0GVuA6w.png" /></figure><p>2. Run the following commands</p><pre>Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString(&#39;https://community.chocolatey.org/install.ps1&#39;))</pre><p>wait for few seconds it should be installed within no time</p><p>3. Install MySQL using Chocolatey</p><pre>choco install mysql -y</pre><p>This installs:<br>1) MySQL Server (usually MySQL80)<br>2) Command-line client<br>3) Registers Windows service<br>No GUI, no MSI clicks.</p><p>4. Verify installaion</p><pre>mysql - version</pre><p>If not found:</p><pre>refreshenv</pre><p>(or reopen PowerShell)</p><p>5. Start MySQL service</p><pre>Get-Service MySQL*</pre><p>Then:</p><pre>Start-Service MySQL80</pre><p>Check:</p><pre>Get-Service MySQL80</pre><p>Status should be Running.</p><p>IMPORTANT NOTE : During the mySQL process, if you’re prompted to set a password . Leave it blank or set your own password that you will later use during Dbeaver-&gt; mySQL Integration</p><p>6. Install DBeaver <a href="https://dbeaver.io/">https://dbeaver.io/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*ubE9ejcGWERtsnF5dXCuzw.png" /></figure><p>7. After installation click on new connection on top left corner</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*rSM4kEJ4NDUu_P2NnH9SeA.png" /></figure><p>8. Choose MySQL</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*j4Dj_iYvmYwNjxI-kT-OPQ.png" /></figure><p>9. Set the following attributes .The password should be left blank</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*I33TG5PK2vziSx_AhOI_dg.png" /></figure><p>10. Click on “Test Connection” once parameters are set . This should prompt you the following message</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*4SnL4d-2MqEgz2hkKtdvvw.png" /></figure><p>And then finally click on “Finish”</p><h4>Step 4: Market Data Schema (market_data)</h4><p>With the database running, the next step was defining the schema.</p><p>This is intentionally treated as a **SQL file** — something that can live directly in GitHub and be replayed anywhere.</p><p>Example (simplified):</p><pre>CREATE TABLE market_data (<br>    ticker VARCHAR(10) NOT NULL,<br>    timestamp DATETIME NOT NULL,<br>    open_price DECIMAL(10,4),<br>    high_price DECIMAL(10,4),<br>    low_price DECIMAL(10,4),<br>    close_price DECIMAL(10,4),<br>    volume BIGINT,<br>    source VARCHAR(50),<br>    PRIMARY KEY (ticker, timestamp)<br>);</pre><p>This schema is deliberately boring.</p><p>No magic.<br>No embeddings.<br>Just clean, queryable market data.</p><p>Once this is set in your DBeaver Editor . Execute the DDL statement . This should create table that is “market data ready”</p><h4>Step 5: Market Data APIs (Free Tier)</h4><p>To populate `market_data`, I used free-tier APIs.<br>An API key will be provided to you once you register on their platform .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uDuG8SMuzvPgFr7fD0W8Vg.png" /></figure><p>Once logged in , you should see a task pane on the left that shows “keys”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vJ5O_oEPK_c7ZLJx1GJAcQ.png" /></figure><p>Choose one of the keys that you wish to use for this project .<br>Open cmd and put the following command</p><pre>set POLYGON_API_KEY = &lt;YOUR OWN POLYGON API KEY&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*0_eEbhGhXoE7juMDvZp5lg.png" /></figure><p>Note all of this is free tier .So dont worry about subscription cost .</p><p>I set the environment variables in my local desktop. And this step is very important because the last thing you want is to get your Polygon API key compromised . <br>You see the below architecture below?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*cJycpHVpUYTdgrMO0SWHdA.png" /></figure><p>The environment variable is ONLY accessible to MCP server . It IS NOT (AND SHOULD NOT BE ) accessible to chatGPT , clawdbot or any other affiliated AI agent . Remember , clawdbot doesent have guardrails . And you should be extremely careful which entities you share your API keys with. Make sure that ONLY the MCP server has access to you Polygon API Key</p><p>This brings me to final step</p><h4>Step 7: MCP Servers (Generated by Clawd Bot)</h4><p>What is an MCP server? <br>An MCP server exposes your tools, data, or services in a **standard way** so an AI (or agent like OpenClaw) can use them safely and consistently.<br>Instead of the AI “guessing” how to talk to MySQL, files, APIs, or scripts, the MCP server says:</p><blockquote>“Here’s how to ask me. Here’s what I can do. Here’s what I’ll give back.”</blockquote><p>Imagine you’re traveling internationally.<br>- <strong>Your devices</strong> = databases, scripts, APIs, files<br>- <strong>Different outlets</strong> = different protocols, auth, formats<br>- <strong>MCP server</strong> = a travel adapter</p><p>You don’t redesign your charger for every country. <br>You plug into the adapter, and everything just works.</p><p>How can I create my own MCP server?<br>This is where Clawd Bot <strong>can </strong>do most of the heavy lifting.</p><p>You can <strong>write the MCP server yourself </strong>— full control, full responsibility, every comma your problem.<br><strong>Or</strong> you can ask <strong>Clawdbot to generate one for you</strong> — which is basically like appointing a <strong>state-owned lawyer</strong>. <br>It’s technically on your side, it follows the rules, it files the paperwork correctly… but don’t expect flair, creativity, or going the extra mile unless you explicitly ask. If you are making use of Clawdbot make sure you review the code for those MCP servers. Last thing you want is the python/Nocde script sending sensitive information to codex .</p><p>Following is code snippet which ensures the environment variable is accessed exclusively from MCP server script <a href="https://github.com/amos-eda-97/Telegram-Bot-OpenClawd/blob/main/mcp-mysql-server/src/index.ts">https://github.com/amos-eda-97/Telegram-Bot-OpenClawd/blob/main/mcp-mysql-server/src/index.ts</a></p><pre>const apiKey = env(&quot;POLYGON_API_KEY&quot;);<br>    if (!apiKey) {<br>      throw new Error(<br>        &quot;POLYGON_API_KEY is not set. Set it in the MCP server env (Cursor mcp.json env) rather than in prompts.&quot;<br>      );<br>    }</pre><p>You can find this in index.ts that I linked above. <br> Another alternative , you can clone my repo into your own openclaw workspace</p><pre>  git clone git@github.com:amos-eda-97/Telegram-Bot-OpenClawd.git</pre><p>The location should be something similar to the following C:\Users\&lt;YOUR_USERNAME&gt;\.openclaw . If you are still unsure about this path , you can check it by running gateway service command . (NOTE : If you have followed the instruction upto this point then note that you have already run this command earlier above .Make sure that at any point there is only one gateway service running . Not more than 1 . )</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BvfrWd83fokmhX5_RCJAxQ.png" /></figure><p>You can check here the location where openclaw files are present . In this case its right uptil openclaw(Not canvas . )</p><p>Once the repo has been cloned type the follwoing prompt to openclaw</p><pre>I have cloned mcp servers in your workspace , can you acknowledge and use that to populate financial data</pre><p>This should configure your two MCP servers to work accordingly with your SQL server .</p><h3>Time to test !</h3><p>Results look satisfactory given the commincation bridge.</p><p><a href="https://youtube.com/shorts/qUYdew_umLE?feature=share">https://youtube.com/shorts/qUYdew_umLE?feature=share</a></p><p>If you were able to follow this video and reach till this point . Then congratulations! You are now proud owner of AI bot that can do custom analysis based on data that you have in your database. Hope you liked this article, please do give your feedback. It helps me bring better ideas to this platform .</p><p><em>To infinity and beyond</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b17ccd046e31" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[End to End Data Engineering Project #3 — Pt 4/4 : Production Level Migration from S3 to Snowflake…]]></title>
            <link>https://medium.com/@amos.eda/end-to-end-data-engineering-project-3-pt-4-4-production-level-migration-from-s3-to-snowflake-9ee418caa74d?source=rss-8c2b759efa9------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ee418caa74d</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[snowflake]]></category>
            <dc:creator><![CDATA[Amos Eda]]></dc:creator>
            <pubDate>Wed, 08 Nov 2023 22:15:10 GMT</pubDate>
            <atom:updated>2023-11-08T22:15:10.388Z</atom:updated>
            <content:encoded><![CDATA[<h3><a href="https://medium.com/@amos.eda/end-to-end-data-engineering-project-3-pt-1-4-production-level-migration-from-s3-to-snowflake-ee89575d0438">End to End Data Engineering Project #3 — Pt 4/4 : Production Level Migration from S3 to Snowflake</a> using Docker, DBT and AWS Services</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*7GEvl-btKKnILMuo.gif" /></figure><p>In this article ,We will be utilizing docker along with AWS services to <strong>package </strong>and <strong>deploy </strong>the DBT code . If you didnt get a chance to go through the previous tutorials, then I highly recommend you visit them .</p><h4>Previous Tutorials</h4><ol><li><a href="https://medium.com/@amos.eda/end-to-end-data-engineering-project-3-pt-1-4-production-level-migration-from-s3-to-snowflake-ee89575d0438">Basics for the project</a></li><li><a href="https://medium.com/@amos.eda/end-to-end-data-engineering-project-3-pt-2-4-production-level-migration-from-s3-to-snowflake-6f11224cab87">Implementation of DBT</a></li><li><a href="https://medium.com/@amos.eda/end-to-end-data-engineering-project-3-pt-3-4-production-level-migration-from-s3-to-snowflake-231a2d0c1705">Staging data from External tables to Local Tables</a></li></ol><p><strong>NOTE</strong> : Please keep in mind that I have put the numbering(for instructions) based on on previous tutorials. If you want to check the previous instructions ,you can simply revisit the previous tutorials.</p><p>That said , lets jump into this tutorial and get started !</p><h4>Pre-requisites</h4><p>Make sure that docker is up an running . If you are having docker desktop then make sure that the docker engine is up and running . If you dont have docker set up , then please follow the instructions at this <a href="https://www.youtube.com/watch?v=5nX8U8Fz5S0&amp;pp=ygUYZG9ja2VyIHNldCB1cCBvbiB3aW5kb3dz">link</a> . (It will hardly take you 15 minutes plus you can reuse docker for many other projects that I will soon post about! )</p><h4>Instructions</h4><p>67)Make sure that docker is running well in your desktop. Im using windows so I have Docker desktop . In order to make sure that docker is working properly in your desktop , go to your command line or terminal and type the following commands</p><pre>docker --version</pre><p>You should see a similar output as follows</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/427/1*ExqgppnqExVyhAWyaLigKA.png" /></figure><h4>Pitstop</h4><p>Here we are going to create a run shell script . A shell script is a list of commands that can be executed as if they are being executed in a command terminal . For example cd, mv cp . You can have all these commands in a text file and when you run that file , each command will get executed one after another . For example you have have a run_shell.sh file that has the following commands</p><pre>mv new_file new_locatoin<br>ls -a</pre><p>And the terminal will take each of the above command and execute one after another . You might have a question . Why would we need a run shell script when we already have a docker file. Isnt docker capable of running all these installations itself?</p><p>You are right! Docker is indeed capable of running the installations . But in docker you have a concept called build and runtime . There are two different kinds of executions that are taking place when a docker file is getting built .</p><p>Build execution : When you are having a build execution , all the commands are executed during the build phase or in other words when you are executing “docker build image” . Think of it as making a pizza and keeping it frozen .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*wJuIzbaJpTnwtoVyBtMsYg.png" /></figure><p>Runtime execution : On the other hand , for runtime execution you have the commands executed at the moment of execution .In other words when you hit “docker run” the commands will get executed . To give you an analogy , imagine reheating the pizza in an oven and adding condiments on top of the pizza. Lets say you want to chilli flakes, tomato sauce ,oregon etc. All these ingredients that you add during the time of consumption are similar to commands getting executed during runttime execution .</p><p>In the context of our project, we would want the few commands to get executed AT runtime. We want the “dbt run “ to be executed WHEN the docker image is getting run .</p><p>One other thing that I wanted to bring to your attention .The AWS services that we are talking about? They <strong>dont BUILD</strong> images. They directly fetch the image and go straight to run mode. Keep in mind we want to orchestrate the process of staging data from S3 to snowflake AT OUR will. We want it to happen at the click of a button .And at that click of a button ,the commands should get executed during runtime (not during build beacuse that wont happen in our AWS Architecture). Hence we have a run shell script . which runs DURING run time</p><p>67)Lets get that run shell script in order . If you remember our previous tutorial . We have executed the following commands to achieved desired results</p><pre>dbt deps<br>dbt run-operation stage_external_sources<br>dbt run</pre><p>We will use the same in our case as part of our run shell script . Execpt we will add just a few toppings on top of it .</p><p>Create a file called run_script.sh . It should be in your working directory</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/247/1*cgKFnyA2_BMK9J-cpzPilw.png" /></figure><p>Type the following code inside it</p><pre>#!/bin/bash<br>dbt deps<br>dbt run-operation stage_external_sources<br>dbt run<br>echo &quot;Successfully Finished&quot;</pre><p>68)Next we will create a Dockerfile in the working directory to make sure that all the data is packaged properly . Create a new Dockerfile in the working directory . It should be on the same level as your packages.yml</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/1*-jQQP6ny6YzrUjfD_ja8OQ.png" /></figure><p>69) Open the Dockerfile and type the following commands</p><pre># Use an official Ubuntu image as the base imageF<br>FROM ghcr.io/dbt-labs/dbt-snowflake:1.5.5<br>ENTRYPOINT [ &quot;/bin/bash&quot; ]</pre><pre>RUN apt-get update<br>RUN apt-get -y install git bash<br>RUN git clone &lt;https://github.com/amos-eda-97/aws_to_swnoflake_dbt_repo.git&gt;</pre><pre>WORKDIR &quot;/root&quot;<br>RUN mkdir .dbt</pre><pre>WORKDIR &quot;/usr/app/dbt/aws_to_swnoflake_dbt_repo&quot;</pre><pre>RUN cp profiles/profiles.yml /root/.dbt/<br>COPY ./run_script.sh .<br>CMD [&quot;./run_script.sh&quot;]</pre><p>70)Save the file and build the docker image by opening a command prompt at the particular location.</p><p>NOTE :Make sure that the command prompt has changed directory TO the location of your working directory . If you dont have your command prompt changed to your working directory then the steps wont work .</p><p>Type in the following command</p><pre>docker build -t my_docker_image .</pre><p>You should get an ouput similar to the following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UjOyiOGVTBw-BP1ZS8lJKA.png" /></figure><p>Next run the docker file and check if its working as intended .</p><pre>docker run my_docker_image</pre><p>You should an output like following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i-n_ep0AQKV-e-mxxgi1nQ.png" /></figure><h4>Pushing Docker Image to ECR</h4><p>71)Now we are going to configure it with out AWS ECR service. Open your AWS console manager and navigate to AWS ECR</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hf7VksYD7pFPGaE6DOhgVA.png" /></figure><p>72) Create a new Repository</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/1*rDYkZCb-rCo_A1kZ4mGDSw.png" /></figure><p>73) Type a name for your repository , something that relates to this project. I have named it “dbt-snowflake”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*1uZzip8ZRJUPg31yMxpviA.png" /></figure><p>74)Create the repository</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/169/1*EppyLGfVwUSs-jEV6IghYQ.png" /></figure><p>75)You should be able to see the following output</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*D5YcW8aOOf53X6H7kjKzzg.png" /></figure><p>76)Select the repository that you have created by click on the checkbox to the left of it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/184/1*NEpR4G3EqbCIPNiY92VfTw.png" /></figure><p>77) And click on “View Push Commands ”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/363/1*NCW9fWXLctgt4nXF77U1AQ.png" /></figure><p>78)Its important to note that you would need to have your AWS CLI configured . You can check the instructions to configuring AWS CLI by visiting the following <a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html">link</a> .It shouldnt take more than 5 minutes to configure everything . A stragiht forward process thanks to exe application created by AWS team .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p9gRAXZfjPUkN7ATJhfeAg.png" /></figure><p>79)One you have followed the instructions , check if aws cli is properly installed in your command prompt by typing in the following command .</p><pre>aws help</pre><p>You should get the following output</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*b9NKoNvrE7BxfqBX7OlBPg.png" /></figure><p>This would mean that aws is properly installed .</p><p>80)Hit “wq” and then copy command one after another from instructions laid out in “View push commands” . Note: While executing these commands , please make sure that the command prompt is in the same location as the working directory</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kY4kSpZlnO2bKJOJhCSJxA.jpeg" /></figure><p>81)Once you have executed the last command , you should see an output similar to the following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e6aHMteKcuVA4ivB6cerSw.png" /></figure><p>82)Once your process is done , select the docker image that you have built</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/309/1*vymsPSzk6BDZTpElyy0DtA.png" /></figure><p>83)You should see similar output as follows</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*LTj1npNkrd8FsAqdgIf1xQ.png" /></figure><h4>Building Task from Docker Image in ECR</h4><p>84) Awesome! You have now uploaded the image successfully . Now its time to shift our attention to ECS . Lets build a task that can execute the docker image that we have just built.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*gKyDWFFUQ-pfZixJJvjHCw.png" /></figure><p>ECS builds an instance of the docker and executes it as if its on runtime . Open ECS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wnKezcJlTyl9oFSDiSxW4w.png" /></figure><p>Create a new cluster</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/206/1*EClFysnI08U0WkF6-8AXeA.png" /></figure><p>85) You can name the cluster anything that yo want .Im naming it as DockerDBT_Cluster</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*339w6-Pzg01ptKM5gxAjSg.png" /></figure><p>We will be using Fargate service. So make sure that its enabled .Hit on “Create”</p><p>86) Next up create new task definition</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bOvJVNhywzMZ7ED-Alp_CQ.png" /></figure><p>87)Create a new task definition.I have set the name for it as “DockerDBTTask” .Also make sure to set the Launch Type as AWS Fargate</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*7D4b_UUPffwDA3vst33uhw.png" /></figure><p>88) Make sure to set the CPU as 0.5 CPU and Memory as 1 GB . We dont want to set high Memory and processing as it might cost us</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*tT9L-OOHPOYsdpxsk_dQTw.png" /></figure><h4>Pitstop</h4><p>Notice how its mentioned container 1 here?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lutesCjrgnGgM2q9yalk8g.png" /></figure><p>You also have an option of adding more containers should you want</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/369/1*QbNoE9sUqyaJiZRlLkGTDQ.png" /></figure><p>These ties into our earlier discussion .Having multiple containers within a larger system</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kZ-PTyrlkxICULNZo2sOnA.gif" /></figure><p>Each OS represents a specific container. This is what is exactly happening in our ECS as well. We can choose to have multiple containers each running its own Docker image! Fascinating right?</p><p>For this exercise we will be focussing on only one docker image .Hence only one container</p><h4>Back to instructions</h4><p>89)Go to your ECR (Elastic container registry page) and check the image that you created for this project</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*AMGllpgQ9QOZY2TiM8akZw.png" /></figure><p>90)Shifting back to ECS ,We have to provide name and Image URI .Get these details from ECR! For name , you can provide any name that you want. But To avoid confusion I have given the Repo name (Of ECR itself) and for the image URI I have copied it directly from ECR</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*6JVcPTrUwURH5OAi1ykxaw.png" /></figure><p>91) Hit on create</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/208/1*KNrstWROXEomlx5W6lddcg.png" /></figure><p>92)Now go to clusters on the left panel and select the clusters</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/385/1*098KmDPvC0Om9vc7_syITA.png" /></figure><p>93) You should be able to see your Cluster as part of the list of clusters</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*MGveIfoV9bfihrKAob52NQ.png" /></figure><p>Select that cluster</p><p>94) Go to the tasks section</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*xqfFxjplP9OBugh8IIuPdg.png" /></figure><p>95)And hit on run new tasks</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*TawhY-Our9g88EBxGssaUQ.png" /></figure><p>96)Scroll down to Deployment configuration and select the family that you want to execute the task on . For this case, We have create “DockerDBTTask:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*eeggILTvhj2eLT_acnRjog.png" /></figure><p>97) Make sure that the revision is the latest. And then hit on “Create”!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*dVVjVc-MGJro4Dg5A-CxiA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/208/1*KNrstWROXEomlx5W6lddcg.png" /></figure><p>98) You should be able to notice that you task is running under the tasks section inside the cluster</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*Mv-Q3Qke5CX9fWphoX5L-g.png" /></figure><p>99) Select that particular task. After doing that select “Logs” section under which you should see “Successfully finished.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZSzPvMUmll4pp_lj8ZQj2A.png" /></figure><p>100) You have successfully executed your docker image in your ECS Task!</p><h4>Configuring Network settings</h4><p>We are doing this so that Step functions knows where to find your ECS task at . This is done using ENI(Elastic network interface) .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*xDGhN_2J0AuzUyiMzIgjEA.gif" /></figure><p>If your ECS isnt allotted a public VPC its going to be very tough for step function to execute ECS task . How can it execute an ECS task if it cant find it!</p><p>101) Lets created a dedicated VPC for our ECS task . You can do that by navigating to VPC in AWS console</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*O0Z7x9rMsLsWblXR4Id3Pw.png" /></figure><p>102) Choose your region where all your work has been done so far. I have created all my resources in North Virginia.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*RR9q45sOBUJTu7FqdW2erQ.png" /></figure><p>103) Create a VPC Group</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*V18rxQs1S8LFJQSluUaIuQ.png" /></figure><p>104)You should see the following resource map on the right side .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RKWNWxJuRntZtZUpcyAnMA.png" /></figure><p>This will give you a list of subnets .</p><p>105)Create a VPC .</p><p>106) View VPC</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/1*egLQZX6FHBISybaM9fXzTg.png" /></figure><p>Please note down this VPC . We will be using at a later stage .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/1*dnfQIL8RH9rHjHCcgvoD1A.png" /></figure><p>107) Open one of the public subnet .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-pmity1d48_6GGGSi33Enw.png" /></figure><p>108) Select a public Subnet . We would want to go for public, because that will make sure Step functions can easily find ECS Task</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*8fCXDt9OomCJOs7dwip3hw.jpeg" /></figure><p>Copy the subnet into a notepad .We will be using this at a later stage .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vIlcvm-o-eRTQRNpxfdSGw.jpeg" /></figure><p>109) Go to your AWS console and search for “Securtiy Groups”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*G68np8xIY1Vq0djOMWWkWA.png" /></figure><p>110)Go to security group section</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*aRYzFxWDBJvzIJrIPx2QqA.png" /></figure><p>111) For this exercise , we will be creating a new security group with new VPC .</p><p>Here is where things get tricky . Do you remember the VPC that you noted down in step 111 . We need to use that for this stage . Create a Security group for this .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*RuJsf_AajEWaG5upUQ09cg.png" /></figure><p>112) Create Security group with your desired name . And make sure that you change your VPC to the one that you noted down earlier .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/1*egLQZX6FHBISybaM9fXzTg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*RiV_CWd3Yn6iNy4qleJtLQ.png" /></figure><p>113) Create Security group</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/1*CVHnGNUjKANVkgf9l52TsA.png" /></figure><p>114)You will get new Security group created first</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6gDPkeZAb-TCeuogoGsuRg.jpeg" /></figure><p>Note down this Security group .You will be using this at a later stage .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/1*nHmwz0tQP-IxL8wpPfN-pw.jpeg" /></figure><p>115)Now lets shift our attention to ECS . We would need a few more details . Go to you cluster group in ECS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*OXqlIuP3OcvNTFpe28RmKA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/361/1*6JAYiy8nSG2sIVSvN8TWFA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*wJkui5ZKAUQqyFubDM0hTA.jpeg" /></figure><p>Copy this Cluster ARN into a notepad</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9R6c52rkXn8XRN68siVhKA.jpeg" /></figure><p>116) Now go to task defintion</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/1*yze4MQStkaebm9w5bTC6IA.png" /></figure><p>117)Select the one that you have created for this exercise</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/379/1*nyi2RGZF-3KVJZkwBd_e8Q.png" /></figure><p>118)The same again</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/391/1*PyU2_5O_zBEcXBBNTgdV2Q.png" /></figure><p>119) Select the ARN . Note it down into your notepad</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iictNi55oRuq_6eOn3rO_g.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D9nMmkElVRIi9PFIpPiifw.jpeg" /></figure><p>120) Now that we have all the details ,lets shift back to step functions. We will need to give all this information to run ECS task successfully</p><h4>Orchestrating ECS task Execution using AWS steps functions</h4><p>121)Navigate to AWS Step functions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UIWTRvmV2uR-XmiODfucNQ.png" /></figure><p>122) “Create State Machine”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*JNKuhriR7Ksh2KHZSmvHFQ.png" /></figure><p>123)The good thing about AWS Step functions is that you have wide array of boiler-plate architectures that you can choose from . Feel free to experiment with them at your lesiure . However for this exercise we will be choosing a very simple state flow. A Blank</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wChE-SkXnUJrVTxqkBCRdw.png" /></figure><p>124) Type in ECS and Drag and drop “Run task” into the “Drage first state here” section</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*EB636p7aO4uy1lPupv7fYg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*SnvGWoDi_P3w4oHD-lGMQg.png" /></figure><p>125) In the right panel , you should see a section called API parameters</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*lrxEVDh1JXd2PvrE7fzDsA.png" /></figure><p>126) Lets create API parameters for our current ECS task</p><p>At this space .Copy paste the following information.</p><pre>{<br>  &quot;LaunchType&quot;: &quot;FARGATE&quot;,<br>  &quot;Cluster&quot;: &quot;&lt;ECS Cluster ARN from notepad&gt;&quot;,<br>  &quot;TaskDefinition&quot;: &quot;&lt;ECS Task ARN from notepad&gt;&quot;,<br>  &quot;NetworkConfiguration&quot;: {<br>    &quot;AwsvpcConfiguration&quot;: {<br>      &quot;Subnets&quot;: [<br>        &quot;&lt;subnet from you notepad&gt;&quot;<br>      ],<br>      &quot;SecurityGroups&quot;: [<br>        &quot;&lt;SG from notepad&gt;&quot;<br>      ],<br>      &quot;AssignPublicIp&quot;: &quot;ENABLED&quot;<br>    }<br>  }<br>}</pre><p>127)There are 4 attributes that you would need to keep here. Copy paste the attributes from your notebook in here</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D9nMmkElVRIi9PFIpPiifw.jpeg" /></figure><pre>{<br>  &quot;LaunchType&quot;: &quot;FARGATE&quot;,<br>  &quot;Cluster&quot;: &quot;&lt;ECS Cluster ARN from notepad&gt;&quot;,<br>  &quot;TaskDefinition&quot;: &quot;&lt;ECS Task ARN from notepad&gt;&quot;,<br>  &quot;NetworkConfiguration&quot;: {<br>    &quot;AwsvpcConfiguration&quot;: {<br>      &quot;Subnets&quot;: [<br>        &quot;&lt;subnet from you notepad&gt;&quot;<br>      ],<br>      &quot;SecurityGroups&quot;: [<br>        &quot;&lt;SG from notepad&gt;&quot;<br>      ],<br>      &quot;AssignPublicIp&quot;: &quot;ENABLED&quot;<br>    }<br>  }<br>}</pre><p>128) Once you have done that. “Create”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/316/1*UuBDrawy89wsoq7tKQhrng.png" /></figure><h4>Pitstop</h4><p>After attempting the above step, It will ask your permission to create service linked roles .Why is it required? This will ensure that step functions will have permission to create resources or authenticate without having to ask you for permission to do a task once every 2 seconds</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*j4Ol7LkxWjy9ieC9P4XV-g.gif" /></figure><h4>Back to instructions</h4><p>129) You should get a prompt such as the following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NwBAEUT0-UgjFlY4nOmD0g.png" /></figure><h4>Pitstop</h4><p>Oops ! What just happened? Looks like things didnt work as we expected. Lets dig deep into this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XLUsINb9ppBYzdGc7XIXaQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9f7kg1Zg75j_CCfK0K06JA.jpeg" /></figure><p>What this means is that step functions doesent have the nessescary permission to execute the task . Despite having service linked role, its not able to get the relevant permissions to finish the task .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*J9NASMcNrNr9t8JOb5jtxA.gif" /></figure><p>For this reason , we will give another permission to Step functions : ECS Full Access role</p><h4>Back to instructions</h4><p>130)Click on the state machine as shown .You will be redirected to your state machine page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*dm4B3UDwpKITMWDlk8k8vg.png" /></figure><p>131)Once you are navigated , click on the IAM role</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_0Y5Nob0n-zHGnIJRoj5TA.jpeg" /></figure><p>132)You should be navigated to a IAM role page . “Add permissions”&gt;”Attatch Policies”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*Q1hjiL01agekZ-BcTjkklQ.png" /></figure><p>133) Provide ECS Full Access</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*O_twrm6y5VPa3WFTEj-B5Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*WvJKHi19i3wGqxkgQhLnuA.png" /></figure><p>Select and add permissions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*8pkRkwu22Ny1GiqkDwxL3A.png" /></figure><p>134) Now go back to your Step functions again in console manager</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*-hEycwRaUdriYAMHklPOfQ.png" /></figure><p>And start Execution</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/236/1*YZsYkHOYz8NVYv8YliSv0Q.png" /></figure><p>135) Operation Succeeded!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*qNGq_fc-Lujb6YQHR9I1sQ.png" /></figure><p>136)Scroll down bellow and select the icon that would redirect you to the ECS Task</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*16gq83nDgt8h8r7bghE8Bg.png" /></figure><p>137) Select “Logs”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*m7MUIR7zU4p_2dzysPFY1Q.png" /></figure><p>138)You should see the following message</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*ZIETX3BXI0cYB7FPu8V4gA.png" /></figure><p>139) Check snowflake .And you should see the tables reflect the changes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*R8GeMIlTAz5iwenpdGw1CA.png" /></figure><h3>Conclusion</h3><p>If you were able to follow all the instructions and you understood the purpose of all the tasks, then congratulations 🎉🎉!</p><p>You have just finished your first production level Data Migration project from S3 to Snowflake using DBT and Docker. There are ofcourse , many more nuances to this .However keeping the scope of the project in mind, I have decided to keep things beginner engaging. If you liked this article, then make sure to follow me for more such articles. Feel free to connect with me on <a href="https://www.linkedin.com/in/amos-eda-839870185/">LinkedIn</a></p><p>See you in the next tutorial .</p><p>Until then</p><p><em>…To infinity and beyond</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ee418caa74d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[End to End Data Engineering Project #3 — Pt 3/4 : Production Level Migration from S3 to Snowflake…]]></title>
            <link>https://medium.com/@amos.eda/end-to-end-data-engineering-project-3-pt-3-4-production-level-migration-from-s3-to-snowflake-231a2d0c1705?source=rss-8c2b759efa9------2</link>
            <guid isPermaLink="false">https://medium.com/p/231a2d0c1705</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[s3]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Amos Eda]]></dc:creator>
            <pubDate>Sat, 04 Nov 2023 01:48:23 GMT</pubDate>
            <atom:updated>2023-11-04T01:51:04.501Z</atom:updated>
            <content:encoded><![CDATA[<h3><a href="https://medium.com/@amos.eda/end-to-end-data-engineering-project-3-pt-1-4-production-level-migration-from-s3-to-snowflake-ee89575d0438">End to End Data Engineering Project #3 — Pt 3/4 : Production Level Migration from S3 to Snowflake</a> using Docker, DBT and AWS Services</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_26ot3i2rjoO37vA_U8aMw.png" /></figure><p>In this article, we will focus on staging data from External table to local destination table . To those who have stumbled upon this article for the first time, This article is part of an ongoing series and I would strongly suggest you to catch up with the previous tutorials to get yourself acquainted with previous tasks.</p><ol><li><a href="https://medium.com/@amos.eda/end-to-end-data-engineering-project-3-pt-1-4-production-level-migration-from-s3-to-snowflake-ee89575d0438">Basics for the project</a></li><li><a href="https://medium.com/@amos.eda/end-to-end-data-engineering-project-3-pt-2-4-production-level-migration-from-s3-to-snowflake-6f11224cab87">Implementation of DBT</a></li></ol><p>That said , lets jump into this tutorial and get started !</p><h3>Instructions</h3><p>53) Create a pckages.yml file in your working directory . Keep in mind this file should be in the exact same location where dbt_project.yml exists . They should both be in the same folder . Otherwise it wont work</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/264/1*GjcLYnl_CqCvVYeAr824ag.png" /></figure><p>54) In your packages.yml Keep the following code. This the equivalent of import libraries .</p><pre>packages:<br>  - package: dbt-labs/dbt_external_tables<br>    version: 0.8.0 # version number</pre><p>55)Once that is done rune the following command</p><pre>dbt deps</pre><p>56)You should get the following output</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*VxUN5RHifrDbCgW2aUNWIw.png" /></figure><p>57) This would mean that the packages were successfully installed .</p><h3>Pitstop</h3><p>Next , we need to bring the data from external stage table to our local table .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*eIxKSYxVXkJUxD_hy1A2qQ.png" /></figure><p>In order to do that we would need to create a new sql file that would be executed during run time and get all the nessescary files from external stage to local destination table . A small snippet of knowledge. You see the models folder here?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/327/1*6PuY-Cy5m4gq-DU-Bi-5Sg.png" /></figure><p>Within the models folder you should see an example folder by default Inside which you will find two sample sql files .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/1*04VsFvsMMkzo5Ls6GAdGiA.png" /></figure><p>What you need to know is that dbt will execute ALL sql files within “models” folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*5wymTG_9hXYyrylV5EIwkQ.gif" /></figure><p>The DBT will check for these sql files recursively and execute them one after another.</p><p>The schema file that you see in here?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*N-NaOOrLO800Ss2Bpp2rpQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*3J6b1pY9tW_2VzljQLAhbA.png" /></figure><p>Inside that, there are details as to where you would want the querries output to be stored. For example, in this case, the output querry of the first model will be saved in a table called my_first_dbt_model . (After execution) .</p><p>Want to check that out yourself? Give it a test run. Run the command “dbt run” And go to your snowflake web app . Check out your tables section, you should see that a new table is created</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/457/1*cSrpg1fY4UUQ2RbEzoNkvQ.png" /></figure><p>I hope you have a better understanding of how dbt works now . Lets shift our attention , back to the instructions .</p><p>58)We want to create another model that will allow us to fetch the data from external table into the local destination database</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*eIxKSYxVXkJUxD_hy1A2qQ.png" /></figure><p>In order to do that , Create another folder within models folder</p><p>Right click and create new folder within models folder</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/379/1*OCjWZl9t_m0ZpLJjLZur5A.png" /></figure><p>I named my folder snowflake_models</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/218/1*j_rfA9oLZ8ieF4yBuiJVwg.png" /></figure><p>59) Once you have created a new folder , create a new file within that called schema.yml (This is to provide basic configurations for the script to properly connect )</p><pre>version: 2<br><br>sources:<br>  - name: snowplow<br>    database: AWS_S3_DB<br>    schema: PUBLIC<br>    loader: S3<br>    loaded_at_field: collector_hour<br>    <br>    tables:<br>      - name: event_ext_tbl<br>        description: &quot;External table of Snowplow events stored as JSON files&quot;<br>        external:<br>          location: &quot;@AWS_STG_SNOWFLAKE&quot;  # reference an existing external stage<br>          file_format: &quot;( type = csv )&quot;      # fully specified here, or reference an existing file format<br>          auto_refresh: true                  # requires configuring an event notification from Amazon S3 or Azure<br>        <br>        # all Snowflake external tables natively include a `metadata$filename` pseudocolumn<br>        # and a `value` column (JSON blob-ified version of file contents), so there is no need to specify<br>        # them here. you may optionally specify columns to unnest or parse from the file:<br>        columns:<br>          - name: date<br>            data_type: varchar(255)<br>            description: &quot;Application ID&quot;<br>          - name: total_price<br>            data_type: varchar(255)<br>            description: &quot;A visit / session index&quot;</pre><h3>Pitstop</h3><p>Understanding schema for staging operations</p><p>This is very important for you to understand.</p><ul><li>“database” is the desitnation database that we want the data to be transfered to</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*nZrYdsb5bwfVCkkcSKCHUw.png" /></figure><ul><li>“schema” is public by default . You can refer to step 48 for further reference</li><li>tables&gt;name :“event_ext_tbl” . This is the table that will be created in the Destination DB after you run more commands in the future .(This image is for demonstration purpose , you <strong>wont</strong> see EVENT_EXT_TBL in the structure now) . You will only see this table as you execute more steps down the line.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*S2o4mdEb0Ia1IqRo_vpGVw.png" /></figure><ul><li>tables&gt;external&gt;location : @AWS_STG_SNOWFLAKE This is the external table that Im referring to</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*1e_zpXaTdyesPQTuM282Ag.png" /></figure><ul><li>sources&gt;tables&gt;columns .This section consists of the columns structure that the table EVENT_EXT_TBL should have . (The following image is for demonstration puspose only , You wont see the table reflect until you execute more steps down the line)</li></ul><h3>Back to instructions</h3><p>60) In schema.yml . Make sure to change the 5 attributes that I have stated above, <strong>according</strong> to the details that you have . In my case, I chose to name all columns to varchar. So under the columns section , you would have something like</p><pre>columns:<br>	- name: date<br>	  data_type: varchar(255)<br>	  description: &quot;Application ID&quot;<br>	- name: total_price<br>	  data_type: varchar(255)<br>	  description: &quot;A visit / session index&quot;</pre><p>Apply the same to as many columns as you have in your CSV file . It wont work as you intend if you dont provide the appropriate details for columns structure.</p><p>61)(Optional) Just to understand how SQL querry files work within DB . Create a file called my_querry.sql under snowflake_models</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/266/1*5asHydGHZXDiO6z6f9pXKA.png" /></figure><p>Once you have created the my_querry sql files . Type the following code in that file</p><pre>{{ config(<br>    materialized=&#39;table&#39;<br>) }}</pre><pre>select * from event_ext_tbl</pre><p>This will ensure that all the data from even_ext_tbl is copied to another local Snowflake table called MY_QUERRY( All output for SQL files are stored in tables named after their own!)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/1*hpAdqzrSgcASoxVH1Bo6PA.png" /></figure><p>Once again , you wont see this until you execute the next step</p><p>62) Now that this is done lets run the command to execute migration of files to local Database EVENT_EXT_TBL.</p><pre>dbt run-operation stage_external_sources</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*4dnR9hpOA74itlX8MEgmDQ.png" /></figure><p>63)(Optional) This step is meant for data to be transferred from EVENT_EXT_TBL to MY_QUERRY</p><pre>dbt run</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/399/1*vHW20A5NcWnpRhzgawCcNg.png" /></figure><p>65) Now all the changes should be reflected . Go to your snowflake web app and check under tables . And check if you able to see EVENT_EXT_TBL and MY_QUERRY tables.</p><h3>Conclusion</h3><p>If everything went as expected . Congratulations 🎉🎉! All the data has now been processed from external table to your local snowflake database using DBT!</p><p>Great work! In the next part of this tutorial we will focus on the AWS tools , orchestrate docker image containerization and task execution using Step functions, ECR and ECS . So stay tuned for Part 4!</p><p>As always , I hope this article was informative. If you have found it helpful, share and follow for more such content .And reach out to me if you are stuck at any point . Until then</p><p><em>… To infinity and beyond.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=231a2d0c1705" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[End to End Data Engineering Project #3 — Pt 2/4 : Production Level Migration from S3 to Snowflake…]]></title>
            <link>https://medium.com/@amos.eda/end-to-end-data-engineering-project-3-pt-2-4-production-level-migration-from-s3-to-snowflake-6f11224cab87?source=rss-8c2b759efa9------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f11224cab87</guid>
            <category><![CDATA[s3]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[snowflake]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Amos Eda]]></dc:creator>
            <pubDate>Mon, 23 Oct 2023 16:54:35 GMT</pubDate>
            <atom:updated>2023-10-23T16:54:35.089Z</atom:updated>
            <content:encoded><![CDATA[<h3><a href="https://medium.com/@amos.eda/end-to-end-data-engineering-project-3-pt-1-4-production-level-migration-from-s3-to-snowflake-ee89575d0438?source=your_stories_page-------------------------------------">End to End Data Engineering Project #3 — Pt 2/4 : Production Level Migration from S3 to Snowflake</a> using Docker, DBT and AWS Services</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*boobsHB0T0fJltTJKeqxMA.png" /></figure><p>Have you ever watched the parody of juraasic park from Critics? . There was one scene in particular that really caught my interest . Here’s the <a href="https://www.youtube.com/watch?v=nerv5YEiJok">link </a>for the video in case you havent watched it . In this video , you see a dinosaur pounce at young kid . But she manages to lock it in a closet . Feeling safe from the doom that imposed her , the girl relaxes against the door . Buuuut! The dinosaur is too smart. It keeps a paper underneath, rattles the door, snatches the key and then proceeds to open the door. It had me thinking , if any of us would’ve thought of such unconventional idea . Think of it :a newspaper as a fishing rod? Or an aparatus that could fetch us an object? Incredible ,dont you think? The dinosaur then proceeds to give a monologue about Venenzuela and revela its larger-than-life plan to mingle with general population under the name “Pilkington”.But that’s beside the point</p><p>Lets bring our attention back to the paper , because this is important . Until I watched this video, a paper to me symbolized words or text that could be read. After I watched this video , however ,it materialised as this object that is capable of slipping through narrow spaces and fetching objects.</p><p>One object , perceived as two different tools …</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*9iIERWztD_vIA1PxYT9N8w.png" /></figure><p>Transformation has always been key to deriving insights of many data culprits. I’d like to think of them as real convicts , they hide in plain sight right under your nose snatching you off the opportunity to make a key business decision. But once you get the key basics of transformation right , even a dinosaur can get it done .</p><p>Welcome back to follow up tutorial of our AWS production level project. In case you havent come across the first article , I’d highly reccomend visiting this <a href="https://medium.com/@amos.eda/end-to-end-data-engineering-project-3-pt-1-4-production-level-migration-from-s3-to-snowflake-ee89575d0438">link </a>. Let’s have a quick recap of what we have done in the previous article .</p><ol><li>We have discussed briefly on what Docker and DBT tool is</li><li>We have created first external table and staged data from S3 bucket to Snowflake using IAM role .</li></ol><p>In this article we will continue from where we have left off. We will be focussing on the transformation aspect . How we can get mend data to our will and get the right results . I won’t be focusing too much on the transformation itself, but rather on the specific procedures and steps required to get it done.</p><h4>The architecture so far</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MuHpkBICjIYjmi7VoDwNvA.png" /></figure><p>For ease of referencing I will be continuing the bullet points from where I have left off . Once again , if you want steps 1–26 . Please visit the following <a href="https://medium.com/@amos.eda/end-to-end-data-engineering-project-3-pt-1-4-production-level-migration-from-s3-to-snowflake-ee89575d0438">link</a></p><p>27) Now its time to create a working directory Choose your target location in your file explorer</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hCFizsS3eo-7eAm_Lq_J2g.png" /></figure><p>Please note you folder will be an empty directory . You shouldnt have any files inside.</p><p>28) And type CMD in the search location and press enter . A comand prompt should open with relevant file locaiton</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/326/1*eDtkeioz8po3l2grhgAQ5Q.png" /></figure><p>29) At the comand prompt , type “code .” For this to work , you have to make sure visual code editor is installed</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*632ydsnJDehm0NG-bcgHjw.png" /></figure><p>30) In your command prompt (at that same location) type “python” and hit enter .You should see the following output</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5J1CtENXEKjo-nLOMu841w.png" /></figure><p>I would like to stress on how the python version is 3.10 . Please ensure that , the version is intact.</p><p>31)Type “quit()” and you should enter back into your normal command prompt.</p><p>32)Now type in the following command</p><pre>pip install dbt-core</pre><p>You should get following output .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7lHPl0GwrUlZIAYpmaGD0g.png" /></figure><p>Notice how Im getting the red , blue and green color highlights. That is a feature of pip with the latest release with python 3.10 . If you are not getting that , then you should probably revisit step 11 . These are all subtle hints or observations that I have made while creating this project, and hey maybe it actually works for you without the color . But if you bump into an error , then its probably a good idea to trace back the tiny nuances that you are observing.</p><p>33)Install dbt-snowflake adapter</p><pre>pip install dbt-snowflake</pre><p>34)Once the installation is finished . Type the following code</p><pre>dbt init</pre><p>35)You should see your first input request .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*Tjgtv0O9TOWs3DpsDfQqoA.png" /></figure><p>Type in the name of your project . Im going to go with “dbt_aws_snowflake”</p><p>36)You should get the following prompt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*b6YyGLqDVLDb-smZjdKnVg.png" /></figure><p>Type 1 , because we want “snowflake” as adapter</p><p>37)It should ask you for you account . To get the details of account , go to your snowflake dashboard where you are logged in</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*BSNILWBd3L9NjoBvAqHj7w.png" /></figure><p>In the link you should see a format <a href="https://app.snowflake.com/">https://app.snowflake.com/</a>&lt; 7 character string no 1&gt;/&lt; 7 character string no 2&gt;/worksheets</p><p>&lt;7 character string no 1&gt; for the sake of this exercise lets take it qwertyqw &lt;7 character string no 2&gt; lets assume its ertyuyt</p><p>Once you are done with that , You need to add “-” between &lt;7 character string no 1&gt; and &lt;7 character string no 2&gt; and that would be your account. So the format would be &lt;7 character string no 1&gt;-&lt;7 character string no 1&gt;</p><p>So your account will look something like qwertyqw-ertyuyt</p><p>[VERY IMPORATNT NOTE ]If you add any other special character in between(like “.”or “,”) then it wont work .So please make sure to keep “-” without spaces.</p><p>[VERY IMPORTANT NOTE] qwertyqw and ertyuyt are just random examples . You need to replace it with the 7 character strings that are present IN YOUR link . Make sure to replace them with that .</p><p>Type that in your command prompt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*vDBKlIjTn_ZdJO20j8Q8sA.png" /></figure><p>38)For username you need to provide the details that you have given here .Please keep them tracked as they are very essential .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*FR8zfs3OZ6jsKiHJHNzwjA.png" /></figure><p>39)Once you enter the username .You will get the following prompt on command prompt. Press 1 as you would need to provide your password</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*zHAkCFfsKJZVp2Yid6SZ_A.png" /></figure><p>40)For password you type the password that you have given for snowflake login .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*FR8zfs3OZ6jsKiHJHNzwjA.png" /></figure><p>41) For the dev role provide “ACCOUNTADMIN”(It comes by default .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*mvCc-9Ya9ZdY-Vda-FjvSw.png" /></figure><p>42)(Optional) If you have a specific role that you would like to provide you can follow these steps on snowflake web app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*cDubs30lxYkTdQtArWqMJA.png" /></figure><p>43) For warehouse , You can provide “COMPUTE _WH” .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/1*ktMN1-4l25Rycr2GkYNeEA.png" /></figure><p>44)(Optional) You could give another warehouse depending on your case . You can see all your warehouses by following these steps on snowflake web app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A3CCJbzsvzZNPdhT1BnHSg.png" /></figure><p>45)For database , you would need to create one. You can go to the worksheet and type in the followin commands . Select the text and hit Ctrl+Enter</p><pre>CREATE OR REPLACE DATABASE AWS_S3_DB;</pre><p>46)Once the database is created , we need to create a table inside the database. Write the following querry , select the text and hit Ctrl+Enter</p><pre>CREATE OR REPLACE TABLE FIN_TAB(date varchar(255), total_price varchar(255));</pre><p>In this case Im having two columns the first being the date and the second being total_price. For both of these I have decided to set type as varchar or the string equivalent in SQL . Please note that you can change it according to the data type that you desire. However for the sake of simplicity and I have decided to keep varchar . If your CSV file has other columns, and you dont want to think too much about what datatype each column should be, then keep them all as varchar.</p><p>47)Once you are done with steps 27 and 28 , you have a database and a table. Lets provide the database details to the cmd . “AWS_S3_DB” or the database that you have inserted</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*lqRcfKMvyW7_Fl4VDKWr5w.png" /></figure><p>48)For schema , you can put “PUBLIC” . Every database has a default schema “PUBLIC” . Or you can easily check it in the snowflake web application</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/463/1*FpIgXOt1tl_vF8Y24s17BA.png" /></figure><p>Type the schema that you want in the terminal</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*bC5MwHNxYQzXZpN56qZ7Eg.png" /></figure><p>49)And finally for threads type 1 or 3(Depending on how fast you want the process to run)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*p63ktukPfGoE1Ih9Wa7f6A.png" /></figure><p>50)Once you are done with all the steps, you are not officially done with setting up your first DBT project with connection details .To confirm , go to C:/Users/&lt;User&gt;/.dbt My name is Amos . So I have folder structure like this . Open the profiles.yml file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*smEeU76FJ0oN7yX6UFeOAw.png" /></figure><p>51)All the details check out! I have all fields appropriately filled</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*yYGY0wERXyq5aUYsi-lpQw.png" /></figure><h3>Conclusion</h3><p>If you were able to follow all the instructions and you understood the purpose of all the tasks, then congratulations 🎉🎉!</p><p>You built your first DBT integrated tool with Snowflake . We will be using extensively in future projects as well since transformations are something we constantly have to deal with . As mentioned earlier, without transformation , we cant see our data in a different light .</p><p>Great work! In the next part of this tutorail we will focus on the getting data from external table rather than from an internal table(Which is what we achieved here). So stay tuned for Part 3 !</p><p>As always , I hope this article was informative. If you have found it helpful, share and follow for more such content .And reach out to me if you are stuck at any point . Until then</p><p><em>… To infinity and beyond.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f11224cab87" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[End to End Data Engineering Project #3— Pt 1/4 : Production Level Migration from S3 to Snowflake]]></title>
            <link>https://medium.com/@amos.eda/end-to-end-data-engineering-project-3-pt-1-4-production-level-migration-from-s3-to-snowflake-ee89575d0438?source=rss-8c2b759efa9------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee89575d0438</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[s3]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[snowflake]]></category>
            <dc:creator><![CDATA[Amos Eda]]></dc:creator>
            <pubDate>Sat, 21 Oct 2023 18:26:00 GMT</pubDate>
            <atom:updated>2023-10-21T18:29:04.601Z</atom:updated>
            <content:encoded><![CDATA[<h3>End to End Data Engineering Project #3— Pt 1/4 : Production Level Migration from S3 to Snowflake using Docker ,DBT and AWS</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0orHc47-GVKHijWlmZJoBQ.png" /></figure><p>That title is quite a tongue twister huh? Well, Don’t let the title of this post overwhelm you . This project (like many other mainstream project) is by no means a tough one. If you opened this link in hopes to get started with a data engineering project , then I assure you it will be worth your time and effort. You will learn a LOT ,if you follow along with the steps rather than just scraping through the article . I have always found trial and error to be my best teacher , making mistakes is the best way to learn something quickly .I personally have learnt more through my mistakes rather than sticking to tutorials . I will try to make this as much fun as possible for you and in turn ,all I request you to provide me with feedback(So that I can write better articles for the future! ).</p><p>NOTE : If you want jump straight to instructions for the project , then feel free to scroll to the “Instructions” section and get started. For the next few paragraphs , I will be briefing over few important concepts that are fundamental for this article , give a little context to the readers on the “why” , “what” ,“how ” and then jump straight into execution. With that said, lets begin!</p><h3>Why would you want to learn this project ?</h3><p>Let’s say you are working in a company like Uber. As a data engineer one of your main tasks would be to move data around constantly in the most efficient manner possible . What is the reason for data migration?</p><p>Data crunching</p><p>If you have ever worked with S3 bucket , then you would know that its pretty tough to analyse user data through simple queries. You could do that , but its going to be a tough one for sure . You would have much better luck doing that in relational database like <strong>drumrolls</strong> …..snowflake!</p><p>And that is exactly what we will be doing in this project. We will be bringing data from S3 bucket to Snowflake ,all while performing data transformations along the way (using DBT tool).</p><h3>What is a DBT tool?</h3><p>DBT (Data Build Tool) is a crucial tool for performing data transformations. Unlike other ETL tools, DBT doesn’t focus much on extraction or loading.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*Kgd67FfgTcQr24IzJhpftw.gif" /></figure><p>Its main advantage lies in performing transformations using queries. With DBT, you can write SQL queries to extract, clean, and transform raw data into structured, analysis-ready datasets. It enables analysts and data engineers to build and manage data transformation pipelines efficiently.</p><p><strong>How are we using DBT for this project?</strong></p><p>We are using DBT to stage data from External Tables(Stages) to Internal Table in Snowflake . So basically this is done by DBT tool .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S7l1FqIPVcw_koCjwPArYQ.jpeg" /></figure><h3>What is Docker?</h3><p>Imagine you have house . And in your house you have multiple rooms , with each room having its own contents inside.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*KuRvMpD8RyUkQ7lc-YE9oQ.png" /></figure><p>Docker works in similar way . You have a main OS sitting in your desktop,( In my case its windows) . And within this main OS we have multiple small containers with its own shared memory</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kZ-PTyrlkxICULNZo2sOnA.gif" /></figure><p>Within each of these OS, you can work as if you are working in completely different environment.(Seperate from your own ).</p><p><strong>How is Docker useful for my application ?</strong></p><p>We will be using docker to package the DBT tool (along with external dependency libraries ) in an Linux based OS and then compile them on a docker image .Docker will maintain a separate memory space for executing DBT related code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fvVvdY0SRX-lJGRmlPve9Q.jpeg" /></figure><h3>AWS Services</h3><p>The AWS services will mainly be used for orchestration purposes .</p><ol><li><strong>ECR Repository</strong> : Once the docker image is build we will be using ECR to store the docker image that we have build . This will facilitate ease of running containers directly from AWS storage space. One good analogy for this would be , think of ECR as mail box : You put an order for a new video game like God of war on Amazon .Once the package is delivered to your mail box , you can fetch it from there at any moment in time.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rZKaTlkFGiDK4j_HQgouLA.png" /></figure><p>Its the same with ECR. Your ECR will act as a repository that has multiple boxes(images) , you can take the image that you want from it at any moment .</p><p>2.<strong> ECS Repository</strong> : Continuing from our earlier analogy , once we recieved our video game, we would want to test it out by playing on our new PS5 console. Think of ECS as PS5 console that will allow you to play the video game .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1kZepmgQfctrmpQQFAFKjA.png" /></figure><p>ECS is responsible for building the image, and creating containers with exclusive memory space that will allow us to run the DBT package.</p><p>3.<strong> Step functions</strong> : Think of Step functions as our schedule .Our schedule dictates how our day goes by. Instead of us having to decide what we want to do , our schedule tells us what needs to be done what point. Its the same for step functions . Instead of ECS manually having to start a task , we can create Step functions to execute a particular task based on custom logic(Whcih are usually dependent on business use cases). You cant keep playing PS5 the whole day now can you ? You get to play it when you’re back from work ,when you dont have any other work or on the weekends.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KXVIh7ZUj3sYJ8ASs2vYiA.png" /></figure><p>I hope that gave you a brief idea of what we will be working on . Now that we have a good understanding of the architecture . lets go ahead and code this out!</p><h4>A few Prerequisites</h4><p>Make sure that you have the following items pre-configured in your system</p><p>1)Python and pip configured, Make sure that the version is 3.10 because I have had issue with 3.8 version of Python while attempting to install dbt .Link for reference : <a href="https://www.youtube.com/watch?v=dYfKJMPNMDw&amp;pp=ygUlY29uZmlndXJpbmcgcHl0aG9uIGFuZCBwaXAgb24gd2luZG93cw%3D%3D">https://www.youtube.com/watch?v=dYfKJMPNMDw&amp;pp=ygUlY29uZmlndXJpbmcgcHl0aG9uIGFuZCBwaXAgb24gd2luZG93cw%3D%3D</a></p><p>2)Visual code editor(Optional)</p><p>3)Docker Desktop(For windows) : You can find the link for download right over here : <a href="https://www.docker.com/products/docker-desktop/">https://www.docker.com/products/docker-desktop/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kxZE8jsAWflBMRhfMFBERw.png" /></figure><p>4)An AWS Account</p><p>5)An active Snowflake account</p><h3>1. Getting started with S3 and Snowflake</h3><p>Before we start working on this we need create a external table that has data from S3.</p><ol><li>Go to your AWS console to your S3 bucket. Make sure that you have an S3 bucket with the relevant folders and files within it .If you dont have one, then you can create one easily . Create a bucket and folder inside it with a csv file .</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/364/1*UPvlQ36DLv6IYOlJO_U3_w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/301/1*dtThws9zgVlWX5qqrQVi7g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*sca5HZKgDK11ZEf2oXWwgg.png" /></figure><p>This file is a csv file .</p><p>Repeating what I just said , because this is crucial for the project: The structure once again is Bucket&gt;Folder&gt;File (CSV file ) .Make sure that you have this structure . And if you dont have one, then create CSV file a file within a bucket.</p><p>5) Create a new external role to get access to S3. Go to IAM users</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*6KQDQqr5Srtuvn2_vpnu8w.png" /></figure><p>6)Go to users</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/316/1*26n0qloHoE950J5reV107Q.png" /></figure><p>7) Create User</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/373/1*d2Ty0kgCCcUFvP1uL9prQQ.png" /></figure><p>8) Set a name for the user and then create then click “Next”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*koD-4A7Bg2FbysNrHHvHSQ.png" /></figure><p>9)Attatch policies directly</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*NiYRtvlIf5siDd08JM0ofQ.png" /></figure><p>10)Type S3FullAccess or atleast part of it and “AmazonS3FullAccess” should appear as part of the search results.And then click on next</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cZw3zh3K0phmqSFoGYcjdQ.png" /></figure><p>11) And then create user</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*4PSu23mGiniGmPbrR2Ja3g.png" /></figure><p>12)Select the user role that you have created</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*U9o4NZKPVnAKz4_AWPrLfg.png" /></figure><p>13)You should see the permissions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*_LZkzlkPebcB_0plNMufLg.png" /></figure><p>14)If you dont see those permissions . then select Add Permisions and repeat the steps from 10 to 13.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*IywrIhRUhRDEPYhIK26UcA.png" /></figure><p>15)Go to roles and select the role that you have created. In my case it snowflake admin user</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YOGjp0N74a6S9CUY6_gnsg.png" /></figure><p>16) Once you have selected your user we will be creating security credentials so that Snowflake can get access to your S3 bucket . Select “Security Credentials”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*1Envb_zCa0bjWToSmIc7dg.png" /></figure><p>17) Scroll down and go to the “Access Keys ” Section . Create Access Key</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*lV5zAVF-959gKXYh54tosw.png" /></figure><p>18)Select the option “Application outside AWS”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vIJWYnyKZer6FdoCtUySIA.png" /></figure><p>19) (Optional) Provide a key tag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/1*_rs_BHjJdF7ijBgOwGxgDA.png" /></figure><p>20) And hit “Create Access Key”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/1*cGTBbJ6U8iYn39v0C5n49w.png" /></figure><p>21) Once you do that you should see you “Access Key” and “Secret Access Key”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*26oAhvbZHcq1NZUDTxSIWw.png" /></figure><p>22) Copy both these details in a notepad or a text file , because we will be using these details elsewhere . Also note , that once you exit from this page , you will never be able to access your secret access key again . So make absolutely sure that you have both the detials saved in a text file or a sticky note .</p><p>23)Navigate to your Snowflake account . And type in the following querry .Please make sure to replace AWS_STG_OP_A with whatever name you are comfortable . But make sure to follow through along with it till the end .</p><p>24)Navigate to your Snowflake account . And type in the following querry .Please make sure to replace AWS_STG_OP_A with whatever name you are comfortable . But make sure to follow through along with it till the end .</p><pre>CREATE OR REPLACE STAGE AWS_STG_OP_A<br>   url=&#39;s3://demo-bucket-json-concatenator/aggregate_folder/&#39;<br>   credentials=(<br>     aws_key_id=&#39;&lt;Your aws key that you stored from the step 21&gt;&#39;<br>     aws_secret_key=&#39;&lt;Your secret access key that you stored from Step 21&gt;&#39;)<br>   file_format = (type = CSV);</pre><p>25)Then Type in the following command to check if the data has been properly inserted</p><pre>select $1,$2 from @AWS_STG_OP_A;</pre><p>26)(Informational) Notice the $1 , $2 etc in the above querry? They represent the columns of the staged external table . You need to have exactly the same number of as that of your CSV file columns .</p><p>For example : In my CSV file , there are two columns . Hence I have $1 and $2 (Two columns each represented by $1 and $2).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*K4zK2jv5VZI0HhewEVV1fA.png" /></figure><p>So if you are CSV file has ,lets say, 5 columns . Then you would need to write a querry like this ‘select $1.$2,$3,$4$5 from @AWS_STG_OP_A;’</p><p>Bottom Line : Make sure that the number of columns matches the number of $1,$2,$3$4,$5 and so that you inset into your querry? Capiche?</p><h3>Conclusion</h3><p>If you were able to follow all the instructions and you understood the purpose of all the tasks, then congratulations 🎉🎉!</p><p>You just built your first staging project where you have acquired data from S3 to Snowflake . While this may look like an easy in principle , you will be surprised how many organisations rely on this simple procedure. There are nuances to this .But the bottom line remains the same. Data migration to warehouses are very crucial in a lot of organisations.</p><p>Great work! In the next part we will be getting our hands dirty with DBT tool , so stay tuned for the Part 2 !</p><p>I hope this article was informative. If you have found it helpful, share and follow for more such content .And reach out to me if you are stuck at any point . Until then</p><p><em>… To infinity and beyond.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee89575d0438" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Minute Projects Series — #2 Integrating DBT with Snowflake]]></title>
            <link>https://medium.com/@amos.eda/5-minute-projects-series-2-integrating-dbt-with-snowflake-92a6f9256426?source=rss-8c2b759efa9------2</link>
            <guid isPermaLink="false">https://medium.com/p/92a6f9256426</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[dbt]]></category>
            <category><![CDATA[snowflake]]></category>
            <dc:creator><![CDATA[Amos Eda]]></dc:creator>
            <pubDate>Mon, 09 Oct 2023 17:01:20 GMT</pubDate>
            <atom:updated>2023-10-09T17:01:20.319Z</atom:updated>
            <content:encoded><![CDATA[<h3>5 Minute Projects Series — #2 <strong>Integrating DBT with Snowflake</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NfL-H66wlcjsLkwg.png" /></figure><p>Imagine a fast-growing e-commerce company that collects vast amounts of transactional and customer data. They use Snowflake as their data warehouse to store this information securely and at scale. However, the data is constantly evolving, with new data sources, fields, and changes in data structures. We cant use the same querries for all different versions of the table . <br>For example the first version of e-commerce website might have product and price . But for the second one we might have product , price AND discounted price. To keep models in a streamlined version manner, we can use DBT in colloboration with Github! . This will ensure that we can pull up model schemas and queries that are relevant to a specific version.</p><p>In this article we will learn to integrate Snowflake along with DBT and test if the connection is going through properly</p><h4>Prerequisites</h4><ol><li>You need to have a snowflake account</li><li>You need to have a DBT account</li></ol><p>If you have neither of those , then please get yourself registered to get started with the process</p><h3>Instructions</h3><ol><li>Login to your Snowflake account at the following link : <a href="https://app.snowflake.com/?_ga=2.7721458.1752484603.1696862005-2101095858.1694282107">https://app.snowflake.com/?_ga=2.7721458.1752484603.1696862005-2101095858.1694282107</a><br>You should be prompted to the following page</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*FR8zfs3OZ6jsKiHJHNzwjA.png" /></figure><p>Enter your username and password. Once you login you should see following page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k4MIWaWDZb6UMvHyV_Gi2g.png" /></figure><p>2)Create another chrome tab or window , Login to your DBT account at the following link : <a href="https://cloud.getdbt.com/">https://cloud.getdbt.com/</a><br>If you already have an account then type in your login credentials in the username and password</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*osC2uuMMO8HJIiNxvIP8MA.png" /></figure><p>But if you dont have an account , then make sure to create a free company account</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*8uzW74zxFFs5mQG7BebWIw.png" /></figure><p>3) Select data on the left panel</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*4ysD98BPy7TEJFmuuEb_zw.png" /></figure><p>4) As you can see I have 3 databases available</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QfPZMEy16cjn1t2PORgydw.png" /></figure><p>5)For this exercise , I will be utilizing SNOWFLAKE_SAMPLE database . Click on it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*8ctQ5WmDc0cDBN9P81y-3w.png" /></figure><p>6) Choose a table , I have chosen TPCDS_SF100TCL</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*du_Ea8MqDeqbko4KFp91Fw.png" /></figure><p>7) Under that, Go to tables</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*aror2f2XQBjXl1cBgHiQbg.png" /></figure><p>8) Under that , go to CALL_CENTER table</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*sf7E0TKSOe_HDCT9_KxpaQ.png" /></figure><p>9) In the right section , you need to choose data preview . This will give a your a brief overview of the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SqkcOeIujKAZ_qgQB1ZR8w.png" /></figure><p>10) Lets go ahead and load this data in a querry .Go to worksheets in the left panel</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kcj8LqolVB1fYBqs7KM7EQ.png" /></figure><p>11) Create a new worksheet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ibolSWyEZEWuiYxZcejZsg.png" /></figure><p>12) Select SQL Worksheet</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*Q3vRV9FX5jbS44MKgFjMCA.png" /></figure><p>13) You should be able to see a bunch of databases on the left panel once you select Databases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kBWkbpPLOBxHGZG7IRU1gQ.png" /></figure><p>14) The one that we are trying to target is SNOWFLAKE_SAMPLE_DATA database .First we will select the database .Type in the following command</p><pre>use SNOWFLAKE_SAMPLE_DATA;</pre><p>There are two ways to execute commands in Snowflake . <br>Select the text and press `Ctrl + Enter`. <br>OR<br>Alternatively you can also run the command by selecting the text that you typed and clicking on the following ‘play’ icon at the top right corner</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ETU3Zqo-y126mKKjMUGQng.png" /></figure><p>15) Next we will get the first 10 columns of the CALL_CENTER Table.</p><pre>select * from TPCDS_SF100TCL.CALL_CENTER LIMIT 10;</pre><p>Select the text that you typed aka “select * from TPCDS…..” so on , and then press Ctrl+Enter. You should see the following .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*aNsIVsMEOFcGTQjrW80IiQ.png" /></figure><p>16) Now lets shift to DBT and make a connection to our current database. After logging in to DBT you should see the following screen . Type a new project name</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EIvb63IAVxP7I_dtVRQdnw.png" /></figure><p>17) Select “Snowflake” and click “Next”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kqfmnc--OT0xtRvKfzjSaA.png" /></figure><p>18) Scroll below and check the settings section .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jNcfgrczFSNlsspnp7FmkA.png" /></figure><p>19) This is where things are going to be slightly tricky . To get the details of account , go to your snowflake dashboard where you are logged in</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*BSNILWBd3L9NjoBvAqHj7w.png" /></figure><p>In the link you should see a format <br><a href="https://app.snowflake.com/">https://app.snowflake.com/</a>&lt; 7 character string no 1&gt;/&lt; 7 character string no 2&gt;/worksheets</p><p><em>&lt;7 character string no 1&gt;</em> for the sake of this exercise lets take it <em>qwertyqw</em><br><em>&lt;7 character string no 2&gt;</em> lets assume its <em>ertyuyt</em></p><p>Once you are done with that , You need to add “-” between &lt;<em>7 character string no 1</em>&gt; and &lt;<em>7 character string no 2</em>&gt; and that would be your account. So the format would be <br>&lt;<em>7 character string no 1</em>&gt;-&lt;<em>7 character string no 2</em>&gt;</p><p>So your account will be</p><pre>qwertyqw-ertyuyt</pre><p>[<strong>VERY IMPORATNT NOTE</strong> ]If you add any other special character in between(like “.” or “,”) instead of “-” then it wont work .So please make sure to keep “-” without spaces.</p><p>[<strong>VERY IMPORTANT NOTE</strong>] <em>qwertyqw</em> and <em>ertyuyt</em> are just random examples . You need to replace it with the 7 character strings that are present IN YOUR link . Make sure to replace them with that .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8DdCK3nJDpBpfSbQGoFT0g.png" /></figure><p>20) Next we would require our Database and warehouse details <br> The database in our case is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AXWe0j81dwnBxrg46SjaeQ.png" /></figure><p>The one that Snowflake provides when you create an account</p><p>21) As for the warehouse check “Admin” &gt; “Warehouses”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A3CCJbzsvzZNPdhT1BnHSg.png" /></figure><p>You should select the one warehouse sitting in the Warehouses section . Copy and paste that .</p><p>22) Your final DBT settings section should look something like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ROhCyfQTDSB3vBkfmMPmsQ.png" /></figure><p>23) For Optional settings &gt; Role , you can select ACCOUNT_ADMIN</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*A_PbKUlMF4UkdsSt56EDIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*cDubs30lxYkTdQtArWqMJA.png" /></figure><p>24) Under Developement Credentials, choose Auth Method (Username &amp; Password [Default]) .And set username and password the same as your login credentials</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*FoAMV_0wgA8x2kARq5GVOg.png" /></figure><p>25) (Optional ) In case you dont remember your username and password , you can check that information in your profile section</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/1*2nFGK2WzB04IHjtlxZgS3A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*-GHWXoFDoJlRT9ZPQpwiOw.png" /></figure><p>NOTE : Please make sure that you have NOT entered your email address in the username section . Its the username that is present in your profile section that needs to be given , not email address. Something like RohanPujari not <a href="/service/mailto:rohan.pujari@gmail.com">rohan.pujari@gmail.com</a></p><p>26) Once you give your username(from your profile) and password ! Test that connection!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*57lfDrxa1DQeHacgzYZPLw.png" /></figure><p>27) You should see the following prompt stating that “test was completed successfully” . Select “Next”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G1nbmBBNowriJsL8IN9aSA.png" /></figure><p>28)Create your own repository name and click “Create”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2xl3sWXDF2sJJw6SDC59nQ.png" /></figure><p>29) Start Developing IDE</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TdBQ4wvdvTsEf37Zt-4lPA.png" /></figure><p>30) Initialise dbt project</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xa87uggHpkmw7kq1ZIGriw.png" /></figure><p>31) You should see the following files get created on the left side</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*lTGQSoWbq0hwGmt_4YFNyQ.png" /></figure><p>32) Create new file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*-gBbRVj-1027nazF8QAIWw.png" /></figure><p>33) Lets check if the query is executing properly . Type the following query</p><pre>select * from TPCDS_SF100TCL.CALL_CENTER LIMIT 10</pre><p>NOTE : Make sure that semi-colon is not present in the end. You might be tempted to add it , but it will only give you errors. DO NOT ADD SEMI-COLON.</p><p>34) Type the above SQL command and then press “Ctrl + Enter” . You should see the following results</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YhCY-Kb3Z2Fmep4Da7VpqA.png" /></figure><h3>Conclusion</h3><p>If you were able to follow all the instructions and you understood the purpose of all the tasks, then congratulations 🎉🎉!</p><p>You just built your first DBT project while integrating with Snowflake</p><p>I hope this article was informative. If you have found it helpful, share and follow for more such content .And reach out to me if you are stuck at any point . Until then</p><p><em>… To infinity and beyond.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92a6f9256426" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Minute Projects Series - #1 Installing Python libraries using Docker on AWS Cloud Shell]]></title>
            <link>https://medium.com/@amos.eda/5-minute-projects-series-1-installing-python-libraries-using-docker-on-aws-cloud-shell-e416668492bf?source=rss-8c2b759efa9------2</link>
            <guid isPermaLink="false">https://medium.com/p/e416668492bf</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Amos Eda]]></dc:creator>
            <pubDate>Sun, 08 Oct 2023 16:41:54 GMT</pubDate>
            <atom:updated>2023-10-08T16:47:05.481Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*blqDCh7D4gsvIOmx.png" /></figure><p>You are a data scientist tasked with developing a machine learning model. Your project requires Python 3.7, NumPy 1.19, and Scikit-Learn 0.24. To complicate matters, you need to collaborate with a team of developers and ensure everyone is using the same dependencies. Traditionally, managing these requirements across various local environments can lead to compatibility issues and wasted time.</p><p>AWS CloudShell to the rescue! What is that you ask? AWS cloud shell is a cloud-based development environment that simplifies development and operations tasks by providing a secure and managed environment accessible directly from your browser. Combine this with Docker, and you have a powerful solution for managing Python libraries and dependencies effortlessly.</p><h3>Prerequisites</h3><p>This article assumes that you already have<br>1) Registered for AWS console manager .If you havent , then please go this <a href="https://aws.amazon.com/resources/create-account/">website</a> and get yourself registered<br>2) Knowledge about Docker containers. If you dont , then dont worry . This article is meant for beginners and intermediate developers .Let’s address the elephant in the room.</p><h3>What is a Docker Container?</h3><p>Lets say you have python 2 version in your local machine . But you want to run python 3 version . You dont want to disturb your environment. In addition to that you also want to configure SQL server and other libraries and packages. Docker will create an isolate environment for <strong>you</strong> where your main environment is left untouched. You can perform all your experimentation within these self-contained containers, making changes and testing them in accordance with project requirements, all without altering your main folder system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3CjzYerPLUMeOg3N.jpg" /><figcaption>Drawers akin to Containers</figcaption></figure><p>A good analogy for this :Think of Docker containers as drawers within a room .And each room belongs to a house. What does this mean?</p><ol><li>The drawers represent containers .</li><li>The clothes inside the container represent packages or libraries such as Python or NodeJS .</li><li>The room with the drawers denotes Container Engine</li><li>The house with different rooms denotes the operating system</li></ol><p>So ,when you shuffle items within a drawer (lets say drawer #1) the items in drawer #2 remain unaffected by that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/292/0*vyKmbfdXEjQp2-en.png" /><figcaption>Each app is sitting inside container in Container enginer</figcaption></figure><p>Its the same for Docker as well, when you mention specific commands to be executed .They are done so in an isolated manner. AWAY from your main file system.</p><p>If you would like to have a more in depth understanding about Docker then I would highly suggest watching this <a href="https://www.youtube.com/watch?v=3c-iBn73dDE&amp;pp=ygUYZG9ja2VyIGNvbXBsZXRlIHR1dG9yaWFs">video</a> . It is my go-to video whenever Im stuck at a particular exercise and I hope you will find it informative.</p><p>Now that we have a basic understanding of Docker, lets get our hands dirty with a simple exercise. I will be attempting to install numpy ,pandas and scikit learn on docker container. Lets begin!</p><h3>Instructions</h3><ol><li>Open your AWS Console and search for Cloud9</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7xJZoSaz6qYGa2v0jcDOUA.png" /></figure><p>2. Create a new Environment</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*mBonmSDwx745tr-yjGuxIA.png" /></figure><p>3. Give a custom name to the environment</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*pOn8-2p-LC0_y0-Z280KIQ.png" /></figure><p>4. Make sure that your platform is Amazon Linux</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*t5_VNNsP7C3tvhBEsC7UAQ.png" /></figure><p>5. Connections are SSM</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*GI-swz4LDdDB-VKUdiI1-g.png" /></figure><p>6. And then create your environment</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*QAx2Q49fkZH2ZJr0vgDR-w.png" /></figure><p>7. Open the Cloud9 Environment</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*K8BM3g1NxwU4bT97UblfFA.png" /></figure><p>8. Create a new terminal</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*0qbZR9EJrtZSF-7mntm4Gw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*M2F3vPuC8V860dYQyX0pVw.png" /></figure><p>9. Check if docker is installed .Type in the following command</p><pre>docker --version</pre><p>You should see the following results</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/281/1*JuyzWJHymkanh1pQ-eEenA.png" /></figure><p>One of the things that I like about AWS cloud shell is that it comes with Docker preinstalled ,saving you a ton of time with pre-installation</p><p>10. Create a new Dockerfile</p><pre>sudo vi Dockerfile</pre><p>11. Once you type that you should see the following screen</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*0PxYgwHsbBD7Q40PSlA8Rg.png" /></figure><p>12. Press “i” .This will get you in insert mode. You should be able to see the following once you have entered into insert mode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*zgJo9XBwshh-H95l9h0mQw.png" /></figure><p>13. Type the following code</p><pre># Use a base image with Python and NumPy pre-installed<br>FROM python:3.8<br><br># Install any additional dependencies if needed<br>RUN pip install numpy scikit-learn<br><br># Copy your Python script into the container<br>COPY python_ny.py /app/python_ny.py<br><br># Set the working directory<br>WORKDIR /app<br><br># Run your Python script when the container starts<br>CMD [&quot;python&quot;, &quot;python_ny.py&quot;]</pre><p>14. Now press `<strong>Esc</strong>` followed by the keys `!<strong>wq</strong>` . This will make sure that the contents you have written in the file are saved. If you have escaped the insert mode properly , you should see the following after typing `<strong>!wq</strong>` .If you didnt get the following , then try hitting escape two or three times and try again</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*2YhWUIw4yHI2cg0npZNBNQ.png" /></figure><p>15. This should take you to the main directory . And you should see the following icon on the left panel as well</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*-_5iNhfuKqLa6eQq5iSoUA.png" /></figure><p>16. Create a python file to test if numpy and scikit got properly installed . Type the following command to create python file</p><pre>sudo vi python_ny.py</pre><p>17. Press “i” and enter insert mode</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*zgJo9XBwshh-H95l9h0mQw.png" /></figure><p>18. Type the following code</p><pre>import numpy as np<br>import sklearn<br>from sklearn.datasets import load_iris<br>from sklearn.model_selection import train_test_split<br>from sklearn.neighbors import KNeighborsClassifier<br>from sklearn.metrics import accuracy_score<br><br># Your NumPy code here<br>arr = np.array([1, 2, 3, 4, 5])<br>print(&quot;Sum:&quot;, np.sum(arr))<br><br>#Your Scikit learn code here<br># Load the Iris dataset<br>iris = load_iris()<br>X = iris.data<br>y = iris.target<br><br># Split the dataset into a training set and a test set<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)<br><br># Create a K-nearest neighbors classifier<br>knn = KNeighborsClassifier(n_neighbors=3)<br><br># Fit the model to the training data<br>knn.fit(X_train, y_train)<br><br># Make predictions on the test data<br>y_pred = knn.predict(X_test)<br><br># Print the accuracy of the model<br>accuracy = accuracy_score(y_test, y_pred)<br>print(f&quot;Accuracy: {accuracy:.2f}&quot;)</pre><p>19. Same as step 14 . Press `<strong>Esc</strong>` followed by the keys `<strong>!wq</strong>` . This will make sure that the contents you have written in the file are saved. If you have escaped the insert mode properly , you should see the following after typing `<strong>!wq</strong>` .If you didnt get the following , then try hitting escape two or three times and try again</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/317/1*UkpodQ-LgN6B6XVfC4VZmQ.png" /></figure><p>20. You should see a python file sitting on the left panel</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/364/1*SJi7hsnYn6OauSx_PxUI0g.png" /></figure><p>21. Now its time to build the docker image. Go ahead and type the following command in the terminal</p><pre>docker build -t latest-python-image .</pre><p>22. If everything goes well, you should be able to see a message stating that all steps have been successfully completed</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*TqAHsK3IaLYJ2O2L5VfUGQ.png" /></figure><p>23. To confirm that your docker image has been properly built , type the following command</p><pre>docker images</pre><p>You will get the following results</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*JKQXwMkDysiE3qunXRl4sw.png" /></figure><p>24. Execute the following command to check if execution is going through</p><pre>docker run --name=myapp latest-python-image</pre><p>And the results are **Insert drumrolls**</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*JUTg1IHF9gFTGwiYI7hYbw.png" /></figure><p>It works! The sum and Accuracy are properly reflecting</p><h3>Conclusion</h3><p>If you were able to follow all the instructions and you understood the purpose of all the tasks, then congratulations 🎉🎉!</p><p>You just built your first docker image on AWS !</p><p>I hope this article was informative. If you have found it helpful, share and follow for more such content .And reach out to me if you are stuck at any point . Until then</p><p><em>… To infinity and beyond.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e416668492bf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[End to End Data Engineering Project #2 — Transferring CSV files to Glue Data Catalog]]></title>
            <link>https://medium.com/@amos.eda/end-to-end-data-engineering-project-2-transferring-csv-files-to-glue-data-catalog-2fa7f742fdae?source=rss-8c2b759efa9------2</link>
            <guid isPermaLink="false">https://medium.com/p/2fa7f742fdae</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Amos Eda]]></dc:creator>
            <pubDate>Thu, 05 Oct 2023 20:15:21 GMT</pubDate>
            <atom:updated>2023-10-05T20:16:12.940Z</atom:updated>
            <content:encoded><![CDATA[<h3>End to End Data Engineering Project #2 — Transferring CSV files to Glue Data Catalog</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/0*CENjX82mn7iRG2wm" /></figure><p>Picture this: A global e-commerce giant collects petabytes of data every day, ranging from customer interactions to sales figures. All of this data is meticulously stored in Amazon S3, a secure and cost-effective cloud storage service. It’s a treasure trove of insights waiting to be unearthed, but there’s one challenge — how do you efficiently analyze such colossal datasets?</p><p>Enter Athena queries,Athena allows businesses to run SQL queries directly against data in Amazon S3, without the need for complex data processing or the management of intricate infrastructure.</p><p>Let’s take a real-world example. Our e-commerce giant wants to understand customer behavior and optimize its marketing strategies. Using Athena queries, they can swiftly analyze purchasing patterns, identify trends, and uncover correlations in the vast sea of transaction data. What would have taken days or weeks of data preprocessing and setup now takes mere minutes. Decision-makers can make informed choices promptly, responding to market dynamics in real-time.</p><p>So how can we make this happen? In today’s tutorial , we are going to run a simple querry against our S3 bucket and get specific insights such average product price of different categories. <br>Lets get started!</p><h4>Creating an S3 Bucket</h4><p>1)Navigate to S3 Bucket</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sOBXaBygECSJYvA_IZLFqw.png" /></figure><p>2)Create bucket</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*4RAQ0nCuenGOMF_o7OmFbQ.png" /></figure><p>3)Type in a unique bucket name (It should be unique or else you cant proceed forward)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*tLrjIwx8idkK-DzMeFQSNw.png" /></figure><p>4) And then select create bucket</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/182/1*fG90g1NDDaQFwhGzJInx4Q.png" /></figure><p>5) Navigate to your bucket</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/349/1*RrowM_je5k0Gui0K58k-0Q.png" /></figure><p>6)Create a folder inside the bucket</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/1*3S9tR2HJYblm8P9moc6TIA.png" /></figure><p>7) Name your folder</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*2VXbCzV8Zcr832HE3j4zrg.png" /></figure><p>8) Create you folder</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/264/1*H1Ee6wgtqq0qDmK-HTF6mA.png" /></figure><p>9) Navigate into that folder</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/312/1*3DW2ghl8UQncWrhEivcIaQ.png" /></figure><p>10)Upload a new file inside it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/359/1*Oxs_wHTB3QSqtCCIuGO-hg.png" /></figure><p>11) Im choosing the following file from NBA online Repository : <a href="https://sports-statistics.com/sports-data/nba-basketball-datasets-csv-files/">https://sports-statistics.com/sports-data/nba-basketball-datasets-csv-files/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mXbvPvgUivadWMZNk94MgA.png" /></figure><p>Download the same and maintain it in your local repo.</p><p>12) After keeping it in your local repository , upload it into your S3 bucket</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/359/1*Oxs_wHTB3QSqtCCIuGO-hg.png" /></figure><p>13)Add file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*HZz1nEhwDppSBI1ZaouugA.png" /></figure><p>14) Upload</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/222/1*nf8m9PVMcMnPDoru30mjsQ.png" /></figure><h3>Pitstop — What is a crawler</h3><p>Now that we have created a S3 bucket and have all of our data . We need a tool that can identify the fields in our csv file and what type each field is. A tool that can take care of assigning the variables based on sample data or first few rows of our dataset . <br>Crawler does just that. It assigns variable types and create a table for us with little to no manual intervention</p><p>Back to instructions</p><p>Lets create a database to make sure that the crawler has place to dump its data.</p><h4>Creating Database</h4><p>15) Check the Databases under DataCatalog in left panel</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*JlpLLBcVzSXxXvB7TgJcfA.png" /></figure><p>16) Create new database</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/306/1*c6ZPlsXz-26pirLHhI8RDA.png" /></figure><p>17) Type in your desired name and create database</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*17TvqA1t8qrg2k_Q-H5lQA.png" /></figure><h4>Creating Crawler</h4><p>18) Navigate to AWS Glue</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*bLHZre3Fj5pUX6xCV3CQaA.png" /></figure><p>19) In the left panel search for crawler</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*HGH61y48imqYIlCnyh7kSg.png" /></figure><p>20) Create Crawler</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/1*ZjBM0efIj4zfOS0Etrjmgg.png" /></figure><p>21) Type your desired name for crawler and click “Next”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*z_6hUF9sYSzvRL8DLI8aNQ.png" /></figure><p>22) Add a data source . Which is our S3 Bucket</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*ZHBhU0NnIjdUlRvAtW1WtQ.png" /></figure><p>23) Set the data source</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*5dNcGvOEaj2vo9WojT2_yQ.png" /></figure><p>24) (Optional )Sometimes when you have too many buckets sitting in your S3 you wont be able to view your S3 bucket . In such cases , go to the next page .A simple step , but something that can easily overlooked</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z0CI9R8G0d2HvUmddWo3pQ.png" /></figure><p>25) Select your bucket and click choose</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lGCR6ZY7Zn1o-8DheihYpQ.png" /></figure><p>26) (<strong>Important!</strong>) Please make sure to have a folder within your bucket. If you dont maintain a folder within your S3 bucket then your crawler wont be able to identify relevant columns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*F1wPUYRoDh8GS_jpCZbiPA.png" /></figure><p>27) (<strong>Important!</strong>) Dont choose the CSV file inside the scraper folder .If you notice carefully, as per the instructions you are only supposed to provide the path TILL the folder , But not the data file. Select the folder and click on “Choose”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*v_iwht0M3fJE9wDZMqj4lw.png" /></figure><p>28) Choose this as add S3 Data source</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*JLa46skcAnO_eEWjpq56Eg.png" /></figure><p>29) Choose “Next”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*i9NxhlVf1Hg45_LCz7isnw.png" /></figure><p>30) Create new IAM role , AWS will automatically do this for you .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DqR1IIUhVV9u1Ah-CgAIdg.png" /></figure><p>31) Give a custom name for the IAM role</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*jEV37TXR1wbBSxlCNJTcEw.png" /></figure><p>32) Click Next</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*hG-LB-6fpEFupkJ8lz0Tkg.png" /></figure><p>33) For database choose the one that we created earlier</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*ihGESYubCesJvqwMO2r6ag.png" /></figure><p>34) Select “Next”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*k1MQeG13ykIkXX0OD9ExYQ.png" /></figure><p>35) In the next page, review all your information and select “Create Crawler”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*b2AHGoEmYH__PsSCLl0TxQ.png" /></figure><p>36) Run the crawler and hit refresh on top right corner and wait till it does the needful .It should take a few minutes before its done</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*3we_voElV95tK0Az-SFuXA.png" /></figure><p>37) Once the crawler is finished with its task , you should see something like this .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jq13UZ8gFPJgLZzmpQorOw.png" /></figure><p>38) Go to databases in the left panel</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*ZCZSMjj7s-Mb3imrIW1xog.png" /></figure><p>(Optional) You might be tempted to go to tables where the real data is sitting, but let me warn you . It looks like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l7f_7WGAwULlvlHsU96SuA.png" /></figure><p>You have no clue which table you would need to open . So easier to stick to databases</p><p>39) Choose your database</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*BN8F1pKDoxpUOt5QAi8m_A.png" /></figure><p>40) This is the scraped table , let check the data using Athena</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VYGRnIX9gdRxKjQPLXTHtA.png" /></figure><p>41) Proceed</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*S-_7uLl3Go7FmLZQedmmig.png" /></figure><p>42)You should see the following data if everything checks out</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KH1PwvZ6BUHSGWpTlqHTug.png" /></figure><p>43) If you check the types of data in the table section on the left side. You will notice that the data types are auto assigned</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/307/1*g-uG2EXltl7edkfgPqXMlQ.png" /></figure><h3>Debugging Columns Issue</h3><p>The steps following this are completely optional . I would highly suggest to go through them as they would give you insights into what kind of problems a data engineer run into on a daily basis</p><p>44) I was curious as to why the fields werent properly labeled. And after opening the CSV file via Excel I came across an interesting insight</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*qIwTUtGYfSj1_QcQUJZnKQ.png" /></figure><p>One of the columns in the CSV isnt labeled!</p><h4>Lets fix that</h4><p>45) Open the csv file with you excel sheet and add a label , I have kept S.No</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WDHc6IGq5WnTwjvn5q_wLw.png" /></figure><p>46) Lets re-upload this file and see if we are getting any different results .Go back to your bucket in S3 .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m9j8RqoKOGcBWoRBvjXbgg.png" /></figure><p>47) Choose your desired folder</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/1*WVRxy3IVGSmDpv018fCtfQ.png" /></figure><p>48) Upload new file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*Bey4TIsOEcDDBjGbB91T4Q.png" /></figure><p>49) Add files</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*dmVzncduW3czcwnWTIrDIQ.png" /></figure><p>50)Choose your saved file (the one where you have updated the label to S.No) and hit Upload</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*vuT1JWp-LsDU718qT--Xjg.png" /></figure><p>51) After it finished uploading , We need to remove the previous uploaded data .Lets go to the table and drop it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uUohxUOfmoFCYtPWZezT5g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dpoN6uA0V4ip8g_7HsjlPw.png" /></figure><p>52)Confirm deletion of table</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*PNOhDS-Yq8LLNwxwd_skAA.png" /></figure><p>53) Go to crawler section</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*r8O4RAZBzXxtOb5S0sKpcg.png" /></figure><p>54)Choose the crawler that you had previously</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*ouoYGHZIRjICjIcXcLroFA.png" /></figure><p>55) Run the crawler once again and dont forget to hit the refresh</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*ffeZeN2e_1E4yoCG8UIPTA.png" /></figure><p>56)You should see something like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*aO7z2_gr1NMbHKgs3yOXhQ.png" /></figure><p>57) Then to databases</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*3w3J9WJPx1DwurHAdabvbg.png" /></figure><p>58)Your database</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*Fi8KBSzb_DoJ8XDtdPs4aw.png" /></figure><p>59) View Table data in Athena</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qtSUD7K_B5F-7hnxVepZsA.png" /></figure><p>60) Proceed</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*o2x_IcQfhQFbjqm47NNzCQ.png" /></figure><p>61) And Voila! We are getting the columns as expected!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_4A-MMt72igXqhMYiIZu4Q.png" /></figure><h4>Limitations and budget constraints</h4><ol><li>You can store unlimited data in S3 however individual Amazon S3 objects can range in size from a minimum of 0 bytes to a maximum of 5 TB. The largest object that can be uploaded in a single PUT is 5 GB.</li><li>Be little aware of Crawlers . They dont take a lot. I got charged only 2 cents for this whole exercise.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DBaXpfvzpdRqFYBEX02PUQ.png" /></figure><h3>Conclusion</h3><p>If you were able to follow all the instructions and you understood the purpose of all the tasks, then congratulations! 🎉🎉 You just ingested your first CSV file using AWS Glue crawler ! <br>I hope this article was informative. If you have found it helpful, share and follow for more such content .And reach out to me if you are stuck at any point . Until then <br><em>… To infinity and beyond.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2fa7f742fdae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An End to End Data Engineering Project : Creating a Data Funnel using AWS Kinesis ,Python and S3…]]></title>
            <link>https://medium.com/@amos.eda/an-end-to-end-data-engineering-project-creating-a-data-funnel-using-aws-kinesis-python-and-s3-40c4d4506361?source=rss-8c2b759efa9------2</link>
            <guid isPermaLink="false">https://medium.com/p/40c4d4506361</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Amos Eda]]></dc:creator>
            <pubDate>Sun, 01 Oct 2023 19:58:18 GMT</pubDate>
            <atom:updated>2023-10-01T20:00:19.437Z</atom:updated>
            <content:encoded><![CDATA[<h3>An End to End Data Engineering Project Tutorial: Creating a Data Funnel using AWS Kinesis ,Python and S3 Bucket</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kDPjwUn27sphkV1x.jpg" /></figure><p>In this age of digital information , there is no lack of data . Information is flowing everywhere and as a business entity its important to make sure that this information is organized . Lets take for example , ecommerce. Let’s consider a use case of a business owner who wants to check trend in sales for summer vs Fall.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WPehyf2-qH6eCgcrPcgxaA.png" /></figure><p>To create this captivating visualization, a wealth of data must undergo extensive number crunching in the background. Data needs to be organized with timestamps. It’s essential to organize the data with timestamps; otherwise, working with it would be a time-consuming and challenging task.</p><p>Keeping data organised can help us to be more precise and selective , helps us to drill down specific infromation that we want to drill down to when we want to derive insghts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*ymZpd7RCzHbF11lTf3KP2w.png" /><figcaption>Organised folders based on time stamps</figcaption></figure><p>How can we organise this data when there is real time information streaming into your cloud infrastructure?<br>In this tutorial we are going to work on AWS architecture where we funnel down the information into different compartments based on timestamps to aid data analytics and visualization.</p><h3>The Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*cW2YyFxYp5tehbNBVwvi2g.png" /><figcaption>Architecture to drill down details</figcaption></figure><p>A quick exercise for you , the reader . Observe the above architecture , take a nice, good look at it and try to guess what each component is reponsible for . What would happen if a specific component is not present or what would happen if you add another element to the mix. There are different phases to this architecture, we will delve deep into each section and see how it contributes to data funneling.</p><h3>(Optional) The inner working behind Architecture</h3><h4>Data Producer</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_rkcaJPrJLFLITAmmIv5Ig.png" /></figure><p>Data producers are entities that send information to cloud infrastructure. These data producers could be something as simple as IOT devices thare are sending data from various nodes to cloud or even real time stock market data that getting sent through API hooks. <br>The data producers do not bother how the data is getting processed or if there would need to be a delay between each packet( information that is getting sent ) to avoid concurrency issues .A good analogy for this would be coal miners who are working in coal mines to gather coal . From their perspective it is irrelevant what gets done with the coal , their primary focus is to make sure that the coal is getting dumped into the wagon.</p><h4>Kinesis Data Streams</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*vertXd8-lLt85q3FcJ1TMg.png" /></figure><p>Data Streams is akin to a wagon/train, it is responsible for gathering all the data that is getting dumped on their doorstep . Once the data gets dumped in a data stream , it arranges the information into a queue, where the information waits to get picked up by another agent. A good analogy to demonstrate this would be a coal wagons that are getting transported out of the cave .</p><h4>Kinesis Firehose and S3</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*Je9zy1fLneOQTvnylUmcig.png" /></figure><p>Firehose is similar to vendors/contractors .These coal vendors have different contracts or agreements with government entities such as Electricity or Gas departments (Folders within S3 bucket) .Firehose is responsible to make sure that data gets delivered to appropriate folders/partitions within S3 bucket. Once the information is collected, it gets dumped into different compartments based on timestamps.</p><p>With that said, lets get started with the tutorial!<br><strong>Note </strong>: Before starting the tuorial, it is assumed that you already have an AWS console account registered .If you havent done so, then please go to the following <a href="https://aws.amazon.com/free/?trk=78b916d7-7c94-4cab-98d9-0ce5e648dd5f&amp;sc_channel=ps&amp;ef_id=Cj0KCQjwjt-oBhDKARIsABVRB0xwWh_a4E0OffdmECvP3fVwklBt2aQLeQZzmmhsKbw5zCCj-laoeHUaAk-7EALw_wcB:G:s&amp;s_kwcid=AL!4422!3!432339156165!e!!g!!create%20aws%20account!9572385111!102212379047&amp;all-free-tier.sort-by=item.additionalFields.SortRank&amp;all-free-tier.sort-order=asc&amp;awsf.Free%20Tier%20Types=*all&amp;awsf.Free%20Tier%20Categories=*all">link</a> and get yourself registered</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><h3>Getting Started</h3><h4>Step -1 : Download the json file from Repository</h4><p>For this tutorial I have created a json data that consists of ecommerce products for a demo website. Download the file from the following github <a href="https://github.com/amos-eda-97/amos-eda-97.github.io/blob/main/ecommerce_data.json">repository </a>.</p><h4>Step -2 : Creating credentials to enable AWS SDK</h4><p>We first need to create credentials for AWS SDK . AWS SDK are custom AWS commands which you can use in your local code . But in order to do so , you need to tell AWS that it’s actually you that is using the AWS SDK and not some impostor . To do so , we generate credentials and the first step to do that is to create a user with relevant permission. <br><strong>1) Login to you AWS online console and navigate to IAM Users</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ALI8m3-C1B9wME4W5N9jzA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KvBPWMY29rmVPZDdtbR3hQ.png" /></figure><p><strong>2)Create new User</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c92dDgAIhfTh7VH1oQ9pGQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WQXJ5m_JHrw6eCozCzzT0A.png" /></figure><p><strong>3)Make sure to select the appropriate options as shown below</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GWbJ0U76iI_7nYS1uUhjlw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dQCTByJLcAi9El4UQ4xMvA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gJ7EQx5yK6AClSvMpJWWKg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*0UquEuZZotRrB7Ua9VuhVw.png" /></figure><p><strong>3)Review your information carefully and select create user</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i50k4QwSNaoze3dhhPe8bg.png" /></figure><p><strong>4)Once you create user , you should be able to see the following information</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/237/1*hYf2Z52lPjD-Uv4W2HBxNw.png" /></figure><p>Store these details at an isolated location , perhaps in a text file or notepad . You will be using these details again at a later phase.</p><p><strong>5)Return to the users dashboard of IAM .</strong></p><p>You should be able to view the IAM user that you have created. Click on it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*mZ1ZB7FjR4I3eWGlYlrHqA.png" /></figure><p><strong>6)Open the Security credentials tab</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*MgQvCrmpjeTj2k9E5QQaYg.png" /></figure><p><strong>7)Scroll down to the Access Keys section and click on create Access Key .</strong></p><p>You will be using these Access Keys in your local code to get access to AWS services programmatically</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hnFaATsVENbJZmLGT2-jfw.png" /></figure><p><strong>8)Select Local code and click the check box acknowledging that you have understood what you are signing up for and click “Next”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WMvls1ZHUrSl-X7wZTLVfw.png" /></figure><p><strong>9)Choose a tag key that you want to assosciate the access keys with</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ySiGDeer49qifBSPSRIYBw.png" /></figure><p><strong>10)This should prompt you to access keys page where you will be able to view your access key and your secret access key</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*dKvspeRrGo_zAi_Y0Iyelw.png" /></figure><p>Make sure to save these details in a text file or a notepad, since we will be using them as part of our data producers code.</p><h4>Step 3 — Python Script for Data Production</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*QQ5V1i2dA4nnU4xXXFKJQw.png" /></figure><p>This part of the tutorial assumes that you have python installed as a prerquisite. If you dont , then please navigate to the following <a href="https://www.python.org/downloads/">link</a> and follow the instructions.</p><ol><li><strong>Open Command Prompt and install boto3(AWS open source library)</strong></li></ol><pre>pip install boto3</pre><p>2.<strong>Create a new python file (With .py extension) . Preferably using visual studio code .</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*O0v7gKODrxv7Dx_0ZlAWsw.png" /></figure><p><strong>3.In the python file , import the relevant libraries</strong></p><pre>import boto3<br>import json<br>import time</pre><p><strong>4.Instantiate AWS related variables</strong></p><pre>aws_access_key_id = &lt;your access key that you stored from earlier&gt;<br>aws_secret_access_key = &lt;your secret access key&gt;<br>aws_region = &#39;us-east-2&#39;</pre><p>In case you are clueless about your AWS region , you can easily check it in your AWS console</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/471/1*f8vrX_RUECo6QnFxN_C5Sw.png" /></figure><p><strong>5.Keeping everything in the same folder</strong></p><p>Make sure that the `ecommerce_data.json` that you downloaded from github earlier exists in the same file location as the python file .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*vPtC99iGB4wt3HtWLftY9w.png" /></figure><p><strong>6.Load the json data</strong></p><pre>with open(&#39;ecommerce_data.json&#39;, &#39;r&#39;) as json_file:<br>    product_data = json.load(json_file)</pre><h4>Step 4 — Kinesis</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*GhHsWP9A1vFWY8I62E96qA.png" /></figure><p>In this phase we are going to configure Kinesis data streams , ensure that the data from the data producers is getting tunneled to intended destination</p><ol><li><strong>Within the same file , initialize Kinesis client</strong></li></ol><pre>kinesis_client = boto3.client(&#39;kinesis&#39;, region_name=aws_region, aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key)</pre><p><strong>2) Create a new stream on Kinesis programmatically</strong></p><pre>stream_name = &#39;data-streamer&#39;<br>shard_count = 1  # You can adjust the number of shards as needed<br><br>try:<br>    kinesis_client.create_stream(<br>        StreamName=stream_name,<br>        ShardCount=shard_count<br>    )<br>    print(f&quot;Stream &#39;{stream_name}&#39; created successfully with {shard_count} shard(s).&quot;)<br>except kinesis_client.exceptions.ResourceInUseException:<br>    print(f&quot;Stream &#39;{stream_name}&#39; already exists.&quot;)<br>except Exception as e:<br>    print(f&quot;Error creating stream: {str(e)}&quot;)</pre><p><strong>3) Add each product into the stream</strong></p><pre># Send each product record to the Kinesis stream<br>for product in product_data:<br>    # Convert the product record to JSON<br>    product_json = json.dumps(product)<br><br>    # Send the JSON record to the stream<br>    response = kinesis_client.put_record(<br>        StreamName=stream_name,<br>        Data=product_json,<br>        PartitionKey=product[&#39;date&#39;]  # Use a unique identifier as the partition key<br>    )<br><br>    print(f&quot;Record sent to Kinesis: {response[&#39;SequenceNumber&#39;]},{response[&#39;ShardId&#39;]}&quot;)<br><br>    # To avoid sending records too quickly (e.g., for rate limiting), you can add a delay<br>    time.sleep(0.1)  # Sleep for 100 milliseconds between each record (adjust as needed)</pre><p>Now we’re going to check if the data got properly inserted in our AWS console</p><p><strong>4)After executing the above code , you should be seeing the following output</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*c1h3rTJeNCz4AC4UD5RcdA.png" /></figure><p>Copy one of the record transaction ID and shard ID as well .Example (the first record ID): <br>- 49644981891148681367608698114075671093958433950903828482<br>- shardId-000000000000</p><p><strong>5) Go the AWS console and navigate to Amazon Kinesis Data Streams</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*14ZtLPaBpFP0RI-5Gn-nWg.png" /></figure><p><strong>6) Select Data Streams</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cszfWBZbuEujim-COjGOAQ.png" /></figure><p><strong>7) Check the streams and click the one that you have created</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fYfamaJ6kjukKdeeTdXfyg.png" /></figure><p><strong>8) Check the data viewer section</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*lO2t98pXNOJrKUabWZ-sZA.png" /></figure><p><strong>9) Select the shardID and record ID that you saved earlier</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W81fPbawsGW8f3DHTXg6ug.png" /></figure><p>If everything is done right , you should be able to see the data that has been uploaded.</p><h4>Step 5 — Creating S3 Bucket</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*zwqpoDDDHF9sOv8n03wUTQ.png" /></figure><p>In this phase we are going to configure S3 bucket and make sure its ready to catch the data getting thrown at it from Kinesis firehose.</p><ol><li><strong>Navigate to AWS console and select S3</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n0HtJqcXvnWQz8MDRzO3sQ.png" /></figure><p><strong>2) Create bucket</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KkSh2D9oA_bFVg6d3gKlnQ.png" /></figure><p><strong>3) Type a unique name</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*vduZl7y44FmM8HchqmWzeA.png" /></figure><p><strong>4) And select “Create Bucket”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/274/1*a54_eCFJGAbK7UABQiWv1Q.png" /></figure><h4>Step 6 — Kinesis Firehose</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*Yf-daRXVpuN_yxPiKDS59A.png" /></figure><p>In this phase we will configure Kinesis Firehose , We will make sure that appropriate partition keys are set in place .This will ensure ease of compartmentalisation.</p><p><strong>1)Navigate to Kinesis Firehose</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/284/1*Br0z5LLEYed2paALLrc6_g.png" /></figure><p><strong>2)Create new delivery stream</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tYJO6JPrE2g3rbiC2IvBpw.png" /></figure><p><strong>3)For source select Kinesis Data stream</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*UmMwUbBMEETpH0N-Eqwg8g.png" /></figure><p><strong>4)For destination select S3</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*v-pm7XIN5MXIlVkcSPjJhQ.png" /></figure><p><strong>5)For source settings choose the data stream that you created earlier</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*Ny-TFTV1SFTlnlHBLf9qsQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-y07XpKuTNIVPgg1XANTRg.png" /></figure><p><strong>6) For Destination settings -&gt; S3 bucket ,select “Create”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*Yz3P_9gudV64U7VJrt5pBA.png" /></figure><p><strong>7) Select the AWS isoft bucket that we created earlier, and click on “Choose”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/1*03qZW4M9lwPKZQuLoT4sPw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/230/1*XXnBgQ5NEovX40kBNJUqgw.png" /></figure><p><strong>8) Enable Dynamic Partitioning </strong><br>Explanation(Optional read) :You might wonder , why this is important. We require dynamic partitioning to ensure that the information is dropped in different compartments . Take our current use case as an example . By ensuring that all the data is getting dropped into the right folders</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*ymZpd7RCzHbF11lTf3KP2w.png" /></figure><p>We are ensuring that data analytics can happen with much more ease .<br>Another use case , Assume that you are a data analytics engineer and you were told to to check the sales trends for the month of October . It wouldn’t take too much effort for you to write a code that can check only those folders and select data from only those folders that are belonging to October. Bottom line , our life gets lot more easier with dynamic partitioning , especially in terms of organizing our data and retrieving relevant information .</p><p>Enable dynamic partition</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*avlWvhVMHCosLJCC9KOkKQ.png" /></figure><p><strong>9) Enable Inline json parsing</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*eUrXr5rZLFvTZh8hQWL9Gw.png" /></figure><p><strong>10) Choose keys for dynamic partitioning . </strong><br>Explanation (Optional) : The following is sample json data</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*w4oJ0rjNe2TX9YdP_PIJQw.png" /></figure><p>I would like to organize the data according to the date format . Hence I’m going to use that basis for dynamic partitioning.</p><p>Add date as key name</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*68wA1xeurOKIoUvwKQoSug.png" /></figure><p><strong>11) Adding S3 bucket prefix to navigate data to specific folders.</strong><br> Explanation(Optional) : Since we would want the information to get dumped into a specific folder in raw_test . We would want to add that as prefix .</p><p>Type raw_test as prefix and click on Apply dynamic partition</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*hYr-AUdaNydB0EK2xFkyyw.png" /></figure><p><strong>12) You should be able to see the following information</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*JwJmbiWNoCUMy3uU1VoSEg.png" /></figure><p><strong>13)For S3 bucket error output type the following folder name</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*xpKg2_dIbVVHI1YAtfvlAw.png" /></figure><p>You can name it however you would like . But make sure to distinguish between the main target folder and the error folder</p><p><strong>14) Finally click on “Create Delivery Stream”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*nzeacH20OcM5bo40Wznn6A.png" /></figure><h4>Finally</h4><p>We have completed end-to-end implementation of Data Funel Architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*x19WuAXpMB8I43Sut1lfbw.png" /></figure><p>Lets start testing our new toy and see how its performing</p><h3>End to End Testing</h3><p>I have run the code snippet for data streaming on my python jupyter notebook</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*frp23Fs24H2TZCCbJ16YTw.png" /></figure><p>Lets check if the records are added into the data streams .I have navigated to my “data-streamer” in Kinesis . I have entered the sequence number of my first transaction</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3bmfsyka539kvkue1a__HA.png" /></figure><p>We can see that the data is getting properly reflected .<br>Now ,When you navigate to firehose , you should see error logs status like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*A2KuVYP7W6HdpeLJYOeUqw.png" /></figure><p><strong>Debugging error logs</strong> (Optional):<br><strong>NOTE</strong> : Go through this step if you have having error logs and its unclear on what exactly caused those errors . <br>But don’t worry even if you are getting destination error logs ,you can always debug them in logs . How do we go to cloudwatch logs?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YEIDXmaNPLDCzt9tGnGK2Q.png" /></figure><p>Once we navigate to cloudwatch , you should see log groups on the left panel</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*xXcovhSwsvFyLZQTyX57VA.png" /></figure><p>Select your firehose streaming service . Mines as following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7LHns8apYxM6TZ7mST5pyw.png" /></figure><p>At log streams , you should be able to see these two log stream . If you check “DestinationDelivery”, you should see logs for firehose funnel</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*vKrqYCBU3k1LZQGr-xf6uQ.png" /></figure><p>Alright,you still with me? If you are then good job. You are doing great :D . BACK to the main course of action , lets check the S3 bucket</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*bTvN1wxR5O9owkpLimo_EA.png" /></figure><p>You should be able to see the following results</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*C_TW8Bh2QtqcUCRmwTJHSQ.png" /></figure><p>Within <em>raw_test</em> folder</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*3l8KDpaA0dBbirLxkNHmUA.png" /></figure><h3>Limitations</h3><p>The only limitations to the project</p><ol><li>Operating within the limits of AWS free tier features</li><li>As long as the data is consistent with format that you have mentioned in data streams (Dynamic partitioning option in firehose). You should be good to go</li></ol><h3>Conclusion</h3><p>And that’s all folks! If you were able to follow all the instructions and you understood the purpose of each task , then congratulations! 🎉🎉</p><p>You just created your first Data Engineering Project using AWS tools !</p><p>One of the advantages with this architecture is that you can add as many data producers as you need(as long as you are operating within limitations I mentioned earlier) . No matter how many data producers you will add, your AWS architecture will be able to herd them all like a dog herding a sheep.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/1*nvcvkOtx4YAdjVuaeP-12g.jpeg" /></figure><p>Hope this tutorial was informative . Please reach out if you have any questions or suggestions .Until then</p><p><em>To infinity and beyond…</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40c4d4506361" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A beginner’s guide to Monte Carlo Search tree]]></title>
            <link>https://medium.com/@amos.eda/a-beginners-guide-to-monte-carlo-search-tree-46bc59a7005d?source=rss-8c2b759efa9------2</link>
            <guid isPermaLink="false">https://medium.com/p/46bc59a7005d</guid>
            <category><![CDATA[reinforcement-learning]]></category>
            <category><![CDATA[monte-carlo]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Amos Eda]]></dc:creator>
            <pubDate>Wed, 19 Jul 2023 00:21:29 GMT</pubDate>
            <atom:updated>2023-07-19T00:22:07.119Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*92Ym20WVB0gG2kbo" /><figcaption>Image can be found <a href="https://images.unsplash.com/photo-1552566626-52f8b828add9?ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxzZWFyY2h8OHx8cmVzdGF1cmFudHxlbnwwfHwwfHx8MA%3D%3D&amp;w=1000&amp;q=80">here</a></figcaption></figure><h3>The restaurant</h3><p>Picture this, you were 10 years old and your family decided to take you to this amazing restaurant . You were skeptical on how the dish was going to taste , but you keep all your premonitions aside and trust your father against your best judgement. He keenly looks over the menu , peeking at you every now and then with a quizzical look (almost as if he is trying to figure out what ) and finally orders Roasted chicken .The dish arrives and you dig in to your first bite …. and then voila , you realize that his selection was actually quite good!</p><p><strong>Score to dad for knowing your taste</strong></p><p>The next day , you tell your friend about this . You tell her “I had this roasted chicken at this amazing restaurant that my dad took me to” .And your friend , she is listening intently to what you are telling her . She starts making a mental note inside her head , kind of jotting down notes on her imaginary RAM .After taking a few moments, she drags you downtown and takes you to another restaurant . She then takes a peek at the menu and orders roasted turkey hoping that she has just the perfect cuisine for you . You dig into that first bite ….and voila! It was good as well .</p><p><strong>Looks like your friend knows you well!</strong></p><p>Now for some odd reason , your friend is on a roll and she decided to try her luck once again . But this time she has decided to switch the genre . She takes you to her favorite seafood restaurant in hopes that she can sweep you off your feet with yet another brilliant selection .You enter the restaurant and you immediately feel your stomach rumble , You could feel it in your bones that this one is going to make the mark , it’s going to hit the spot and your friend is going to get commended . The food is ordered and delivered to your table, your mouth is all watery and you can’t wait to have your first bite .Your friend being the religious person that she is , started praying . You didn’t close your eyes (Eyes on the prize) . As soon as she said amen , you dig into your first bite .. AAAND it was terrible.</p><p><strong>Unfortunate :/</strong></p><p>You’re probably wondering “Why did I waste 5 minutes of my precious time reading this absurd story that has absolutely nothing to do with the title.” Hold on to your horses , this has a context ,I’ll be getting to that shortly</p><h3>Monte Carlo Tree Search</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i6RhdYDFGgs8KfVFs9ERaw.png" /><figcaption>Image can be found <a href="https://media.geeksforgeeks.org/wp-content/uploads/mcts_own.png">here</a></figcaption></figure><p>Take a clear look at the image .If you have skipped the story because you thought it was boring , then try reading it again and come back here.</p><p>Good? Alright. Let’s explore Monte Carlo Tree Search algorithm now</p><h3>Exploitation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/0*Boxssy_Xv54XLRiO" /><figcaption>Image can be found <a href="https://media.istockphoto.com/id/1217649450/photo/chicken-or-hen-on-a-green-meadow.jpg?s=612x612&amp;w=0&amp;k=20&amp;c=zRlZTkwoc-aWb3kI10OqlRLbiQw3R3_KUIchNVFgYgw=">here</a></figcaption></figure><p>When your dad took you to your first restaurant he began the first selection . He wasn’t sure if it was going to work , he had some preemptive knowledge of what you might like and dislike , and went ahead and ordered roasted chicken for you . This worked out brilliantly in your case! .Maybe he noticed how you always loved it when your mom cooked chicken for you .The selection was done based on the parameters that he had over you .</p><p>Exploitation in reinforcement learning involves making decisions based on known information or past experiences to maximize the immediate rewards.</p><p>In the first restaurant, your dad observed how much you enjoyed chicken when your mom cooked them for you. He likely inferred that Roasted Chicken would be a safe and satisfying choice for you based on your past reactions to chicken meals. This decision was made by exploiting the knowledge he had about your taste preferences.</p><h3>Exploration</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*LPIqmhg3y8OI45kr" /><figcaption>Image can be found <a href="https://images.unsplash.com/photo-1610847188112-fda7a87b39a3?ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxzZWFyY2h8Mnx8dHVya2V5JTIwYmlyZHxlbnwwfHwwfHx8MA%3D%3D&amp;w=1000&amp;q=80">here</a></figcaption></figure><p>Now coming to your friend, she had some information on you , but she wasn’t with you your entire childhood. She had some idea of what you might have liked and what you might have disliked .And based on the information that you gave her , she decided to something different . A slight variation from your first dish roasted chicken , or rather its cousin : Roasted turkey .</p><p>Exploration involves taking actions that are less predictable or not based solely on past knowledge. While your friend had some idea of your likes and dislikes from the information you gave her, she decided to try something different, moving away from the known choice of Roasted Chicken.</p><h3>Exploration vs Exploitation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/0*JKRHWIx9HJFuwZZV" /><figcaption>Image can be found <a href="https://media.istockphoto.com/id/627987316/photo/salmon-fish-isolated-on-white.jpg?s=612x612&amp;w=0&amp;k=20&amp;c=eDA2DkO8PbnQ7_F4w7B6RYM4TGTWhB5VEd1mpvF3BD4=">here</a></figcaption></figure><p>In the third try , when she tried to get you to try seafood , you had an instinct that told you that you were going to like it (Based on just the smell ) . How does this relate to MCST? In MCST reinforcement learning, an agent (in this case, you) faces the challenge of balancing between exploitation, which involves choosing actions that are known to have high rewards based on previous experiences, and exploration, which involves trying out new actions to gather more information about their potential rewards.</p><p>When your cousin took you to a seafood restaurant, you had an instinct or a hunch that you were going to like it based on your previous good experiences with your father and friend’s previous restaurant choices. This corresponds to the exploitation aspect, where you decided to exploit the knowledge from your past successes and selected the seafood restaurant, expecting a good reward (delicious food) in the short run. Unfortunately this didn’t turn out good for you .</p><p>It wasn’t the outcome that you hoped for, and the dish turned out to be terrible.</p><p>This highlights the importance of exploration in reinforcement learning. Even though you had positive experiences before, it’s still essential to explore new options (new restaurants) to avoid getting stuck with a limited set of choices and risking losing in the long run (ending up with a bad experience).</p><h3>Conclusion</h3><p>Monte Carlo Tree Search Algorithm is the one of core fundementals of Reinforcement learning .A lot of algorithms work based on this concept , understanding it is pivotal and I hope this article helped you get a base idea on its inner workings . The actualy implementation is lot more rigorous , but having a basic understanding takes you a long way .</p><p>If you liked this article , then make sure to follow me! Reach out to me at <a href="https://www.linkedin.com/in/amos-eda-839870185/">https://www.linkedin.com/in/amos-eda-839870185/</a> . As always ,if you have any constructive criticism. I would love to hear all about it!</p><p><em>To infinity and beyond …</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46bc59a7005d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>