|
20 | 20 | from ads.feature_store.feature_store import FeatureStore |
21 | 21 | from ads.feature_store.input_feature_detail import FeatureDetail, FeatureType |
22 | 22 | from ads.feature_store.service.oci_feature_group import OCIFeatureGroup |
| 23 | +from ads.feature_store.service.oci_feature_group_job import OCIFeatureGroupJob |
23 | 24 | from ads.feature_store.service.oci_feature_store import OCIFeatureStore |
24 | 25 | from tests.unitary.with_extras.feature_store.test_feature_group_job import ( |
25 | 26 | FEATURE_GROUP_JOB_PAYLOAD, |
|
44 | 45 | "isInferSchema": False, |
45 | 46 | } |
46 | 47 |
|
| 48 | +FEATURE_GROUP_JOB_RESPONSE_PAYLOAD = { |
| 49 | + "compartmentId": "ocid1.compartment.oc1.iad.xxx", |
| 50 | + "featureGroupId": "861AA4E9C8E811A79D74C464A01CDF42", |
| 51 | + "id": "d40265b7-d66e-49a3-ae26-699012e0df5d", |
| 52 | + "ingestionMode": "OVERWRITE", |
| 53 | + "lifecycleState": "SUCCEEDED", |
| 54 | +} |
| 55 | + |
47 | 56 |
|
48 | 57 | @pytest.fixture(autouse=True) |
49 | 58 | def dataframe_fixture_basic(): |
@@ -211,14 +220,14 @@ def test_from_id(self, mock_oci_from_id, mock__update_from_oci_fs_model): |
211 | 220 |
|
212 | 221 | @patch.object(OCIFeatureGroup, "create") |
213 | 222 | def test_create_success( |
214 | | - self, |
215 | | - mock_oci_dsc_model_create, |
| 223 | + self, |
| 224 | + mock_oci_dsc_model_create, |
216 | 225 | ): |
217 | 226 | """Tests creating datascience feature_group.""" |
218 | 227 | oci_dsc_model = OCIFeatureGroup(**FEATURE_GROUP_PAYLOAD) |
219 | 228 | mock_oci_dsc_model_create.return_value = oci_dsc_model |
220 | 229 |
|
221 | | - # to check rundom display name |
| 230 | + # to check random display name |
222 | 231 | self.mock_dsc_feature_group.with_name("") |
223 | 232 | result = self.mock_dsc_feature_group.create() |
224 | 233 | mock_oci_dsc_model_create.assert_called() |
@@ -281,7 +290,7 @@ def test__to_oci_fs_entity(self, mock_load_key_file, mock_config_from_file): |
281 | 290 | @patch.object(SparkSessionSingleton, "__init__", return_value=None) |
282 | 291 | @patch.object(SparkSessionSingleton, "get_spark_session") |
283 | 292 | def test_materialise( |
284 | | - self, spark_session, get_spark_session, mocke_update, dataframe_fixture_basic |
| 293 | + self, spark_session, get_spark_session, mocke_update, dataframe_fixture_basic |
285 | 294 | ): |
286 | 295 | with patch.object(FeatureGroupJob, "create") as mock_feature_group_job: |
287 | 296 | with patch.object(FeatureStore, "from_id"): |
@@ -324,10 +333,20 @@ def test_history(self, feature_store, spark_session, get_spark_session): |
324 | 333 | @patch.object(SparkSessionSingleton, "get_spark_session") |
325 | 334 | @patch.object(OCIFeatureStore, "from_id") |
326 | 335 | def test_restore( |
327 | | - self, feature_store, spark_session, get_spark_session, mock_update |
| 336 | + self, feature_store, spark_session, get_spark_session, mock_update |
328 | 337 | ): |
329 | 338 | with patch.object(SparkEngine, "sql") as mock_execution_strategy: |
330 | 339 | mock_execution_strategy.return_value = None |
331 | 340 | self.mock_dsc_feature_group.with_id(FEATURE_GROUP_OCID) |
332 | 341 | self.mock_dsc_feature_group.restore(1) |
333 | 342 | mock_execution_strategy.assert_called_once() |
| 343 | + |
| 344 | + def test_get_last_job(self): |
| 345 | + """Tests getting most recent feature group job for a feature group.""" |
| 346 | + with patch.object(FeatureGroupJob, "list") as mock_feature_group_job: |
| 347 | + self.mock_dsc_feature_group.with_id(FEATURE_GROUP_OCID) |
| 348 | + mock_feature_group_job.return_value = [ |
| 349 | + FeatureGroupJob.from_dict({"spec": FEATURE_GROUP_JOB_RESPONSE_PAYLOAD}) |
| 350 | + ] |
| 351 | + fg_job = self.mock_dsc_feature_group.get_last_job() |
| 352 | + assert fg_job is not None |
0 commit comments