Skip to content

Commit

Permalink
Merge pull request #1607 from vespa-engine/kkraune/feed-GHA
Browse files Browse the repository at this point in the history
Simplify - same as for documentation
  • Loading branch information
kkraune authored Dec 17, 2024
2 parents 6e68be9 + e94cb83 commit 55e6735
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/feed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
25 changes: 21 additions & 4 deletions feed_to_vespa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 55e6735

Please sign in to comment.