Question: Here is the background information on your task We have signed a new account - Daikibo Industrials, a global leader in the manufacturing of heavy

Here is the background information on your task
We have signed a new account -Daikibo Industrials, a global leader in the manufacturing of heavy machinery, founded and headquartered in Tokyo, Japan. They needed assistance with a variety of problems and were impressed to find out Deloitte could help in all verticals.
Daikibo is in the process of integrating IIoT (Industrial Internet-of-Things)devices to monitor, measure and analyze their manufacturing processes. Half of their infrastructure uses devices streaming telemetry data in one format, and the other half -in another. They need your help to combine the two.
Here is your task
Take the following steps to complete the task:
Create an account at repl.it.
Fork this project into your workspace.
After navigating to the project -find the Fork button on the page and press it.
Get acquainted with the 2data formats by exploring the files (hint: it's the same message, represented in 2different formats):
data-1.jsondata-2.json
Explore the target unified format by looking at the file data-result.json. This is the format you should aim to output in your solution.
Complete the solution located in the file main.py.
The project is setup in a way to test your solution automatically as you run it.
Find the 2functions in need of implementation and finish them (look for comment lines starting with "IMPLEMENT:").
Use repl.it to run your project and test your solution (look for a big Run button, currently located at the top).
Don't mind the red color of the console output and the message on failed repl process when you run the project -the important thing is to see no failures in the tests.
Successful tests produce output looking similar to this
Please use comments in main.py,if you need to leave notes on your solution.
Hint: notice the timestamps of the 2telemetry formats are different, but the target format is exactly like one of them (milliseconds).You will need to convert the other format (ISO)to it.Check the resources for a link to a SO post that can help.
In the next step you will submit your solution.
import json, unittest, datetime
with open("./data-1.json","r")as f:
jsonData1=json.load(f)
with open("./data-2.json","r")as f:
jsonData2=json.load(f)
with open("./data-result.json","r")as f:
jsonExpectedResult =json.load(f)
def convertFromFormat1(jsonObject):
# IMPLEMENT: Conversion From Type 1
return NotImplemented
def convertFromFormat2(jsonObject):
# IMPLEMENT: Conversion From Type 1
return NotImplemented
def main (jsonObject):
result ={}
if (jsonObject.get('device')==None):
result =convertFromFormat1(jsonObject)
else:
result =convertFromFormat2(jsonObject)
return result
class TestSolution(unittest.TestCase):
def test_sanity(self):
result =json.loads(json.dumps(jsonExpectedResult))
self.assertEqual(
result,
jsonExpectedResult
)
def test_dataType1(self):
result =main (jsonData1)
self.assertEqual(
result,
jsonExpectedResult,
'Converting from Type 1failed'
)
def test_dataType2(self):
result =main (jsonData2)
self.assertEqual(
result,
jsonExpectedResult,
'Converting from Type 2failed'
)
if __name__=='__main__':
unittest.main()
data-1.json file content below
{
"deviceID": "dh28dslkja",
"deviceType": "LaserCutter",
"timestamp": 1624445837783,
"location": "japan/tokyo/keiy-industrial-zone/daikibo-factory-meiyo/section-1",
"operationStatus": "healthy",
"temp": 22
}
data-2.json file content below
{
"device": {
"id": "dh28dslkja",
"type": "LaserCutter"
},
"timestamp": "2021-06-23T10:57:17.783Z",
"country": "japan",
"city": "tokyo",
"area": "keiy-industrial-zone",
"factory": "daikibo-factory-meiyo",
"section": "section-1",
"data": {
"status": "healthy",
"temperature": 22
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!