Example #1
0
    def test_as_of_dates_entity_index(self):
        data = {
            "entity_id": [1, 2],
            "feature_one": [0.5, 0.6],
            "feature_two": [0.5, 0.6],
        }
        with tempfile.TemporaryDirectory() as tmpdir:
            project_storage = ProjectStorage(tmpdir)
            matrix_store = CSVMatrixStore(project_storage, [], "test")
            matrix_store.matrix = pd.DataFrame.from_dict(data)
            matrix_store.metadata = {"end_time": "2016-01-01", "indices": ["entity_id"]}

            self.assertEqual(matrix_store.as_of_dates, ["2016-01-01"])
Example #2
0
    def test_as_of_dates_entity_index(self):
        data = {
            'entity_id': [1, 2],
            'feature_one': [0.5, 0.6],
            'feature_two': [0.5, 0.6],
        }
        with tempfile.TemporaryDirectory() as tmpdir:
            project_storage = ProjectStorage(tmpdir)
            matrix_store = CSVMatrixStore(project_storage, [], 'test')
            matrix_store.matrix = pd.DataFrame.from_dict(data)
            matrix_store.metadata = {
                'end_time': '2016-01-01',
                'indices': ['entity_id']
            }

            self.assertEqual(matrix_store.as_of_dates, ['2016-01-01'])
Example #3
0
    def test_s3_save(self):
        with mock_s3():

            client = boto3.client("s3")
            client.create_bucket(Bucket="fake-matrix-bucket", ACL="public-read-write")
            example = next(self.matrix_stores())
            project_storage = ProjectStorage("s3://fake-matrix-bucket")

            tosave = CSVMatrixStore(project_storage, [], "test")
            tosave.matrix = example.matrix
            tosave.metadata = example.metadata
            tosave.save()

            tocheck = CSVMatrixStore(project_storage, [], "test")
            assert tocheck.metadata == example.metadata
            assert tocheck.matrix.to_dict() == example.matrix.to_dict()
Example #4
0
    def test_s3_save(self):
        with mock_s3():
            import boto3
            client = boto3.client('s3')
            client.create_bucket(Bucket='fake-matrix-bucket',
                                 ACL='public-read-write')
            example = next(self.matrix_stores())
            project_storage = ProjectStorage('s3://fake-matrix-bucket')

            tosave = CSVMatrixStore(project_storage, [], 'test')
            tosave.matrix = example.matrix
            tosave.metadata = example.metadata
            tosave.save()

            tocheck = CSVMatrixStore(project_storage, [], 'test')
            assert tocheck.metadata == example.metadata
            assert tocheck.matrix.to_dict() == example.matrix.to_dict()