Skip to content

Commit 9e99e90

Browse files
committed
Removed s comments by using conftest file
Signed-off-by: David Y Liu <davidyliuliu@gmail.com>
1 parent 25dae14 commit 9e99e90

4 files changed

Lines changed: 47 additions & 53 deletions

File tree

sdk/python/tests/conftest.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
import multiprocessing
15+
from datetime import datetime, timedelta
1516
from sys import platform
1617

18+
import pandas as pd
1719
import pytest
1820

1921

@@ -45,3 +47,43 @@ def pytest_collection_modifyitems(config, items):
4547
for item in items:
4648
if "integration" in item.keywords:
4749
item.add_marker(skip_integration)
50+
51+
52+
@pytest.fixture
53+
def simple_dataset_1() -> pd.DataFrame:
54+
now = datetime.utcnow()
55+
ts = pd.Timestamp(now).round("ms")
56+
data = {
57+
"id": [1, 2, 1, 3, 3],
58+
"float_col": [0.1, 0.2, 0.3, 4, 5],
59+
"int64_col": [1, 2, 3, 4, 5],
60+
"string_col": ["a", "b", "c", "d", "e"],
61+
"ts_1": [
62+
ts,
63+
ts - timedelta(hours=4),
64+
ts - timedelta(hours=3),
65+
ts - timedelta(hours=2),
66+
ts - timedelta(hours=1),
67+
],
68+
}
69+
return pd.DataFrame.from_dict(data)
70+
71+
72+
@pytest.fixture
73+
def simple_dataset_2() -> pd.DataFrame:
74+
now = datetime.utcnow()
75+
ts = pd.Timestamp(now).round("ms")
76+
data = {
77+
"id": ["a", "b", "c", "d", "e"],
78+
"float_col": [0.1, 0.2, 0.3, 4, 5],
79+
"int64_col": [1, 2, 3, 4, 5],
80+
"string_col": ["a", "b", "c", "d", "e"],
81+
"ts_1": [
82+
ts,
83+
ts - timedelta(hours=4),
84+
ts - timedelta(hours=3),
85+
ts - timedelta(hours=2),
86+
ts - timedelta(hours=1),
87+
],
88+
}
89+
return pd.DataFrame.from_dict(data)

sdk/python/tests/test_feature_store.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@
1616
from tempfile import mkstemp
1717

1818
import pytest
19-
from fixtures.data_source_fixtures import simple_dataset_1 # noqa: F401
20-
from fixtures.data_source_fixtures import (
19+
from pytest_lazyfixture import lazy_fixture
20+
from utils.data_source_utils import (
2121
prep_file_source,
2222
simple_bq_source_using_query_arg,
2323
simple_bq_source_using_table_ref_arg,
2424
)
25-
from pytest_lazyfixture import lazy_fixture
2625

2726
from feast.data_format import ParquetFormat
2827
from feast.data_source import FileSource

sdk/python/tests/test_inference.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import pytest
2-
from fixtures.data_source_fixtures import simple_dataset_1 # noqa: F401
3-
from fixtures.data_source_fixtures import simple_dataset_2 # noqa: F401
4-
from fixtures.data_source_fixtures import (
2+
from utils.data_source_utils import (
53
prep_file_source,
64
simple_bq_source_using_query_arg,
75
simple_bq_source_using_table_ref_arg,
@@ -13,7 +11,7 @@
1311

1412

1513
@pytest.mark.integration
16-
def test_data_source_ts_col_inference_success(simple_dataset_1): # noqa: F811
14+
def test_data_source_ts_col_inference_success(simple_dataset_1):
1715
with prep_file_source(df=simple_dataset_1) as file_source:
1816
actual_file_source = file_source.event_timestamp_column
1917
actual_bq_1 = simple_bq_source_using_table_ref_arg(
@@ -27,9 +25,7 @@ def test_data_source_ts_col_inference_success(simple_dataset_1): # noqa: F811
2725
assert expected == actual_file_source == actual_bq_1 == actual_bq_2
2826

2927

30-
def test_infer_entity_value_type_from_feature_views(
31-
simple_dataset_1, simple_dataset_2 # noqa: F811
32-
):
28+
def test_infer_entity_value_type_from_feature_views(simple_dataset_1, simple_dataset_2):
3329
with prep_file_source(
3430
df=simple_dataset_1, event_timestamp_column="ts_1"
3531
) as file_source, prep_file_source(

sdk/python/tests/fixtures/data_source_fixtures.py renamed to sdk/python/tests/utils/data_source_utils.py

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,12 @@
11
import contextlib
22
import tempfile
3-
from datetime import datetime, timedelta
43

5-
import pandas as pd
6-
import pytest
74
from google.cloud import bigquery
85

96
from feast.data_format import ParquetFormat
107
from feast.data_source import BigQuerySource, FileSource
118

129

13-
@pytest.fixture
14-
def simple_dataset_1() -> pd.DataFrame:
15-
now = datetime.utcnow()
16-
ts = pd.Timestamp(now).round("ms")
17-
data = {
18-
"id": [1, 2, 1, 3, 3],
19-
"float_col": [0.1, 0.2, 0.3, 4, 5],
20-
"int64_col": [1, 2, 3, 4, 5],
21-
"string_col": ["a", "b", "c", "d", "e"],
22-
"ts_1": [
23-
ts,
24-
ts - timedelta(hours=4),
25-
ts - timedelta(hours=3),
26-
ts - timedelta(hours=2),
27-
ts - timedelta(hours=1),
28-
],
29-
}
30-
return pd.DataFrame.from_dict(data)
31-
32-
33-
@pytest.fixture
34-
def simple_dataset_2() -> pd.DataFrame:
35-
now = datetime.utcnow()
36-
ts = pd.Timestamp(now).round("ms")
37-
data = {
38-
"id": ["a", "b", "c", "d", "e"],
39-
"float_col": [0.1, 0.2, 0.3, 4, 5],
40-
"int64_col": [1, 2, 3, 4, 5],
41-
"string_col": ["a", "b", "c", "d", "e"],
42-
"ts_1": [
43-
ts,
44-
ts - timedelta(hours=4),
45-
ts - timedelta(hours=3),
46-
ts - timedelta(hours=2),
47-
ts - timedelta(hours=1),
48-
],
49-
}
50-
return pd.DataFrame.from_dict(data)
51-
52-
5310
@contextlib.contextmanager
5411
def prep_file_source(df, event_timestamp_column="") -> FileSource:
5512
with tempfile.NamedTemporaryFile(suffix=".parquet") as f:

0 commit comments

Comments
 (0)