示例#1
0
	def post(self,requests):
		try:
			filePath=requests.POST.get('filePath')
			idfordata=requests.POST.get('idforData')
			if not filePath:
				raise Exception("Invalid Request Parameter")
		except:
			return JsonResponse({'error':'Invalid Request Parameter'},status=400)
		print('filpath >>>>>>>>>>>>>>>> ',filePath)
		return Scoring.loadModelfile(filePath,idfordata)
示例#2
0
 def test_07_scoreCsvDataWithSKL(self):
     logging.info("Test Case : Score csv data with SKL model.")
     filePath = os.path.abspath('testUseCase/supportdata/irisSKL.pmml')
     result = Scoring.loadModelfile(filePath)
     modelName = 'irisSKL'
     filePath = os.path.abspath('testUseCase/supportdata/iris_test.csv')
     result = Scoring.predicttestdata(filePath, modelName)
     result = json.loads(result.__dict__['_container'][0])
     self.assertEqual('result' in result, True)
     self.assertEqual(result['result'].endswith('.csv'), True)
     logging.info("PASSED")
示例#3
0
 def test_09_scoreJsonDataWithNN(self):
     logging.info("Test Case : Score json data with NN model.")
     filePath = os.path.abspath('testUseCase/supportdata/irisNN.pmml')
     result = Scoring.loadModelfile(filePath)
     modelName = 'irisNN'
     filePath = os.path.abspath('testUseCase/supportdata/iris_test.json')
     result = Scoring.predicttestdata(filePath, modelName)
     result = json.loads(result.__dict__['_container'][0])
     self.assertEqual('result' in result, True)
     self.assertEqual(result['result'].endswith('.txt'), True)
     logging.info("PASSED")
示例#4
0
 def test_03_loadModelForError(self):
     logging.info("Test Case : Load a model into memory. (2)")
     filePath = os.path.abspath('testUseCase/supportdata/errorPmml.pmml')
     result = Scoring.loadModelfile(filePath)
     self.assertEqual(result.status_code, 500)
     self.assertEqual(
         json.loads(result.__dict__['_container'][0])['keytoModel'], None)
     self.assertEqual(
         json.loads(result.__dict__['_container'][0])['message'],
         'Model loading failed, please contact Admin')
     result = Scoring.getListOfModelinMemory()
     self.assertEqual(len(json.loads(result.__dict__['_container'][0])), 1)
     logging.info("PASSED")
示例#5
0
    def test_11_scoreSignleRecordWithSKL(self):
        logging.info("Test Case : Score single record with SKL model.")
        filePath = os.path.abspath('testUseCase/supportdata/irisSKL.pmml')
        result = Scoring.loadModelfile(filePath)

        modelName = 'irisSKL'
        data = json.loads(
            '{"sepal_length":4,"sepal_width":5,"petal_length":3,"petal_width":5}'
        )
        result = Scoring.predicttestdata(None, modelName, data)
        result = json.loads(result.__dict__['_container'][0])
        self.assertEqual('result' in result, True)
        self.assertEqual(result['result'].endswith('.txt'), True)
        logging.info("PASSED")
示例#6
0
 def test_02_loadModelForCorrectness(self):
     logging.info("Test Case : Load a model into memory. (1)")
     filePath = os.path.abspath(
         'testUseCase/supportdata/NewTrialModel.pmml')
     result = Scoring.loadModelfile(filePath)
     self.assertEqual(result.status_code, 200)
     self.assertEqual(
         json.loads(result.__dict__['_container'][0])['keytoModel'],
         'NewTrialModel')
     self.assertEqual(
         json.loads(result.__dict__['_container'][0])['message'],
         'Model loaded successfully')
     result = Scoring.getListOfModelinMemory()
     self.assertEqual(len(json.loads(result.__dict__['_container'][0])), 1)
     logging.info("PASSED")