<?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 Sindhu Madicherla on Medium]]></title>
        <description><![CDATA[Stories by Sindhu Madicherla on Medium]]></description>
        <link>https://medium.com/@sindhu.madicherla?source=rss-1bd2f334eb5b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*MIwkseWa2d8xXeps</url>
            <title>Stories by Sindhu Madicherla on Medium</title>
            <link>https://medium.com/@sindhu.madicherla?source=rss-1bd2f334eb5b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 07:19:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sindhu.madicherla/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[RAG Chatbot using ChromaDB, LlamaIndex, Open AI, and Streamlit]]></title>
            <link>https://medium.com/@sindhu.madicherla/rag-chatbot-using-chromadb-llamaindex-open-ai-and-streamlit-d3fb87df415f?source=rss-1bd2f334eb5b------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3fb87df415f</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[chatgpt]]></category>
            <dc:creator><![CDATA[Sindhu Madicherla]]></dc:creator>
            <pubDate>Tue, 07 May 2024 06:16:24 GMT</pubDate>
            <atom:updated>2024-05-07T06:17:07.787Z</atom:updated>
            <content:encoded><![CDATA[<h3>RAG Chatbot using ChromaDB, LlamaIndex and Streamlit</h3><p>This article aims to create a simple chatbot application called ‘<strong>ResearchBot</strong>’, using research articles from arXiv. <a href="https://arxiv.org/">ArXiv</a> is an open-access archive for millions of scholarly articles. We will implement RAG architecture using Llama index Open AI for embeddings, Chroma DB for vector store, and Streamlit for building a simple UI. The gitub link for the same can be found <a href="https://github.com/Sindhu-Madicherla/researchbot">here</a>.</p><p>Before moving forward, make sure that you are familiar with RAG, and also have an Open AI API key. On a high level, RAG architecture allows us to feed data from external sources to pre trained LLMs like Open AI, LLAMA etc. and get responses that are more relevant to our use case.</p><p>We will start by pulling the required modules from <a href="https://github.com/Sindhu-Madicherla/researchbot/blob/main/requirements.txt">requirements.txt</a> . All the required variables, along with Open AI Key have to be mentioned in <a href="https://github.com/Sindhu-Madicherla/researchbot/blob/main/src/ResearchBot/variables/configs.py">configs.py</a>. Our code flow can be divided into 2 major operations.</p><ol><li>Data Ingestion</li><li>Data Retrieval</li></ol><h3><strong>Data Ingestion :</strong></h3><h4><strong>Download and parse data from Arxiv</strong></h4><p>ArXiv provides a python module called arXiv, which we will use to download the articles in PDF format. We can either search by the paper ID, or get the papers related to a particular topic.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a13dfa8b25f5374968f8db80c0e9011a/href">https://medium.com/media/a13dfa8b25f5374968f8db80c0e9011a/href</a></iframe><p>Once the papers are downloaded, we convert them to markdown text and to Documents finally, which can be parsed by Llama Index’s MarkDownNodeParser</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b5de290147e974dc274e7681c2d61701/href">https://medium.com/media/b5de290147e974dc274e7681c2d61701/href</a></iframe><p>I am splitting the documents into chunks of size 5000, as the documents are lengthy sometimes, and Open AI’sext-embedding-3-small has a token limit of 8191 tokens.</p><p>We can load data of any other type by choosing the right parser from <a href="https://docs.llamaindex.ai/en/stable/module_guides/loading/node_parsers/modules/">Llama Index Node Parsers</a>.</p><h4><strong>Embed the articles and store them to Vector Store:</strong></h4><p>We need to first create a Vector store or get an existing one using Chromadb. I am using Open AI embedding function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7247073e75ed3306e85c2a25f13976db/href">https://medium.com/media/7247073e75ed3306e85c2a25f13976db/href</a></iframe><p>As of now, we have just collected all the required ingredients to be able to save the data. We now need to run the final Ingestion pipeline available from LlamaIndex to persist the data into the Chroma Vector Store that we have created</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c458c6059c046da6f6858bdcad14966/href">https://medium.com/media/0c458c6059c046da6f6858bdcad14966/href</a></iframe><p>We can cache the data locally, to be able to access it faster later.</p><h3><strong>Data Retrieval</strong></h3><h4>Index retrieval</h4><p>Index is the key component in our retrieval, and the main entry point to the Vector Store index. We will first retrieve the index from the Vector Store created above. When the user asks a question in the chatbot, we can get the top K nodes which are the most similar to the query using the index.as_retriever method. We can then add the data as context and build the prompt to Open AI</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bfca86e0cbd25214c5f88f54e92fc1ef/href">https://medium.com/media/bfca86e0cbd25214c5f88f54e92fc1ef/href</a></iframe><p>Once the prompt is built, we will send this to Open AI Chat Completion method to get the response. The files <a href="https://github.com/Sindhu-Madicherla/researchbot/blob/main/src/ResearchBot/utils/chat.py">chat.py</a> and <a href="https://github.com/Sindhu-Madicherla/researchbot/blob/main/src/ResearchBot/utils/thread.py">thread.py</a> have been written additionally under utils to be able to maintain the chat thread.</p><p>We can also add ‘<strong>Function calling</strong>’ option while sending the request to Open AI. This option allows us to call other functions by intelligently generating a JSON object that contains the arguments to the function. We need to have proper doc string to mention what should be the values to the inputs of the function. In our case, we have added the function ‘<strong>context_retriever</strong>’, which will pull more relevant data , if needed by the LLM. We can let the LLM decide to call the function or not by providing ‘tool_choice’ as ‘auto’.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/13d2c9056931f732c38c5ca4f819bdf3/href">https://medium.com/media/13d2c9056931f732c38c5ca4f819bdf3/href</a></iframe><p>More information on Function Calls can be found in <a href="https://platform.openai.com/docs/guides/function-calling">Open AI documentation</a></p><h3>Streamlit application :</h3><p>This is the final part where we build our <a href="https://github.com/Sindhu-Madicherla/researchbot/blob/main/app.py">app.py</a> by combining the data ingestion and retrieval logics mentioned above. We can create a simple chatbot interface using Streamlit’s <strong>st.chat_input</strong> and <strong>st.chat_message</strong> methods. It should be able to do the following activities.</p><ul><li>Load the Vector index on starting the application. We can add a cache_resource decorator while calling the method to load index, so that the the function runs only once during the start of the application.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a6893bcaf6ebee5c2890d242dafe69a3/href">https://medium.com/media/a6893bcaf6ebee5c2890d242dafe69a3/href</a></iframe><ul><li>Retrieve index, get the relevant nodes to the user query, and print the response in the conversation. The conversations will have to be saved in streamlit’s session_state to display it as a chat</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b773e3f15ff3e5a18a0f3abfa29e4d76/href">https://medium.com/media/b773e3f15ff3e5a18a0f3abfa29e4d76/href</a></iframe><ul><li>Run the pipeline to load new data on uploading a file. We will add upload button to our page on the top. The content in the file can either be a comma separated list of page IDs , or a specific topic like “topic-Generative AI”. Example pages have been given in <a href="https://github.com/Sindhu-Madicherla/researchbot/blob/main/papers.txt">papers.txt</a> and <a href="https://github.com/Sindhu-Madicherla/researchbot/blob/main/papers1.txt">papers1.txt</a></li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/272bf79c74d05e96367322ea7e2f231c/href">https://medium.com/media/272bf79c74d05e96367322ea7e2f231c/href</a></iframe><p>Finally, run the below to start the application and chat with it.</p><pre>streamlit run app.py</pre><p>The application looks like below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lTkz1acBSzn7y-5CRvRa8A.png" /></figure><p>We can play around the application by modifying values like Prompt, temperature , embedding model etc. We can further add CI/CD pipeline and make into a docker application hosted on AWS by following the corresponding sections in this <a href="https://medium.com/dev-genius/end-to-end-ml-ops-application-using-aws-ec2-7577e78646e7">medium post</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3fb87df415f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[End to End ML Ops Application using AWS EC2]]></title>
            <link>https://blog.devgenius.io/end-to-end-ml-ops-application-using-aws-ec2-7577e78646e7?source=rss-1bd2f334eb5b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7577e78646e7</guid>
            <category><![CDATA[mlflow]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[mlops]]></category>
            <dc:creator><![CDATA[Sindhu Madicherla]]></dc:creator>
            <pubDate>Fri, 29 Dec 2023 12:24:41 GMT</pubDate>
            <atom:updated>2024-06-24T06:48:35.346Z</atom:updated>
            <content:encoded><![CDATA[<p>This article is a step by step explanation on how to deploy a simple machine learning web application from end to end, evaluate performance with MLFlow, and add CI CD pipeline with Github actions. The application will be deployed as a docker container on Amazon EC2 instance . The target is to predict if a person is prone to Heart Attack given their health indicators.</p><p>We will be using the health data from the Kaggle notebook ‘<a href="https://www.kaggle.com/datasets/kamilpytlak/personal-key-indicators-of-heart-disease/data">Indicators of Heart Disease</a>’. The data file for 2020 has been uploaded in <a href="https://github.com/Sindhu-Madicherla/Heart_Disease_Predictor/blob/main/heart_disease.zip">git</a>. The source code is available at ‘<a href="https://github.com/Sindhu-Madicherla/Heart_Disease_Predictor">Heart_Disease_Predictor</a>’. The data consists of health/lifestyle profile of around 319795 people.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ONIKbv0u_vhBLEzXMJI6vQ.png" /></figure><p>We will not be delving into the EDA part, as we will focus more on the training pipeline. We will be using a Neural Network with 2 hidden layers with ReLu activation function, and finally a SoftMax layer. I have used 20 epochs for training, a learning rate of 0.01, BCE loss, and Adam optimizer for model building. All the source code can be referred from the <a href="https://github.com/Sindhu-Madicherla/Heart_Disease_Predictor">github</a> repository. On a high level, we will follow the below path :</p><p>Model Training &gt; Building Web Application &gt; Github Actions &gt; EC2 Deployment</p><h3>Initial setup :</h3><h4>Git Repository setup :</h4><ul><li>Create a new github repository, and open terminal in the repo folder. Create a new environment , and activate it</li></ul><pre># Using Conda<br>conda create -n heartDisease python=3.8 -y<br>conda activate heartDisease<br><br># Using venv<br>python -m venv heartDisease<br>.\heartDisease\Scripts\activate</pre><ul><li>Run the script ‘<a href="https://github.com/Sindhu-Madicherla/Heart_Disease_Predictor/blob/main/template.py">template.py</a>’ to create the folder skeleton and important files. All the source files will get created under a folder with the project name. Project name has been kept as ‘<strong>HeartDisease</strong>’ for this project .</li><li>Update <strong>requirements.txt</strong> file with all the required modules, and update setup.py . The SRC_REPO in setup.py is the same as ‘project_name’ variable in template.py. Install the requirements by running the below in command prompt.</li></ul><pre>pip install -r requirements.txt</pre><h4>MLFlow/Dagshub Setup :</h4><p>I used Dagshub to connect to MLFlow, and log the experiments. In <a href="https://dagshub.com/">Dasghub</a>, click on Create, and then ‘<strong>Connect a Respository</strong>’ . Connect to ‘Github’ in the next page. Under ‘<strong>Repository access</strong>’ <strong>, </strong>select the newly created git repo and save.</p><p>Once the repository is created, navigate to the repo page, and click on <strong>Remote &gt; Expriments</strong> to get the MLFlow tracking URI, and credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*skAmuNfxLVVAMeAGwWRRjw.png" /></figure><p>To be able to use this MLFLow URI to log our model evaluation results, we need to set the variables in our new environment . If you are using Anaconda prompt, the variables can be set using the below code .</p><pre>export MLFLOW_TRACKING_URI=https://dagshub.com/sindhu.madicherla/Heart_Disease_Predictor.mlflow<br>export MLFLOW_TRACKING_USERNAME=sindhu.madicherla <br>export MLFLOW_TRACKING_PASSWORD=***</pre><p>After model evaluation, the logged experiment results can be seen under Experiments in the Dagshub Repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1EFJFyXRs1tA6fvQng6JEw.png" /></figure><h3>Prediction Pipeline</h3><h4>Application Code :</h4><p>The prediction pipeline is designed to have 5 stages, which are Data Ingestion, Data Validation, Data Transformation, Model Training, and Model Evaluation. Here is a brief overview of what will be performed at each stage.</p><ol><li><strong>Data Ingestion </strong>: Download the data file from the github source url mentioned in config.yaml, extract the data, and create a new folder artifacts/data_ingestion/ to store the data</li><li><strong>Data Validation</strong> : Read data from the stored location, and compare the data columns against the columns mentioned in schema.yaml</li><li><strong>Data Transformation </strong>: Convert the target column (HeartDisease) to numeric, split the data to train and test , fit target encoders on categorical columns of the train data, and transform the test data. Store the train data, test data, and the encoder artifacts/data_transformtation/ folder</li><li><strong>Model Trainer</strong> : Creates a Neural Network model with the structure given in ‘NeuralNetwork.py’, trains the model, and saves it under artifacts/model_trainer</li><li><strong>Model Evaluation</strong> : Runs the model , and stores the accuracy and loss as a new experiment using the MLFlow URL</li></ol><p>On a high level, each stage will be called in main.py, by initiating a class corresponding to that stage from the <strong>pipeline</strong> folder. Each of these pipeline classes would first get the required config by instantiating the necessary config from <strong>configuration.py</strong>, which gets the data stored in <strong>config.yaml</strong>. This config is then used to initiate the corresponding class from <strong>components</strong> folder, which has the functions defined to perform the operations specific to the stage.</p><p>Before we go into the implementation details of the pipeline, we need to update the below files with the required information.</p><ol><li><strong>config.yaml </strong>: Used to store the data or model paths for each stage. The source_URL in data_ingestion stage has to be updated with the git location of the source file.</li><li><strong>params.yaml </strong>: Used to store the model parameters, which we can finetune for better accuracy.</li><li><strong>schema.yaml </strong>: Used to store the schema of the dataset.</li></ol><p>Once these files are updated, we need to update the necessary files for each stage in the training pipeline. I will mention the files setup for the data ingestion stage below, and the other stages can be implemented in a similar fashion. The files can be created from scratch, or the existing ones from the git source code can be updated.</p><ul><li>Create an entity class called <strong>DataIngestionConfig </strong>in entity/config_entity.py, to store the required variables or paths.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9037454e4a8cebe5ec36f9780c9bc1e0/href">https://medium.com/media/9037454e4a8cebe5ec36f9780c9bc1e0/href</a></iframe><ul><li>Define the method ‘<strong>get_data_ingestion_config</strong>’ in Configuration manager class under config/configuration.py , which will create the required directory, and return <strong>DataIngestionConfig</strong> class .</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/343f9b2bf41998f2d29be26d92166793/href">https://medium.com/media/343f9b2bf41998f2d29be26d92166793/href</a></iframe><ul><li>Create a script ‘<strong>data_ingestion.py</strong>’ under component folder, which has the methods defined to perform the necessary actions at that stage. For the data ingestion stage, it will download data file, extract the data, and store it in a folder ‘data_ingestion’ under artifacts folder.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4dd9fc3b78f0faf60d77b35fa990e1ae/href">https://medium.com/media/4dd9fc3b78f0faf60d77b35fa990e1ae/href</a></iframe><ul><li>Finally, create the script ‘<strong>stage_01_data_ingestion.py</strong>’ under pipeline folder, which will create the required classes, and call the methods on instantiating it</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cd946075f28e848e7706c39c28916bce/href">https://medium.com/media/cd946075f28e848e7706c39c28916bce/href</a></iframe><ul><li>Once the files are setup, <strong>main.py</strong> has to be updated to call the Data Ingestion stage .</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f716da840efda170dc30bbb7277e384a/href">https://medium.com/media/f716da840efda170dc30bbb7277e384a/href</a></iframe><p>Once the scripts are completed for all stages, main.py can be called to run and test the application. Ideally, the pipeline should download data, split it to train and test, perform category encoding and store the encoder, train the model on train data, evaluate it on test data, and store the accuracy and loss in MLFlow.</p><p>To be able to predict for a new data, we need to create the <strong>prediction.py</strong> file under pipeline folder.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/650f64deafdb25d06c25d777c2385e66/href">https://medium.com/media/650f64deafdb25d06c25d777c2385e66/href</a></iframe><p>It will take a new row of data as input, convert to a tensor, and pass through the model. If the return value is greater than 0.5, it means that the person is at the risk of Heart Disease</p><h4>Github Actions :</h4><p>Github’s actions can help us with the CI CD pipeline. A new docker image is built and pushed when there are any changes made to the repository. The code for this has to be updated under <strong>.github &gt; workflows &gt; </strong><a href="https://github.com/Sindhu-Madicherla/Heart_Disease_Predictor/blob/main/.github/workflows/main.yaml"><strong>main.yaml</strong></a></p><p>After EC2 instance setup, github will login to ECR, build a new docker image, and run it whenever there is a new push to the repository.</p><h3>UI and Docker Configuration</h3><p>The next step is to create a UI for the application, where we can enter the input data, and call prediction.py to give the result. The html scripts for the main page, and the prediction page have to be created under <strong>templates</strong> folder, as per the required design. I have created a basic form to take the input. The corresponding css, and other static files are under the folder <strong>static</strong> .</p><p>Finally, we use Flask to run the application, and update the code for default, train, and prediction endpoints in <a href="https://github.com/Sindhu-Madicherla/Heart_Disease_Predictor/blob/main/app.py">app.py</a> . The default endpoint or the index page will be used to take the inputs, train endpoint will use <strong>main.py </strong>to build and train the model, and predict endpoint will use <strong>prediction.py</strong> .</p><p>The application can now be open on the local machine by running app.py. It opens up on <a href="http://127.0.0.1:8080/">http://127.0.0.1:8080/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0e6hVUsmZqdqXxlp8fURsQ.png" /><figcaption>Index Page</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ReORQNRlE3k6Qe4She7a-w.png" /><figcaption>Results Page</figcaption></figure><p>To containerize the application, update the contents of <strong>Dockerfile </strong>as below.<strong> </strong>We are installing AWS CLI here as we will run the application on EC2 instance later.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/33fbbeca1dad528024bc8be86afdfe54/href">https://medium.com/media/33fbbeca1dad528024bc8be86afdfe54/href</a></iframe><h3>AWS setup :</h3><p>To deploy the application on an EC2 instance, we first need to have a user to login, and a repository on ECR to upload the docker containers.</p><h4>User creation (IAM)</h4><ul><li>Login to AWS console, and open IAM. Click on Users and select ‘Add user’ .</li><li>While creating, select ‘<strong>Attach existing policy</strong>’ and attach the policies ‘<strong>AmazonEC2ContainerRegistryFullAccess</strong>’ and ‘<strong>AmazonEC2FullAccess</strong>’</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G15lPxFUSTPemHHaitaqFg.png" /></figure><ul><li>Once the user is created, go to the user page, and click on ‘<strong>Create Access keys</strong>’. Select ‘<strong>Command Line Interface</strong>’ and create the keys. Download the csv file of the access keys, as it will be useful in further steps.</li></ul><h4>Elastic Container Registry (ECR)</h4><ol><li>Open ECR page in AWS console, and create a new repository with a suitable name.</li><li>Copy the repo URI of the new new repository, and save it as it will be used later</li></ol><h4>EC2 setup</h4><ul><li>Open EC2 in AWS console, and click on ‘<strong>Launch Instance</strong>’, to create a new instance</li><li>Instance type can be Ubuntu, which has at least 8 GB RAM . Create a ‘<strong>Key Pair</strong>’ of type ‘<strong>RSA</strong>’. This key pair can be used when we have to login to the server from elsewhere . Under ‘<strong>Configure Storage</strong>’ , replace with 32 minimum, and finish launching the instance</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g5c2QFEezdVmMyZW0P4eHw.png" /></figure><ul><li>Head to ‘<strong>View All Instances</strong>’ , and wait for the state of the new instance to turn to ‘<strong>Running</strong>’ . Once it is running, click on the Instance ID, and select ‘<strong>Connect</strong>’ to connect to the instance</li><li>Once the terminal opens, install docker on it by running the below commands.</li></ul><pre>curl -fsSL https://get.docker.com -o get-docker.sh<br>sudo sh get-docker.sh<br>sudo usermod -aG docker ubuntu<br>newgrp docker</pre><ul><li>As we are running the application on port 8080, we need to allow the port on the server. Navigate to the EC2 instance page, click on ‘<strong>Security</strong>’. Select the security group, and click ‘<strong>Edit Inbound Rules</strong>’, and add a rule, with type as ‘<strong>Custom TCP</strong>’. Change the ‘<strong>Port Range</strong>’ to 8080, change IP range to ‘0.0.0.0/0’ , and save the rules.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NkZpzOHIgx62-BJoYhq82Q.png" /></figure><ul><li>For any changes on the github repository to reflect on the EC2 instance, we need to set the instance as a self hosted runner. Open the github project, and navigate to <strong>Settings &gt; Actions &gt; Runners</strong></li><li>Select ‘<strong>New self-hosted runner</strong>’ and then select Linux. This would give a list of commands , which have to be implemented step by step on the EC2 server. Once we run.sh, , it will be listening for the jobs</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sn54ilCmYJxbReNdyKxGaQ.png" /></figure><h4>Github Secrets :</h4><p>For the Github to connect to the EC2 server to perform the actions, we need to add AWS specific parameters in the repository.</p><p>Under the Github repository settings, click on ‘<strong>Secrets and Variables</strong>’ , and then <strong>Actions</strong>. Click on ‘<strong>New Repository Secret</strong>’, and all the variables mentioned in the README file .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T5XdLJEyuHkoYk3t_x28Kg.png" /></figure><h3>Final Steps</h3><p>As the CI/CD setup is implemented via Github actions and EC2 self hosted runner, whenever a new change is pushed to the github repository, a new version of docker application will be created and uploaded to ECR. This will take some time based on the application content. The output during this process can be seen in the Github repository’s actions .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2z0qdQhddu_2cPUC08yrYQ.png" /></figure><p>To run the application, copy the public IP address from the EC2 instance, and run it with port 8080.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NYfLi8I-0NcG8xMTDSL0Nw.png" /></figure><p>It is a good practice to delete all the AWS instances once the project is completed, as they are chargeable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7577e78646e7" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/end-to-end-ml-ops-application-using-aws-ec2-7577e78646e7">End to End ML Ops Application using AWS EC2</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>