Skip to content

Commit e333db0

Browse files
committed
Reducing test times
1 parent 432955f commit e333db0

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

ads/feature_store/common/spark_session_singleton.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import os
1212

1313
from ads.common.oci_client import OCIClientFactory
14+
from ads.feature_store.common.utils.utility import get_env_bool
1415

1516
try:
1617
from delta import configure_spark_with_delta_pip
@@ -33,7 +34,7 @@
3334

3435

3536
def developer_enabled():
36-
return os.getenv("DEVELOPER_MODE")
37+
return get_env_bool("DEVELOPER_MODE", False)
3738

3839

3940
class SingletonMeta(type):

ads/feature_store/common/utils/utility.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8; -*-
3-
3+
import os
44
# Copyright (c) 2023 Oracle and/or its affiliates.
55
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
66

@@ -60,6 +60,25 @@ def get_execution_engine_type(
6060
else ExecutionEngine.SPARK
6161
)
6262

63+
def get_env_bool(env_var: str, default: bool = False) -> bool:
64+
"""
65+
:param env_var: Environment variable name
66+
:param default: Default environment variable value
67+
:return: Value of the boolean env variable
68+
"""
69+
env_val = os.getenv(env_var)
70+
if env_val is None:
71+
env_val = default
72+
else:
73+
env_val = env_val.lower()
74+
if env_val == "true":
75+
env_val = True
76+
elif env_val == "false":
77+
env_val = False
78+
else:
79+
raise ValueError("For environment variable: {0} only string values T/true or F/false are allowed but: \
80+
{1} was provided.".format(env_var, env_val))
81+
return env_val
6382

6483
def get_metastore_id(feature_store_id: str):
6584
"""

tests/integration/feature_store/test_datatype_pandas_mixed.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@
55
import numpy as np
66
import pytest
77

8-
flights_df = pd.read_csv("https://objectstorage.us-ashburn-1.oraclecloud.com/p/hh2NOgFJbVSg4amcLM3G3hkTuHyBD-8aE_iCsuZKEvIav1Wlld-3zfCawG4ycQGN/n/ociodscdev/b/oci-feature-store/o/beta/data/flights/flights.csv")
9-
flights_df_mixed = pd.DataFrame(flights_df["CANCELLATION_REASON"])
108

119

1210
class TestDataTypePandasMixed(FeatureStoreTestCase):
11+
flights_df = pd.read_csv("https://objectstorage.us-ashburn-1.oraclecloud.com/p/hh2NOgFJbVSg4amcLM3G3hkTuHyBD-8aE_iCsuZKEvIav1Wlld-3zfCawG4ycQGN/n/ociodscdev/b/oci-feature-store/o/beta/data/flights/flights.csv")
12+
flights_df_mixed = pd.DataFrame(flights_df["CANCELLATION_REASON"])
1313

1414
input_feature_details_mixed = [
15-
FeatureDetail("CANCELLATION_REASON").with_feature_type(FeatureType.STRING).with_order_number(1)]
16-
15+
FeatureDetail("CANCELLATION_REASON").with_feature_type(FeatureType.STRING).with_order_number(1)]
1716
def define_feature_group_resource_with_pandas_mixed_infer_schema(
1817
self, entity_id, feature_store_id
1918
):
@@ -27,7 +26,7 @@ def define_feature_group_resource_with_pandas_mixed_infer_schema(
2726
.with_entity_id(entity_id)
2827
.with_feature_store_id(feature_store_id)
2928
.with_primary_keys([])
30-
.with_schema_details_from_dataframe(flights_df_mixed)
29+
.with_schema_details_from_dataframe(self.flights_df_mixed)
3130
.with_statistics_config(False)
3231
)
3332

@@ -76,7 +75,7 @@ def test_feature_group_pandas_mixed_with_schema(self):
7675
feature_group.create()
7776
assert feature_group.oci_feature_group.id
7877

79-
feature_group.materialise(flights_df_mixed)
78+
feature_group.materialise(self.flights_df_mixed)
8079
df = feature_group.select().read()
8180
assert df
8281

0 commit comments

Comments
 (0)