in assets/scripts/setup.py [0:0]
def populate_data_store(industry: str):
client_options = (
ClientOptions(api_endpoint=f"{DATA_STORE_LOCATION}-discoveryengine.googleapis.com")
if DATA_STORE_LOCATION != "global"
else None
)
# Create a client
client = discoveryengine.DocumentServiceClient(client_options=client_options)
parent = client.branch_path(
project=PROJECT_ID,
location=DATA_STORE_LOCATION,
data_store=DATA_STORE_ID,
branch="default_branch",
)
request = discoveryengine.ImportDocumentsRequest(
parent=parent,
gcs_source=discoveryengine.GcsSource(
input_uris=[DATASTORE_INDUSTRY_SOURCES_MAP[industry]],
data_schema="content",
),
reconciliation_mode=discoveryengine.ImportDocumentsRequest.ReconciliationMode.INCREMENTAL,
)
operation = client.import_documents(request=request)
print(f"Import operation will keep on running on the background: {operation.operation.name}")