Challenge Overview

Challenge Objectives

 

  • Python Rest API development using Flask framework - refactor existing codebase

NOTE: The review/appeals timeline is shorter than usual - pay attention to the deadlines

Project Background

  • Our client has developed a specific method of calculating specific oil properties

  • All the calculations are currently in an Excel workbook - our goal is to create an API to process the data, i.e. move the calculations from Excel into the codebase.

  • In this challenge, we’ll refactor the api endpoints and remove all database related features

 

Technology Stack

 

  • Python 3

  • Flask

  • Flask-Restplus

 

Code access

 

The base code is available in the forums. 

 

Individual requirements

 

  • 1. Remove all database related features
    Goal here is to make the calculations backend stateles, ie remove all the db related features - importing data, updates, searching, etc. Remove all the db models and all api endpoints except for one POST /calculation endpoint (that is the current POST /data endpoint) that takes the input parameters, calculates and returns both the inputs and outputs (keep same request response format). Update RestPlus models and test suite.

  • 2. Add logging
    Configure app logger to print all the logging output to stdout. Log level should be configurable via environment variable <API_NAME>_LOG_LEVEL. All requests (method, url, query params) and responses (response code) should be logged with INFO level. Use WARN and ERROR levels to log unusual scenarios (ex empty array that doesn’t break the rest of the calculations) or error cases (division by zero, our of range, etc) respectively. Log the request and response body with DEBUG level and log all the calculations (ex steps, loops, etc) with TRACE level.
     

General requirements

 

  • Unit tests are required for all endpoints.

  • All endpoints should be annotated with Swagger annotations and swagger UI should be served by the API.

  • All endpoint routes should be prefixed with “API_NAME_”

  • All configuration parameters should be extracted to a common settings module. All environment variables have to be prefixed with “API_NAME_”

  • Please make sure your code is well-documented. Use the following style guides Google Python Style Guide, Python Style Guide, and Docstring Conventions. Code linter is required. Please make sure it is well-engineered but not over-engineered (YAGNI and KISS) solution. We're looking for well-structured and tested code. Well-structured code follows good design principles like the SOLID principles and well-tested code has comprehensive unit tests.

  • The code should be implemented using Python3 only.

  • Use matrix operations with numpy/pandas where possible


 

What To Submit

 

  • All source code

  • Deployment guide

  • Postman collection containing sample calls for all endpoints (success/failure)

  • Verification guide - how to set up the environment, start the API, and verification screenshots

  • The unit tests coverage report



Final Submission Guidelines

See above

ELIGIBLE EVENTS:

Topcoder Open 2019

Review style

Final Review

Community Review Board

Approval

User Sign-Off

ID: 30095841