Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/pla 162 make vespa search adapter code in the sdk not require certs #103

2 changes: 1 addition & 1 deletion src/cpr_sdk/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
_MAJOR = "1"
_MINOR = "4"
_PATCH = "3"
_PATCH = "4"
_SUFFIX = ""

VERSION_SHORT = "{0}.{1}".format(_MAJOR, _MINOR)
Expand Down
17 changes: 13 additions & 4 deletions src/cpr_sdk/vespa.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from pathlib import Path
from typing import Any, List, Optional

Expand All @@ -12,6 +13,7 @@
from cpr_sdk.yql_builder import YQLBuilder

SENSITIVE_QUERY_TERMS = load_sensitive_query_terms()
_LOGGER = logging.getLogger(__name__)


def split_document_id(document_id: str) -> tuple[str, str, str]:
Expand Down Expand Up @@ -46,15 +48,22 @@ def find_vespa_cert_paths() -> tuple[Optional[str], Optional[str]]:
"""
vespa_directory = Path.home() / ".vespa/"
if not vespa_directory.exists():
raise FileNotFoundError(
"Could not find .vespa directory in home directory. "
"Please specify a cert_directory."
_LOGGER.warning(
"Could not find .vespa directory in home directory when looking for certs."
)
return None, None

vespa_config = vespa_directory / "config.yaml"
if not vespa_config.exists():
_LOGGER.warning(
"Could not find config.yaml file in .vespa directory when looking for certs."
)
return None, None

# read the config.yaml file to find the application name
with open(vespa_directory / "config.yaml", "r", encoding="utf-8") as yaml_file:
data = yaml.safe_load(yaml_file)
if "application" not in data:
if not data or "application" not in data:
return None, None
application_name = data["application"]

Expand Down
Loading