diff --git a/.github/workflows/run-examples-with-release.yaml b/.github/workflows/run-examples-with-release.yaml new file mode 100644 index 0000000..55b8c10 --- /dev/null +++ b/.github/workflows/run-examples-with-release.yaml @@ -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 diff --git a/.github/workflows/run-examples.yaml b/.github/workflows/run-examples.yaml new file mode 100644 index 0000000..ad9e9cf --- /dev/null +++ b/.github/workflows/run-examples.yaml @@ -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 diff --git a/examples/filters.py b/examples/filters.py index 2d29519..9272955 100644 --- a/examples/filters.py +++ b/examples/filters.py @@ -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: diff --git a/examples/processors.py b/examples/processors.py index 5a7eb3f..c0ca0d7 100644 --- a/examples/processors.py +++ b/examples/processors.py @@ -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)