Skip to content

Commit 97a6e71

Browse files
Frances Hubis Thomacopybara-github
authored andcommitted
feat: Add has_template_config to MultimodalDataset.
PiperOrigin-RevId: 808720000
1 parent bf91a55 commit 97a6e71

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

google/cloud/aiplatform/preview/datasets.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,11 @@ def attach_template_config(
12881288
)
12891289
return self
12901290

1291+
def has_template_config(self) -> bool:
1292+
"""Returns true if the dataset has a template config attached."""
1293+
self._assert_gca_resource_is_available()
1294+
return _GEMINI_TEMPLATE_CONFIG_SOURCE_FIELD in self._gca_resource.metadata
1295+
12911296
@property
12921297
def template_config(self) -> Optional[GeminiTemplateConfig]:
12931298
"""Return a copy of the template config attached to this dataset."""

tests/unit/aiplatform/test_multimodal_datasets.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,18 @@ def test_attach_template_config_with_prompt(
749749
timeout=None,
750750
)
751751

752+
@pytest.mark.usefixtures("get_dataset_mock")
753+
def test_has_template_config(self, update_dataset_with_template_config_mock):
754+
aiplatform.init(project=_TEST_PROJECT)
755+
dataset = ummd.MultimodalDataset(dataset_name=_TEST_NAME)
756+
template_config = ummd.GeminiTemplateConfig(
757+
field_mapping={"question": "questionColumn"},
758+
)
759+
assert dataset.has_template_config() is False
760+
# Attach a template config to the dataset.
761+
dataset.attach_template_config(template_config=template_config)
762+
assert dataset.has_template_config() is True
763+
752764
@pytest.mark.usefixtures(
753765
"get_dataset_with_prompt_resource_mock", "prompts_get_mock"
754766
)

0 commit comments

Comments
 (0)