Design and build a wrapper for the Open Weather API current weather data service

Overview

Full Stack Code Assessment Challenge

python3.7 redis AWS Docker Swagger

Design and build a wrapper for the Open Weather API current weather data service that returns a city's temperature, with caching, also allowing for the temperature of the latest queried cities that are still validly cached to be retrieved.

PROJECT STRUCTURE

The project structure is based on the official Flask RESTPlus scaling your project

.
├── main
│   ├── helpers
│   │   └── redis.py
│   ├── __init__.py
│   └── resources
│       ├── __init__.py
│       └── openweather
│           ├── __init__.py
│           ├── routes.py
│           ├── test_request_by_citY_name.py
│           └── test_request_temperature.py
├── tests
│   ├── base.py
│   ├── test_config.py
│   ├── serializers.py
│   └── services.py
├── .dockerignore
├── .gitignore
├── app.py   
├── config.py
├── docker-compose.yml
├── Dockerfile
├── README.md
└── requirements.txt
Folders
  • main - All the RESTful API implementation is here.
  • main/helpers - Useful function for working with redis cache.
  • tests - All the tests used on API.
Files
  • main/__init__.py - Resource agroupment for all Namespaces.
  • main/resources/__init__.py - The Flask Application factory (create_app()).
  • config.py - Config file for envs, global config vars and so on.
  • Dockerfile - Dockerfile used to build a Docker image.
  • .dockerignore - Lists files and directories which should be ignored while Docker build process.
  • .gitignore - Lists files and directories which should not be added to git repository.
  • requirements.txt - All project dependencies.
  • app.py - The application entrypoint.

RUNNING ON CLOUD

You can check this application live running on AWS cloud using Lambda functions: My Cloud App

RUNNING ON DOCKER

Requirements

Make sure you have already installed both Docker Engine and Docker Compose. You don’t need to install Python or Redis, as both are provided by Docker images.

Clone the repository
$ git clone https://github.com/duanribeiro/DevGrid_exercise.git
$ cd DevGrid_exercise
Add Environment Variables

A file called docker-compose.yml contains all environment variables. Variables declared in file have the following format: ENVIRONMENT_VARIABLE=value.

In order for Flask to run, there must be set OPENWEATHER_ENDPOINT, OPENWEATHER_APIKEY, CACHE_TTL_SECONDS, DEFAULT_MAX_NUMBER variables declared.

Variable Default Discussion
OPENWEATHER_ENDPOINT https://api.openweathermap.org/data/2.5/weather Endpoint used to fetch data from Open Weather API.
OPENWEATHER_APIKEY your_secret_api_password The API key is a unique identifier that authenticates requests associated with your project for usage and billing purposes.
CACHE_TTL_SECONDS 300 Time to live (TTL) is an integer value that specifies the number of seconds until the cached key expires.
DEFAULT_MAX_NUMBER 5 Default value from max number of queried cities that are still valid.
REDIS_ENDPOINT redis localhost Redis host address.
REDIS_PORT 6379 Redis host port.
Create and run the images:
$ docker-compose up

It will deploy 2 docker containers:

TESTING

Unittest supports simple test discovery. In order to be compatible with test discovery, all of the test files must be importable from the top-level directory of the project.

$ python -m unittest discover .\tests\
You might also like...
An API wrapper for the file.io web service.

🗃️ File.io An API wrapper for the file.io web service. Install $ pip3 install fileio or

An open source development framework to help you build data workflows and modern data architecture on AWS.
An open source development framework to help you build data workflows and modern data architecture on AWS.

AWS DataOps Development Kit (DDK) The AWS DataOps Development Kit is an open source development framework for customers that build data workflows and

The official wrapper for spyse.com API, written in Python, aimed to help developers build their integrations with Spyse.

Python wrapper for Spyse API The official wrapper for spyse.com API, written in Python, aimed to help developers build their integrations with Spyse.

Spotify Top Lists - get the current top lists of a user from the Spotify API and display them in a Flask app
Spotify Top Lists - get the current top lists of a user from the Spotify API and display them in a Flask app

Spotify Top Lists This is a simple script that will get the current top lists of a user from the Spotify API and display them in a Flask app. Requirem

Aws-lambda-requests-wrapper - Request/Response wrapper for AWS Lambda with API Gateway

AWS Lambda Requests Wrapper Request/Response wrapper for AWS Lambda with API Gat

TypeRig is a Python library aimed at simplifying the current FontLab API

TypeRig TypeRig is a Python library aimed at simplifying the current FontLab API while offering some additional functionality that is heavily biased t

 Wetterdienst - Open weather data for humans
Wetterdienst - Open weather data for humans

We are a group of like-minded people trying to make access to weather data in Python feel like a warm summer breeze, similar to other projects like rdwd for the R language, which originally drew our interest in this project.

Asynchronous wrapper for wttr.in weather forecast.

aiopywttr Asynchronous wrapper for wttr.in weather forecast. Synchronous version here. Installation pip install aiopywttr Example This example prints

Wrapper for wttr.in weather forecast.

pywttr Wrapper for wttr.in weather forecast. Asynchronous version here. Installation pip install pywttr Example This example prints the average temper

Owner
Duan Rafael Ribeiro
Economist and developer, i believe that technology is a essencial part in the development of companies and people.
Duan Rafael Ribeiro
Weather Tracker, made with Python using Open Weather API

Weather Tracker Weather Tracker, made with Python using Open Weather API

Sahil Kumar 1 Feb 7, 2022
Ubuntu env build; Nginx build; DB build;

Deploy 介绍 Deploy related scripts bitnami Dependencies Ubuntu openssl envsubst docker v18.06.3 docker-compose init base env upload https://gitlab-runn

Colin(liuji) 10 Dec 1, 2021
Texting service to receive current air quality conditions and maps, powered by AirNow, Twilio, and AWS

The Air Quality Bot is generally available by texting a zip code (and optionally the word "map") to (415) 212-4229. The bot will respond with the late

Alex Laird 8 Oct 16, 2022
A python script that changes our background based on current weather and time of the day.

Desktop background on Windows 10, based on current weather and time A python script that changes our background based on current weather and time of t

Maj Gaberšček 1 Nov 16, 2021
🚀 An asynchronous python API wrapper meant to replace discord.py - Snappy discord api wrapper written with aiohttp & websockets

Pincer An asynchronous python API wrapper meant to replace discord.py ❗ The package is currently within the planning phase ?? Links |Join the discord

Pincer 125 Dec 26, 2022
Mazda Connected Service API wrapper based on pymazda and Flask.

Mazda Connected Service Relay Mazda Connected Service API wrapper based on pymazda and Flask. Usage Make POST calls to https://mymazda.herokuapp.com/{

Alan Chen 10 Jan 5, 2023
A thin Python Wrapper for the Dark Sky (formerly forecast.io) weather API

Dark Sky Wrapper This is a wrapper for the Dark Sky (formerly forecast.io) API. It allows you to get the weather for any location, now, in the past, o

Ze'ev Gilovitz 414 Nov 16, 2022
Python wrapper library for World Weather Online API

pywwo Python wrapper library for World Weather Online API using lxml.objectify How to use from pywwo import * setKey('<your_key>', 'free') w=LocalWeat

World Weather Online 20 Dec 19, 2022
Insane Weather Bot is here! Give suggestions, fork, and do much more to help us enhance the abilities of Insane Weather Bot.

Insane_Weather_Bot Insane Weather Bot is here! Give suggestions, fork, and do much more to help us enhance the abilities of Insane Weather Bot. Weathe

null 1 Jan 2, 2022
:globe_with_meridians: A Python wrapper for the Geocodio geolocation service API

Py-Geocodio Python wrapper for Geocodio geocoding API. Full documentation on Read the Docs. If you are upgrading from a version prior to 0.2.0 please

Ben Lopatin 84 Aug 2, 2022