Skip to content

Commit 34996a2

Browse files
BenjaminKazemicopybara-github
authored andcommitted
feat: GenAI SDK client(multimodal) - Add get/update/list/delete to multimodal datasets.
PiperOrigin-RevId: 823619345
1 parent 6a6674d commit 34996a2

File tree

8 files changed

+1104
-44
lines changed

8 files changed

+1104
-44
lines changed

tests/unit/vertexai/genai/replays/test_create_multimodal_datasets.py

Lines changed: 63 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,32 @@ def test_create_dataset(client):
4141

4242

4343
def test_create_dataset_from_bigquery(client):
44-
dataset = client.datasets.create_multimodal_dataset_from_bigquery(
45-
multimodal_dataset=types.MultimodalDataset(
46-
display_name="test-from-bigquery",
47-
bigquery_uri=BIGQUERY_TABLE_NAME,
48-
)
44+
dataset = client.datasets.create_from_bigquery(
45+
multimodal_dataset={
46+
"display_name": "test-from-bigquery",
47+
"description": "test-description-from-bigquery",
48+
"metadata": {
49+
"inputConfig": {
50+
"bigquerySource": {"uri": f"bq://{BIGQUERY_TABLE_NAME}"},
51+
},
52+
},
53+
}
54+
)
55+
assert isinstance(dataset, types.MultimodalDataset)
56+
assert dataset.display_name == "test-from-bigquery"
57+
58+
59+
def test_create_dataset_from_bigquery_without_bq_prefix(client):
60+
dataset = client.datasets.create_from_bigquery(
61+
multimodal_dataset={
62+
"display_name": "test-from-bigquery",
63+
"description": "test-description-from-bigquery",
64+
"metadata": {
65+
"inputConfig": {
66+
"bigquerySource": {"uri": BIGQUERY_TABLE_NAME},
67+
},
68+
},
69+
},
4970
)
5071
assert isinstance(dataset, types.MultimodalDataset)
5172
assert dataset.display_name == "test-from-bigquery"
@@ -77,24 +98,51 @@ async def test_create_dataset_async(client):
7798

7899
@pytest.mark.asyncio
79100
async def test_create_dataset_from_bigquery_async(client):
80-
dataset = await client.aio.datasets.create_multimodal_dataset_from_bigquery(
81-
multimodal_dataset=types.MultimodalDataset(
82-
display_name="test-from-bigquery",
83-
bigquery_uri=BIGQUERY_TABLE_NAME,
84-
)
101+
dataset = await client.aio.datasets.create_from_bigquery(
102+
multimodal_dataset={
103+
"display_name": "test-from-bigquery",
104+
"description": "test-description-from-bigquery",
105+
"metadata": {
106+
"inputConfig": {
107+
"bigquerySource": {"uri": f"bq://{BIGQUERY_TABLE_NAME}"},
108+
},
109+
},
110+
}
85111
)
86112
assert isinstance(dataset, types.MultimodalDataset)
87113
assert dataset.display_name == "test-from-bigquery"
88114

89115

90116
@pytest.mark.asyncio
91117
async def test_create_dataset_from_bigquery_async_with_timeout(client):
92-
dataset = await client.aio.datasets.create_multimodal_dataset_from_bigquery(
118+
dataset = await client.aio.datasets.create_from_bigquery(
93119
config=types.CreateMultimodalDatasetConfig(timeout=120),
94-
multimodal_dataset=types.MultimodalDataset(
95-
display_name="test-from-bigquery",
96-
bigquery_uri=BIGQUERY_TABLE_NAME,
97-
),
120+
multimodal_dataset={
121+
"display_name": "test-from-bigquery",
122+
"description": "test-description-from-bigquery",
123+
"metadata": {
124+
"inputConfig": {
125+
"bigquerySource": {"uri": f"bq://{BIGQUERY_TABLE_NAME}"},
126+
},
127+
},
128+
},
129+
)
130+
assert isinstance(dataset, types.MultimodalDataset)
131+
assert dataset.display_name == "test-from-bigquery"
132+
133+
134+
@pytest.mark.asyncio
135+
async def test_create_dataset_from_bigquery_async_without_bq_prefix(client):
136+
dataset = await client.aio.datasets.create_from_bigquery(
137+
multimodal_dataset={
138+
"display_name": "test-from-bigquery",
139+
"description": "test-description-from-bigquery",
140+
"metadata": {
141+
"inputConfig": {
142+
"bigquerySource": {"uri": BIGQUERY_TABLE_NAME},
143+
},
144+
},
145+
},
98146
)
99147
assert isinstance(dataset, types.MultimodalDataset)
100148
assert dataset.display_name == "test-from-bigquery"
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Copyright 2025 Google LLC
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+
#
15+
# pylint: disable=protected-access,bad-continuation,missing-function-docstring
16+
17+
from tests.unit.vertexai.genai.replays import pytest_helper
18+
from vertexai._genai import types
19+
20+
import pytest
21+
22+
BIGQUERY_TABLE_NAME = "vertex-sdk-dev.multimodal_dataset.test-table"
23+
24+
25+
def test_delete_dataset(client):
26+
dataset = client.datasets.create_from_bigquery(
27+
multimodal_dataset={
28+
"display_name": "test-from-bigquery",
29+
"metadata": {
30+
"inputConfig": {
31+
"bigquerySource": {"uri": f"bq://{BIGQUERY_TABLE_NAME}"},
32+
},
33+
},
34+
}
35+
)
36+
name = dataset.name.split("/datasets/")[1]
37+
38+
operation = client.datasets._delete_multimodal_dataset(
39+
name=name,
40+
)
41+
assert isinstance(operation, types.MultimodalDatasetOperation)
42+
assert operation
43+
44+
45+
pytestmark = pytest_helper.setup(
46+
file=__file__,
47+
globals_for_file=globals(),
48+
)
49+
50+
pytest_plugins = ("pytest_asyncio",)
51+
52+
53+
@pytest.mark.asyncio
54+
async def test_delete_dataset_async(client):
55+
dataset = client.datasets.create_from_bigquery(
56+
multimodal_dataset={
57+
"display_name": "test-from-bigquery",
58+
"metadata": {
59+
"inputConfig": {
60+
"bigquerySource": {"uri": f"bq://{BIGQUERY_TABLE_NAME}"},
61+
},
62+
},
63+
}
64+
)
65+
name = dataset.name.split("/datasets/")[1]
66+
67+
operation = client.datasets._delete_multimodal_dataset(
68+
name=name,
69+
)
70+
assert isinstance(operation, types.MultimodalDatasetOperation)
71+
assert operation
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Copyright 2025 Google LLC
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+
#
15+
# pylint: disable=protected-access,bad-continuation,missing-function-docstring
16+
17+
from tests.unit.vertexai.genai.replays import pytest_helper
18+
from vertexai._genai import types
19+
20+
import pytest
21+
22+
BIGQUERY_TABLE_NAME = "vertex-sdk-dev.multimodal_dataset.test-table"
23+
DATASET = "8810841321427173376"
24+
25+
26+
def test_get_dataset(client):
27+
dataset = client.datasets._get_multimodal_dataset(
28+
name=DATASET,
29+
)
30+
assert isinstance(dataset, types.MultimodalDataset)
31+
assert dataset.name.endswith(DATASET)
32+
assert dataset.display_name == "test-from-bigquery"
33+
34+
35+
pytestmark = pytest_helper.setup(
36+
file=__file__,
37+
globals_for_file=globals(),
38+
)
39+
40+
pytest_plugins = ("pytest_asyncio",)
41+
42+
43+
@pytest.mark.asyncio
44+
async def test_get_dataset_async(client):
45+
dataset = await client.aio.datasets._get_multimodal_dataset(
46+
name=DATASET,
47+
)
48+
assert isinstance(dataset, types.MultimodalDataset)
49+
assert dataset.name.endswith(DATASET)
50+
assert dataset.display_name == "test-from-bigquery"
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2025 Google LLC
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+
#
15+
# pylint: disable=protected-access,bad-continuation,missing-function-docstring
16+
17+
from tests.unit.vertexai.genai.replays import pytest_helper
18+
from vertexai._genai import types
19+
20+
import pytest
21+
22+
BIGQUERY_TABLE_NAME = "vertex-sdk-dev.multimodal_dataset.test-table"
23+
24+
25+
def test_list_dataset(client):
26+
datasets = client.datasets._list_multimodal_datasets()
27+
assert isinstance(datasets, types.ListMultimodalDatasetsResponse)
28+
29+
30+
pytestmark = pytest_helper.setup(
31+
file=__file__,
32+
globals_for_file=globals(),
33+
)
34+
35+
pytest_plugins = ("pytest_asyncio",)
36+
37+
38+
@pytest.mark.asyncio
39+
async def test_list_dataset_async(client):
40+
datasets = await client.aio.datasets._list_multimodal_datasets()
41+
assert isinstance(datasets, types.ListMultimodalDatasetsResponse)
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Copyright 2025 Google LLC
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+
#
15+
# pylint: disable=protected-access,bad-continuation,missing-function-docstring
16+
17+
from tests.unit.vertexai.genai.replays import pytest_helper
18+
from vertexai._genai import types
19+
20+
import pytest
21+
22+
METADATA_SCHEMA_URI = (
23+
"gs://google-cloud-aiplatform/schema/dataset/metadata/multimodal_1.0.0.yaml"
24+
)
25+
BIGQUERY_TABLE_NAME = "vertex-sdk-dev.multimodal_dataset.test-table"
26+
DATASET = "8810841321427173376"
27+
28+
29+
def test_update_dataset(client):
30+
operation = client.datasets._update_multimodal_dataset(
31+
name=DATASET,
32+
display_name="test-display-name",
33+
description="test-description",
34+
metadata={
35+
"inputConfig": {
36+
"bigquerySource": {"uri": f"bq://{BIGQUERY_TABLE_NAME}"},
37+
},
38+
},
39+
)
40+
assert isinstance(operation, types.MultimodalDatasetOperation)
41+
42+
43+
pytestmark = pytest_helper.setup(
44+
file=__file__,
45+
globals_for_file=globals(),
46+
)
47+
48+
pytest_plugins = ("pytest_asyncio",)
49+
50+
51+
@pytest.mark.asyncio
52+
async def test_update_dataset_async(client):
53+
operation = await client.aio.datasets._update_multimodal_dataset(
54+
name=DATASET,
55+
display_name="test-display-name",
56+
metadata={
57+
"inputConfig": {
58+
"bigquerySource": {"uri": f"bq://{BIGQUERY_TABLE_NAME}"},
59+
},
60+
},
61+
)
62+
assert isinstance(operation, types.MultimodalDatasetOperation)
63+
assert operation

0 commit comments

Comments
 (0)