Example #1
0
 def test_table(self):
     attr = data_types.Table(
         data=[[1, "two", 3], [4, "five", 6]],
         columns=["header1", "header2", "header3"],
     )
     assert attr._as_dict() == {
         "type": "verta.table.v1",
         "table": {
             "header": ["header1", "header2", "header3"],
             "rows": [[1, "two", 3], [4, "five", 6]],
         },
     }
Example #2
0
 def test_table_numpy(self):
     np = pytest.importorskip("numpy")
     attr = data_types.Table(
         data=np.arange(1, 7).reshape((2, 3)),
         columns=["header1", "header2", "header3"],
     )
     assert attr._as_dict() == {
         "type": "verta.table.v1",
         "table": {
             "header": ["header1", "header2", "header3"],
             "rows": [[1, 2, 3], [4, 5, 6]],
         },
     }
Example #3
0
    def test_batch(self, experiment_run, strs):
        key1, key2 = strs[:2]
        attr1 = data_types.Table(
            data=[[1, "two", 3], [4, "five", 6]],
            columns=["header1", "header2", "header3"],
        )
        attr2 = data_types.ConfusionMatrix(
            value=[[1, 2, 3], [4, 5, 6], [7, 8, 9]],
            labels=["a", "b", "c"],
        )

        experiment_run.log_attribute(key1, attr1)
        assert experiment_run.get_attribute(key1) == attr1._as_dict()
        experiment_run.log_attribute(key2, attr2)
        assert experiment_run.get_attribute(key2) == attr2._as_dict()
Example #4
0
    def test_batch(self, model_version, strs):
        key1, key2, key3 = strs[:3]
        attr1 = data_types.Table(
            data=[[1, "two", 3], [4, "five", 6]],
            columns=["header1", "header2", "header3"],
        )
        attr2 = data_types.ConfusionMatrix(
            value=[[1, 2, 3], [4, 5, 6], [7, 8, 9]],
            labels=["a", "b", "c"],
        )
        attr3 = {"a": 1}

        model_version.add_attribute(key1, attr1)
        assert model_version.get_attribute(key1) == attr1
        model_version.add_attribute(key2, attr2)
        assert model_version.get_attribute(key2) == attr2
        model_version.add_attribute(key3, attr3)

        assert model_version.get_attributes() == {
            key1: attr1,
            key2: attr2,
            key3: attr3,
        }