Skip to content

Commit 47c059d

Browse files
authored
samples(discoveryengine): Add Import Documents Samples for Google Cloud Sources (GoogleCloudPlatform#11958)
* samples(discoveryengine): Add Import Documents Samples for Google Cloud sources https://cloud.google.com/generative-ai-app-builder/docs/create-data-store-es
1 parent b97d17e commit 47c059d

File tree

3 files changed

+567
-46
lines changed

3 files changed

+567
-46
lines changed

discoveryengine/create_data_store_sample.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ def create_data_store_sample(
5454
industry_vertical=discoveryengine.IndustryVertical.GENERIC,
5555
# Options: SOLUTION_TYPE_RECOMMENDATION, SOLUTION_TYPE_SEARCH, SOLUTION_TYPE_CHAT, SOLUTION_TYPE_GENERATIVE_CHAT
5656
solution_types=[discoveryengine.SolutionType.SOLUTION_TYPE_SEARCH],
57+
# TODO(developer): Update content_config based on data store type.
5758
# Options: NO_CONTENT, CONTENT_REQUIRED, PUBLIC_WEBSITE
58-
content_config=discoveryengine.DataStore.ContentConfig.PUBLIC_WEBSITE,
59+
content_config=discoveryengine.DataStore.ContentConfig.CONTENT_REQUIRED,
5960
)
6061

6162
request = discoveryengine.CreateDataStoreRequest(

discoveryengine/documents_sample_test.py

Lines changed: 106 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,31 @@
1818
from discoveryengine import import_documents_sample
1919
from discoveryengine import list_documents_sample
2020

21+
import pytest
22+
2123
project_id = os.environ["GOOGLE_CLOUD_PROJECT"]
2224
location = "global"
2325
data_store_id = "test-structured-data-engine"
24-
gcs_uri = "gs://cloud-samples-data/gen-app-builder/search/empty.json"
2526

26-
# Empty Dataset
27-
bigquery_dataset = "genappbuilder_test"
28-
bigquery_table = "import_documents_test"
27+
28+
def test_import_documents_bigquery():
29+
# Empty Dataset
30+
bigquery_dataset = "genappbuilder_test"
31+
bigquery_table = "import_documents_test"
32+
operation_name = import_documents_sample.import_documents_bigquery_sample(
33+
project_id=project_id,
34+
location=location,
35+
data_store_id=data_store_id,
36+
bigquery_dataset=bigquery_dataset,
37+
bigquery_table=bigquery_table,
38+
)
39+
40+
assert "operations/import-documents" in operation_name
2941

3042

3143
def test_import_documents_gcs():
32-
operation_name = import_documents_sample.import_documents_sample(
44+
gcs_uri = "gs://cloud-samples-data/gen-app-builder/search/empty.json"
45+
operation_name = import_documents_sample.import_documents_gcs_sample(
3346
project_id=project_id,
3447
location=location,
3548
data_store_id=data_store_id,
@@ -39,13 +52,97 @@ def test_import_documents_gcs():
3952
assert "operations/import-documents" in operation_name
4053

4154

42-
def test_import_documents_bigquery():
43-
operation_name = import_documents_sample.import_documents_sample(
55+
@pytest.mark.skip(reason="Permissions")
56+
def test_import_documents_cloud_sql():
57+
sql_project_id = project_id
58+
sql_instance_id = "vertex-ai-search-tests"
59+
sql_database_id = "test-db"
60+
sql_table_id = "products"
61+
62+
operation_name = import_documents_sample.import_documents_cloud_sql_sample(
4463
project_id=project_id,
4564
location=location,
4665
data_store_id=data_store_id,
47-
bigquery_dataset=bigquery_dataset,
48-
bigquery_table=bigquery_table,
66+
sql_project_id=sql_project_id,
67+
sql_instance_id=sql_instance_id,
68+
sql_database_id=sql_database_id,
69+
sql_table_id=sql_table_id,
70+
)
71+
72+
assert "operations/import-documents" in operation_name
73+
74+
75+
def test_import_documents_spanner():
76+
spanner_project_id = project_id
77+
spanner_instance_id = "test-instance"
78+
spanner_database_id = "vais-test-db"
79+
spanner_table_id = "products"
80+
81+
operation_name = import_documents_sample.import_documents_spanner_sample(
82+
project_id=project_id,
83+
location=location,
84+
data_store_id=data_store_id,
85+
spanner_project_id=spanner_project_id,
86+
spanner_instance_id=spanner_instance_id,
87+
spanner_database_id=spanner_database_id,
88+
spanner_table_id=spanner_table_id,
89+
)
90+
91+
assert "operations/import-documents" in operation_name
92+
93+
94+
def test_import_documents_firestore():
95+
firestore_project_id = project_id
96+
firestore_database_id = "vais-tests"
97+
firestore_collection_id = "products"
98+
99+
operation_name = import_documents_sample.import_documents_firestore_sample(
100+
project_id=project_id,
101+
location=location,
102+
data_store_id=data_store_id,
103+
firestore_project_id=firestore_project_id,
104+
firestore_database_id=firestore_database_id,
105+
firestore_collection_id=firestore_collection_id,
106+
)
107+
108+
assert "operations/import-documents" in operation_name
109+
110+
111+
@pytest.mark.skip(reason="Timeout")
112+
def test_import_documents_bigtable():
113+
bigtable_project_id = project_id
114+
bigtable_instance_id = "bigtable-test"
115+
bigtable_table_id = "vais-test"
116+
117+
operation_name = import_documents_sample.import_documents_bigtable_sample(
118+
project_id=project_id,
119+
location=location,
120+
data_store_id=data_store_id,
121+
bigtable_project_id=bigtable_project_id,
122+
bigtable_instance_id=bigtable_instance_id,
123+
bigtable_table_id=bigtable_table_id,
124+
)
125+
126+
assert "operations/import-documents" in operation_name
127+
128+
129+
@pytest.mark.skip(reason="Permissions")
130+
def test_import_documents_healthcare_fhir_sample():
131+
location = "us"
132+
data_store_id = "healthcare-search-test"
133+
healthcare_project_id = project_id
134+
healthcare_location = "us-central1"
135+
healthcare_dataset_id = "vais_testing"
136+
healthcare_fihr_store_id = "vais_test_fihr_data"
137+
138+
operation_name = import_documents_sample.import_documents_healthcare_fhir_sample(
139+
project_id=project_id,
140+
location=location,
141+
data_store_id=data_store_id,
142+
healthcare_project_id=healthcare_project_id,
143+
healthcare_location=healthcare_location,
144+
healthcare_dataset_id=healthcare_dataset_id,
145+
healthcare_fihr_store_id=healthcare_fihr_store_id,
49146
)
50147

51148
assert "operations/import-documents" in operation_name

0 commit comments

Comments
 (0)