File size: 745 Bytes
8ce4d25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
from vespa.application import Vespa
from dotenv import load_dotenv


def get_vespa_app():
    load_dotenv()
    vespa_app_url = os.environ.get(
        "VESPA_APP_URL"
    )  # Ensure this is set to your Vespa app URL
    vespa_cloud_secret_token = os.environ.get("VESPA_CLOUD_SECRET_TOKEN")

    if not vespa_app_url or not vespa_cloud_secret_token:
        raise ValueError(
            "Please set the VESPA_APP_URL and VESPA_CLOUD_SECRET_TOKEN environment variables"
        )
    # Instantiate Vespa connection
    vespa_app = Vespa(
        url=vespa_app_url, vespa_cloud_secret_token=vespa_cloud_secret_token
    )
    vespa_app.wait_for_application_up()
    print(f"Connected to Vespa at {vespa_app_url}")
    return vespa_app