Skip to content

COH-32107 - Create a GitHub workflow action for running Python examples #245

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

Merged
merged 15 commits into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/run-examples-with-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright 2025, Oracle Corporation and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at
# https://oss.oracle.com/licenses/upl.

name: Run Examples with released client
on:
workflow_dispatch:
schedule:
- cron: "0 5 * * *"
jobs:
run-examples-with-latest-release:
strategy:
fail-fast: false
matrix:
python-version: ["3.9.x", "3.10.x", "3.11.x", "3.12.x", "3.13.x"]
os: [ubuntu-latest]
coherence-image:
- ghcr.io/oracle/coherence-ce
coherenceVersion:
- 25.03.1
runs-on: ${{ matrix.os }}
steps:
- name: Get Docker Images
shell: bash
run: |
docker pull ${{ matrix.coherence-image }}:${{ matrix.coherenceVersion }}

- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Coherence Python Client
shell: bash
run: |
python -m pip install --upgrade pip
pip install coherence-client
pip install sentence-transformers # required for vector_search example

- name: Start the Server using image
shell: bash
run: |
docker run -d -p 1408:1408 ${{ matrix.coherence-image }}:${{ matrix.coherenceVersion }}
sleep 20

- name: Run the example
shell: bash
run: |
cd examples
for file in *.py; do
echo "Run example ${file}"
COHERENCE_CLIENT_REQUEST_TIMEOUT=180.0 python3 $file
echo "==== Done running example ${file} ======"
done
65 changes: 65 additions & 0 deletions .github/workflows/run-examples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Copyright 2025, Oracle Corporation and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at
# https://oss.oracle.com/licenses/upl.

name: Run Examples
on:
workflow_dispatch:
push:
branches:
- '*'
pull_request:
branches: [ main ]
jobs:
run-examples:
strategy:
fail-fast: false
matrix:
python-version: ["3.9.x"]
poetry-version: ["1.8.4"]
os: [ubuntu-latest]
coherence-image:
- ghcr.io/oracle/coherence-ce
coherenceVersion:
- 25.03.1
runs-on: ${{ matrix.os }}
steps:
- name: Get Docker Images
shell: bash
run: |
docker pull ${{ matrix.coherence-image }}:${{ matrix.coherenceVersion }}

- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
shell: bash
run: |
pip install poetry==${{ matrix.poetry-version }}

- name: Install Dependencies
run: python -m poetry install

- name: Install Coherence Python Client
shell: bash
run: |
python -m pip install --upgrade pip
python -m poetry run pip install sentence-transformers # required for vector_search example

- name: Start the Server using image
shell: bash
run: |
docker run -d -p 1408:1408 ${{ matrix.coherence-image }}:${{ matrix.coherenceVersion }}
sleep 20

- name: Run the example
shell: bash
run: |
cd examples
for file in *.py; do
echo "Run example ${file}"
COHERENCE_CLIENT_REQUEST_TIMEOUT=180.0 python -m poetry run python3 $file
echo "==== Done running example ${file} ======"
done
6 changes: 3 additions & 3 deletions examples/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ async def do_run() -> None:
print("NamedMap size is :", await named_map.size())

print("Retrieve the Hobbits between the ages of 17 and 21 ...")
async for entry in named_map.entries(Filters.between("age", 17, 21)):
async for entry in await named_map.entries(Filters.between("age", 17, 21)):
print("Key :", entry.key, ", Value :", entry.value)

print("Retrieve the Hobbits between the ages of 17 and 30 and live in Hobbiton ...")
query_filter: Filter = Filters.between("age", 17, 30).And(Filters.equals("home", "Hobbiton"))
async for entry in named_map.entries(query_filter):
async for entry in await named_map.entries(query_filter):
print("Key :", entry.key, ", Value :", entry.value)

print("Retrieve the Hobbits between the ages of 17 and 25 who live in Hobbiton or Frogmorton")
query_filter = Filters.between("age", 17, 25).And(Filters.is_in("home", {"Hobbiton", "Frogmorton"}))
async for entry in named_map.entries(query_filter):
async for entry in await named_map.entries(query_filter):
print("Key :", entry.key, ", Value :", entry.value)

finally:
Expand Down
4 changes: 2 additions & 2 deletions examples/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ async def do_run() -> None:

print("Sending all Hobbits ten years into the future!")
keys: List[int] = []
async for entry in named_map.invoke_all(Processors.increment("age", 10)):
async for entry in await named_map.invoke_all(Processors.increment("age", 10)):
keys.append(entry.key)
print("Updated age of Hobbit with id ", entry.key, "to", entry.value)

print("Displaying all updated Hobbits ...")
async for result in named_map.get_all(set(keys)):
async for result in await named_map.get_all(set(keys)):
print(result.value)

await named_map.remove(hobbit.id)
Expand Down