From e94cb834567e54ef2ee29efb7e979f53fae502f7 Mon Sep 17 00:00:00 2001 From: Kristian Aune Date: Tue, 17 Dec 2024 12:12:26 +0100 Subject: [PATCH] Simplify - same as for documentation --- .github/workflows/feed.yml | 10 ++-------- feed_to_vespa.py | 25 +++++++++++++++++++++---- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/.github/workflows/feed.yml b/.github/workflows/feed.yml index 5b6713e82..593ac5443 100644 --- a/.github/workflows/feed.yml +++ b/.github/workflows/feed.yml @@ -36,14 +36,8 @@ jobs: run: | pip3 install PyYAML mmh3 requests html5lib beautifulsoup4 markdownify tiktoken - - name: Get Vespa CLI - update to later versions as needed - run: | - apt update && apt -y install curl - mkdir -p opt - VESPA_CLI_VERSION=$(curl -fsSL https://api.github.com/repos/vespa-engine/vespa/releases/latest | grep -Po '"tag_name": "v\K.*?(?=")') - curl -fsSL https://github.com/vespa-engine/vespa/releases/download/v${VESPA_CLI_VERSION}/vespa-cli_${VESPA_CLI_VERSION}_linux_amd64.tar.gz | \ - tar -zxf - -C opt - ln -fs ./opt/*/bin/vespa + - name: Install Vespa CLI + uses: vespa-engine/setup-vespa-cli-action@v1 - name: Feed site run: | diff --git a/feed_to_vespa.py b/feed_to_vespa.py index a5e4ec00d..9865c15a1 100755 --- a/feed_to_vespa.py +++ b/feed_to_vespa.py @@ -69,10 +69,27 @@ def vespa_remove(endpoint, doc_ids, namespace, doc_type): def vespa_feed(endpoint, feed, namespace, doc_type): - if doc_type == "paragraph" or doc_type == "term" or doc_type == "doc": - splits = re.split(r'/|\.', endpoint) - app_string = splits[3] + '.' + splits[2] - print(subprocess.run(['./vespa', 'feed', '-a', app_string, '-t', endpoint, feed], capture_output=True)) + if doc_type not in ["paragraph", "term", "doc"]: + raise ValueError(":error:Unknown vespa doc_type: {0}".format(doc_type)) + + splits = re.split(r'/|\.', endpoint) + app_string = splits[3] + '.' + splits[2] + print("Feeding to app: {0} , endpoint: {1}".format(app_string, endpoint)) + + process = subprocess.run(['vespa', 'feed', '-a', app_string, '-t', endpoint, feed], capture_output=True) + + # Print sderr if not empty + if process.stderr: + print("::group::VespaCLI-Error") + print("::error::Errors reported by VespaCLI:") + print(process.stderr.decode('utf-8')) + print("::endgroup::") + + if process.returncode != 0: + print("::error::Errors encountered while feeding Vespa application.") + sys.exit(process.returncode) + + return process.stdout.decode('utf-8') def get_docs(index):