Exemplo n.º 1
0
 def test_record_logged_model(self):
     store = self.get_store()
     run_id = self.create_test_run().info.run_id
     m = Model(artifact_path="model/path",
               run_id=run_id,
               flavors={"tf": "flavor body"})
     store.record_logged_model(run_id, m)
     self._verify_logged(
         store,
         run_id=run_id,
         params=[],
         metrics=[],
         tags=[RunTag(MLFLOW_LOGGED_MODELS, json.dumps([m.to_dict()]))],
     )
     m2 = Model(artifact_path="some/other/path",
                run_id=run_id,
                flavors={"R": {
                    "property": "value"
                }})
     store.record_logged_model(run_id, m2)
     self._verify_logged(
         store,
         run_id,
         params=[],
         metrics=[],
         tags=[
             RunTag(MLFLOW_LOGGED_MODELS,
                    json.dumps([m.to_dict(), m2.to_dict()]))
         ],
     )
     m3 = Model(artifact_path="some/other/path2",
                run_id=run_id,
                flavors={"R2": {
                    "property": "value"
                }})
     store.record_logged_model(run_id, m3)
     self._verify_logged(
         store,
         run_id,
         params=[],
         metrics=[],
         tags=[
             RunTag(MLFLOW_LOGGED_MODELS,
                    json.dumps([m.to_dict(),
                                m2.to_dict(),
                                m3.to_dict()]))
         ],
     )
     with self.assertRaises(TypeError):
         store.record_logged_model(run_id, m.to_dict())
Exemplo n.º 2
0
def test_model_uuid():
    m = Model()
    assert m.model_uuid is not None
    assert _is_valid_uuid(m.model_uuid)

    m2 = Model()
    assert m.model_uuid != m2.model_uuid

    m_dict = m.to_dict()
    assert m_dict["model_uuid"] == m.model_uuid
    m3 = Model.from_dict(m_dict)
    assert m3.model_uuid == m.model_uuid

    m_dict.pop("model_uuid")
    m4 = Model.from_dict(m_dict)
    assert m4.model_uuid is None