Challenge Overview
Challenge Objectives
-
Update unit definition formulas
Project Background
-
Our client has developed a unit converter tool that we want to port to Python and expose as an API
-
All the conversions and unit definitions are currently in an Excel workbook - our goal is to create an API to manage unit definitions, and unit conversions
-
In this challenge, we’ll update the unit definitions to match the ones in the Excel workbook
Technology Stack
Note: no coding is required - you only need to update the unit formulas
-
Python 3
-
Flask
-
Flask-Restplus
-
MongoDB
-
Pint - unit conversion library
Code access
The base code is available in the forums.
Individual requirements
Our unit converter has a data import script that imports the units from a json file. That file is created by reading the units conversion rules from an excel file. The issue here is that the formulas in the import file assume all units are converted by just multiplying the unit value with a number (ex unit2 = x * unit1), which is not always correct. The task here is to check and fix the formulas for all units. Unit conversion in the Excel file is done through a macro and it contains all the details for converting each of the units (for example see the ConvertDensity macro for a formula to convert density units - “ToMetricFactor = (141.5 / (131.5 + ToConvert)) * 1000”).
Second task is to add more units to the import data file. Add the following units:
-
Cubic Feet per Day in the FlowRate (Mass) group
-
"Pounds U.S. Gallon (ppg)", "Pounds per Cubic Inch (lbs / in^3)" in Density group
-
"Cubic Feet per Day (cuft / day)", "Cubic Meters per Second (m^3 / s)", "Gal (U.K. liquid) per Second (U.K. gal / sec)", "Gal (U.S. liquid) per Second (U.S. gal / sec)" in the FlowRate (Volumetric) group
What To Submit
-
All source code
-
Deployment guide
-
Verification guide - how to set up the environment, start the API, and verification screenshots