Skip to content

Commit 0eee866

Browse files
author
Yevgeni Litvin
committed
Resurrecting test_reading_legacy_dataset test
It was removed by mistake. The test actually tests an ability to read a dataset created with previous version of petastorm.
1 parent fc61d3e commit 0eee866

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

petastorm/etl/safe_pickle.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
"pyspark",
2424
"decimal",
2525
"builtins",
26+
"copy_reg",
27+
"__builtin__",
2628
}
2729

2830

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright (c) 2017-2018 Uber Technologies, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
import os
15+
16+
import pytest
17+
18+
from petastorm import make_reader
19+
20+
21+
def dataset_urls():
22+
"""Returns a list of legacy datasets available for testing"""
23+
legacy_data_directory = os.path.join(os.path.dirname(__file__), 'data', 'legacy')
24+
versions = os.listdir(legacy_data_directory)
25+
urls = ['file://' + os.path.join(legacy_data_directory, v) for v in versions]
26+
return urls
27+
28+
29+
@pytest.mark.parametrize('legacy_dataset_url', dataset_urls())
30+
def test_reading_legacy_dataset(legacy_dataset_url):
31+
"""The test runs for a single legacy dataset. Opens the dataset using `make_reader` and reads all records from it"""
32+
with make_reader(legacy_dataset_url, workers_count=1) as reader:
33+
all_data = list(reader)
34+
35+
# Some basic check on the data
36+
assert len(all_data) == 100
37+
assert len(all_data[0]._fields) > 5
38+
assert all_data[0].matrix.shape == (32, 16, 3)

0 commit comments

Comments
 (0)