<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Anam-Mahmood</title>
    <description>The latest articles on DEV Community by Anam-Mahmood (@anammahmood).</description>
    <link>https://dev.to/anammahmood</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F618065%2Fe886ff58-bc05-491a-9426-5c0d7ec8e03c.png</url>
      <title>DEV Community: Anam-Mahmood</title>
      <link>https://dev.to/anammahmood</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/anammahmood"/>
    <language>en</language>
    <item>
      <title>Energy Sustainability: Create a Climate Impact Rating System</title>
      <dc:creator>Anam-Mahmood</dc:creator>
      <pubDate>Sun, 25 Apr 2021 17:30:36 +0000</pubDate>
      <link>https://dev.to/ibmdeveloper/energy-sustainability-create-a-climate-impact-rating-system-4ifj</link>
      <guid>https://dev.to/ibmdeveloper/energy-sustainability-create-a-climate-impact-rating-system-4ifj</guid>
      <description>&lt;p&gt;As the population is growing, so is the energy demand. This has resulted in fossil fuels affecting the environment, from air and water pollution to climate change. Adopting alternatives like solar and wind, along with improving productivity can help provide cleaner and more efficient energy. &lt;/p&gt;

&lt;p&gt;While we must switch to clean energy in our home to make an impact on the climate, it is also important to consider the commercial sector as the energy consumption there is often much higher than in the residential sector. That's because a major portion of this energy consumption goes into products that we buy. &lt;/p&gt;

&lt;p&gt;For changes to take place in the commercial sector it is important to raise consumer awareness about energy costs and other greenhouse gases being emitted in the manufacturing process of the goods that we buy. So by creating a Climate Impact Rating system (CIR) we give consumers like us, an idea of what goes into the making of the industrial products that we buy. This creates a framework for a product labeling system and includes a CIR (climate impact rating) system which will be visible to the consumers at the point of sales so they can see what they are bringing into their homes. &lt;/p&gt;

&lt;p&gt;CIR is very similar to the labeling found on food that tells you exactly what and how much went into making that particular food item. For example, the amount of sugar, fat, and carbs. Similarly, this rating system will show you how much energy, co2, water, plastic, and other consumables were consumed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The following is the architecture:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn8chvrfgm5pe83q21t9z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn8chvrfgm5pe83q21t9z.png" alt="Architecture-of-the-App"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The user scans a product barcode with an app, which then calls the Climate Impact Rating API, passing in the barcode ID.&lt;/li&gt;
&lt;li&gt;The Climate Impact Rating API retrieves the rating data that matches that barcode ID.&lt;/li&gt;
&lt;li&gt;The Climate Impact Rating API returns the rating data for the app to format and display appropriately.&lt;/li&gt;
&lt;li&gt;Manufacturers can upload product and rating data via the Climate Impact Rating API (via a reserved portal).&lt;/li&gt;
&lt;li&gt;In the future, a Climate Impact Analyzer will run in the background to produce summary data, enabling broader rating queries to be satisfied by the API.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Steps
&lt;/h2&gt;

&lt;h4&gt;
  
  
  Step 0: Clone the Repo
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;https://github.com/Anam-Mahmood/Solution-Starter-Kit-Energy-2020&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 1: Create a free IBM Cloud account or log in to IBM Cloud
&lt;/h4&gt;

&lt;p&gt;&lt;a href="//ibm.biz/ArabAISummit"&gt;Create free account or Login&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 2: Create Cloudant Service on IBM Cloud
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Search for "Cloudant" on IBM Cloud.&lt;/li&gt;
&lt;li&gt;Select "Cloudant" from the Select an offering section.&lt;/li&gt;
&lt;li&gt;Select "Multi-tenant" in the environment and "Dallas" or "London" in the region, give your service instance a unique name.&lt;/li&gt;
&lt;li&gt;Make sure to select "IAM" in the authentication method and select the free "Lite" plan and click on create.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb60zth4xudzmx3hy2u9k.png" alt="Create Cloudant Service on IBM Cloud"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Step 2.1: Create Cloudant service credentials
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Once your Cloudant instance has been created, you need to create a service credential that the CIR API Server can use to communicate with it. By selecting your running Cloudant instance, you can choose "Service credentials" from the left-hand menu.&lt;/li&gt;
&lt;li&gt;Click on "New Credentials" and give it a name and select the role of a "Manager" and click "Create".
-Once created, you can display the credentials by selecting view service credentials, and then copy the credentials.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnn0axs0aajsd3dgy424b.png" alt="Create credentials for Cloudant"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Step 3: Running the project
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Now open the project you cloned in the IDE of your liking and browse into the "example" directory and open the file "server.py"&lt;/li&gt;
&lt;li&gt;Paste the credentials you copied in the "API access" section.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgvx52khb96d1qqd8vovo.png" alt="Paste the credentials in the application"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You are now ready to run your application. You can either run your application locally or on docker. If you want to run using Docker, make sure you have Docker installed and running on your machine. &lt;/p&gt;

&lt;p&gt;Install Docker &lt;a href="https://www.docker.com/products/docker-desktop" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 4: Run your application
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Run Locally&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once you’re in the directory where you cloned your project. Create a virtual environment (also known as vitualenv). It is preferred to run your project in a virtual environment as that creates an isolated environment around your Python/Flask project and allows you to run different projects on different versions without affecting the others.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;#this will install the necessary files to create a virtualenv&lt;br&gt;
pip install virtualenv&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;#name your virtual environment, I am calling it venv&lt;br&gt;
virtualenv venv&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;&lt;code&gt;#activate your virtualenv&lt;br&gt;
source venv/bin/activate&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;#Once your work on this project is over, deactivate your virtualenv&lt;br&gt;
deactivate&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Once you activate the virtual environment, run the following commands,&lt;br&gt;
&lt;code&gt;#if you don't have python run these commands&lt;br&gt;
brew install python&lt;br&gt;
pip install --user pipenv&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Run this command, to have it create a "pipfile.lock" with all the dependencies installed.&lt;br&gt;
pipenv install&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now that you have the dependencies, you can run the API server.&lt;br&gt;
&lt;code&gt;pipenv run python ./server.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now your server is up and running at &lt;br&gt;
&lt;code&gt;Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4nipica8w4r04pvxtaqq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4nipica8w4r04pvxtaqq.png" alt="Running locally"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Run your application on Docker&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you have docker setup on your machine, you can run the API Server image. Run the following commands&lt;br&gt;
&lt;code&gt;docker build . -t cir-api-server&lt;br&gt;
docker run -p 8080:8080 cir-api-server&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The flask server in the docker container should be up and running at &lt;br&gt;
&lt;code&gt;Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 5: You can now test your endpoints!
&lt;/h4&gt;

&lt;p&gt;If you run docker image then you can use this curl statement,&lt;br&gt;
&lt;code&gt;curl "http://0.0.0.0:8080/v1/product?barcode_id=0125551234508"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Alternatively, you can visit: &lt;code&gt;http://0.0.0.0:8080/&lt;/code&gt; and expand "Get product", click on execute and paste &lt;code&gt;0125551234508&lt;/code&gt; barcode of the product to get the information.&lt;/p&gt;

&lt;p&gt;If you are running locally then use this curl statement,&lt;br&gt;
&lt;code&gt;curl "http://0.0.0.0:5000/v1/product?barcode_id=0125551234508"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Alternatively, you can visit: &lt;code&gt;http://127.0.0.1:5000&lt;/code&gt; and expand "Get product", click on execute and paste &lt;code&gt;0125551234508&lt;/code&gt; barcode of the product to get the information.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdha67ri8d7azkmeb7dug.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdha67ri8d7azkmeb7dug.png" alt="Picture1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu7qi94iqhkv1m2rdkbrn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu7qi94iqhkv1m2rdkbrn.png" alt="Picture2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuz3vx2gtrdsipuq28nby.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuz3vx2gtrdsipuq28nby.png" alt="Picture3"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You Can check the Cloudant service on IBM Cloud that you created and the dummy data file should have been uploaded to the database.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzlm7qp1d2pnshq0zi7z6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzlm7qp1d2pnshq0zi7z6.png" alt="Picture4"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can watch the event recording &lt;a href="https://www.youtube.com/watch?v=tVZgLzW8cRk" rel="noopener noreferrer"&gt;here&lt;/a&gt;. Get an introduction to Data Science and its methodology and a hands-on on how to get started with IBM Cloud.&lt;/p&gt;

&lt;p&gt;Note: This code pattern is part of the Call for Code 2020 Starter kit, this is just an example code that you can use to play around with and then build your solutions either on top of this code or start from scratch and build a solution of your own. This code itself as is cannot be submitted for the Call for Code 2021 challenge.  &lt;/p&gt;

</description>
      <category>python</category>
      <category>database</category>
      <category>cloud</category>
      <category>iam</category>
    </item>
  </channel>
</rss>
