Ejemplo n.º 1
0
 def test_record_invoke_id(self, sagemaker, fake_utcnow, fake_uuid4):
     predictor = ModelPredictor(sagemaker.serve())
     assert predictor.record_invoke_id(
         {"a": "inputs"}, {"b": "outputs"}) == {
             "ts": "2019-01-31T12:00:02+00:00",
             "uuid": "20f803c4-f155-469e-ba96-14caa30af9e1",
         }
Ejemplo n.º 2
0
 def test_metadata(self, sagemaker, fake_utcnow):
     predictor = ModelPredictor(sagemaker.serve())
     assert predictor.metadata() == {
         "model_version": "test-model-1.2.3",
         "ml2p_version": str(ml2p_version),
         "timestamp": 1548936002.0,
     }
Ejemplo n.º 3
0
 def test_record_invoke(self, sagemaker, fake_utcnow, fake_uuid4):
     predictor = ModelPredictor(sagemaker.serve())
     datum = {"feature_a": 1, "feature_b": "b"}
     prediction = {
         "metadata": predictor.metadata(),
         "result": {
             "probability": 0.5,
             "input": 1
         },
     }
     predictor.record_invoke(datum, prediction)
     record = sagemaker.s3_get_object(
         "foo",
         "bar/predictions/test-model-1.2.3/"
         "ts-2019-01-31T12:00:02+00:00--"
         "uuid-20f803c4-f155-469e-ba96-14caa30af9e1.json",
     )
     assert record == {"input": datum, "result": prediction}
Ejemplo n.º 4
0
 def test_result(self, sagemaker):
     predictor = ModelPredictor(sagemaker.serve())
     with pytest.raises(NotImplementedError) as exc_info:
         predictor.result({})
     assert str(
         exc_info.value) == "Sub-classes should implement .result(...)"
Ejemplo n.º 5
0
 def test_invoke_batch_with_result_not_implemented(self, sagemaker):
     predictor = ModelPredictor(sagemaker.serve())
     with pytest.raises(NotImplementedError) as exc_info:
         predictor.batch_invoke([{}])
     assert str(
         exc_info.value) == "Sub-classes should implement .result(...)"
Ejemplo n.º 6
0
 def test_teardown(self, sagemaker):
     predictor = ModelPredictor(sagemaker.serve())
     predictor.teardown()
Ejemplo n.º 7
0
 def test_setup(self, sagemaker):
     predictor = ModelPredictor(sagemaker.serve())
     predictor.setup()
Ejemplo n.º 8
0
 def test_create(self, sagemaker):
     env = sagemaker.serve()
     predictor = ModelPredictor(env)
     assert predictor.env is env