Skip to content

COH-31421 - Integrate Coherence AI changes to main and release a new version to Pypi #207

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 7 commits into from
Jan 30, 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
2 changes: 1 addition & 1 deletion .github/workflows/validate-nslookup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
poetry-version: ["1.8.4"]
os: [ubuntu-latest]
coherenceVersion:
- 24.09
- 24.09.2
- 22.06.11
base-image:
- gcr.io/distroless/java17-debian11
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ jobs:
poetry-version: ["1.8.4"]
os: [ubuntu-latest]
coherenceVersion:
- 24.09
- 24.09.2
- 22.06.11
base-image:
- gcr.io/distroless/java17-debian11
profile:
- ",-jakarta,javax"
- ",jakarta,-javax"
exclude:
- coherenceVersion: 24.09
- coherenceVersion: 24.09.2
profile: ",-jakarta,javax"
- coherenceVersion: 22.06.11
profile: ",jakarta,-javax"
Expand Down
15 changes: 13 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,12 @@ E2E_TESTS := tests/e2e/test_session.py \
tests/e2e/test_filters.py \
tests/e2e/test_processors.py \
tests/e2e/test_aggregators.py \
tests/e2e/test_near_caching.py \
# tests/e2e/test_ai.py \
tests/e2e/test_near_caching.py

#----------------------------------------------------------------------------------------------------------------------
# AI tests
# ----------------------------------------------------------------------------------------------------------------------
AI_TESTS := tests/e2e/test_ai.py

# ----------------------------------------------------------------------------------------------------------------------
# Clean-up all of the build artifacts
Expand Down Expand Up @@ -171,6 +175,13 @@ generate-proto: ## Generate Proto Files
test: ##
pytest -W error --cov src/coherence --cov-report=term --cov-report=html $(UNIT_TESTS) $(E2E_TESTS)

# ----------------------------------------------------------------------------------------------------------------------
# Run tests with code coverage
# ----------------------------------------------------------------------------------------------------------------------
.PHONY: test-with-ai
test-with-ai: ##
pytest -W error --cov src/coherence --cov-report=term --cov-report=html $(UNIT_TESTS) $(E2E_TESTS) $(AI_TESTS)

# ----------------------------------------------------------------------------------------------------------------------
# Run nslookup tests with code coverage
# ----------------------------------------------------------------------------------------------------------------------
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ The Coherence Python Client allows Python applications to act as cache clients t
* Support for storing Python objects as JSON as well as the ability to serialize to Java objects on the server for access from other Coherence language API's

#### Requirements
* [Coherence CE](https://github.com/oracle/coherence) 22.06.11+ or Coherence 14.1.1.2206.11+ Commercial edition with a configured [gRPCProxy](https://docs.oracle.com/en/middleware/standalone/coherence/14.1.1.2206/develop-remote-clients/using-coherence-grpc-server.html).
* Python 3.9.x
* [Coherence CE](https://github.com/oracle/coherence) 22.06.11+ or Coherence 14.1.1.2206.11+, 14.1.2.0+ Commercial edition with a configured [gRPCProxy](https://docs.oracle.com/en/middleware/standalone/coherence/14.1.1.2206/develop-remote-clients/using-coherence-grpc-server.html).
* Usage of module `coherence.ai` requires [Coherence CE](https://github.com/oracle/coherence) 24.09.2+
* Python 3.9.x or later


#### Starting a Coherence Cluster
Expand All @@ -31,7 +32,7 @@ For local development, we recommend using the Coherence CE Docker image; it cont
everything necessary for the client to operate correctly.

```bash
docker run -d -p 1408:1408 ghcr.io/oracle/coherence-ce:24.09
docker run -d -p 1408:1408 ghcr.io/oracle/coherence-ce:24.09.02
```

## Installation
Expand Down Expand Up @@ -112,7 +113,7 @@ Please consult the [security guide](./SECURITY.md) for our responsible security

## License

Copyright (c) 2023, 2024, Oracle and/or its affiliates.
Copyright (c) 2023, 2025, Oracle and/or its affiliates.

Released under the Universal Permissive License v1.0 as shown at
<https://oss.oracle.com/licenses/upl/>.
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
sys.path.insert(0, os.path.abspath("../src"))

# The full version, including alpha/beta/rc tags
release = "1.1.1"
release = "2.0.0"

# -- Project information -----------------------------------------------------

project = "Python Client for Oracle Coherence. v%s" % release
copyright = "(c) 2022, 2024, Oracle and/or its affiliates."
copyright = "(c) 2022, 2025, Oracle and/or its affiliates."
author = "Oracle"


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# https://oss.oracle.com/licenses/upl.
[tool.poetry]
name = "coherence-client"
version = "1.1.1"
version = "2.0.0"
description = """The Coherence Python Client allows Python applications to act as cache clients to a \
Coherence Cluster using Google's gRPC framework as the network transport."""
packages = [
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Copyright (c) 2022, 2024, Oracle and/or its affiliates.
# Copyright (c) 2022, 2025, Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at
# https://oss.oracle.com/licenses/upl.

from distutils.core import setup

setup(
name="coherence-client",
version="1.1.1",
version="2.0.0",
packages=["coherence"],
url="https://github.com/oracle/coherence-py-client",
license="UPL",
Expand Down
2 changes: 1 addition & 1 deletion src/coherence/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from __future__ import annotations

__version__ = "1.1.1"
__version__ = "2.0.0"

import contextvars
import logging
Expand Down
11 changes: 6 additions & 5 deletions src/coherence/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ async def put_if_absent(self, key: K, value: V) -> Optional[V]:
"""

@abc.abstractmethod
async def put_all(self, map: dict[K, V], ttl: Optional[int] = 0) -> None:
async def put_all(self, map: dict[K, V], ttl: Optional[int] = None) -> None:
"""
Copies all mappings from the specified map to this map

Expand Down Expand Up @@ -669,7 +669,7 @@ async def put(self, key: K, value: V, ttl: Optional[int] = None) -> Optional[V]:

:param key: the key with which the specified value is to be associated
:param value: the value to be associated with the specified key
:param ttl: the expiry time in millis (optional). If not specific, it will default to the default
:param ttl: the expiry time in millis (optional). If not specified, it will default to the default
ttl defined in the cache options provided when the cache was obtained
:return: resolving to the previous value associated with specified key, or `None` if there was no mapping for
key. A `None` return can also indicate that the map previously associated `None` with the specified key
Expand All @@ -685,7 +685,7 @@ async def put_if_absent(self, key: K, value: V, ttl: Optional[int] = None) -> Op

:param key: the key with which the specified value is to be associated
:param value: the value to be associated with the specified key
:param ttl: the expiry time in millis (optional). If not specific, it will default to the default
:param ttl: the expiry time in millis (optional). If not specified, it will default to the default
ttl defined in the cache options provided when the cache was obtained.
:return: resolving to the previous value associated with specified key, or `None` if there was no mapping for
key. A `None` return can also indicate that the map previously associated `None` with the specified key
Expand Down Expand Up @@ -1576,8 +1576,9 @@ class Options:
Environment variable to specify the Coherence gRPC server address for the client to connect to. The
environment variable is used if address is not passed as an argument in the constructor. If the environment
variable is not set and address is not passed as an argument then `DEFAULT_ADDRESS` is used. One can also
use the 'coherence' gRPC resolver address of "coherence:///host:port" to connect to the Coherence Name
Service, running on the cluster port, and automatically discover the gRPC endpoints.
use the 'coherence' resolver address of "coherence:///host:port" to connect to the Coherence Name
Service, running on the cluster port, and automatically discover the gRPC proxy addresses and one of them
will be randomly picked.
"""
ENV_REQUEST_TIMEOUT = "COHERENCE_CLIENT_REQUEST_TIMEOUT"
"""
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/test_ai.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2022, 2024, Oracle and/or its affiliates.
# Copyright (c) 2022, 2025, Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at
# https://oss.oracle.com/licenses/upl.
import random
Expand Down Expand Up @@ -93,6 +93,7 @@ async def populate_document_chunk_vectors(vectors: NamedCache[int, DocumentChunk


@pytest.mark.asyncio
@pytest.mark.filterwarnings("ignore::pytest.PytestUnraisableExceptionWarning")
async def test_similarity_search_with_index(test_session: Session) -> None:
cache: NamedCache[int, ValueWithVector] = await test_session.get_cache("vector_cache")
cache.add_index(BinaryQuantIndex(Extractors.extract("vector")))
Expand Down Expand Up @@ -134,6 +135,7 @@ async def test_similarity_search_with_index(test_session: Session) -> None:


@pytest.mark.asyncio
@pytest.mark.filterwarnings("ignore::pytest.PytestUnraisableExceptionWarning")
async def test_similarity_search_with_document_chunk(test_session: Session) -> None:
cache: NamedCache[int, DocumentChunk] = await test_session.get_cache("vector_cache")
dc: DocumentChunk = await populate_document_chunk_vectors(cache)
Expand Down
60 changes: 42 additions & 18 deletions tests/scripts/run-tests.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

#
# Copyright (c) 2022, 2023, Oracle and/or its affiliates.
# Copyright (c) 2022, 2025, Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at
# https://oss.oracle.com/licenses/upl.
#
Expand Down Expand Up @@ -30,21 +30,45 @@ if [ -z "${PROFILE_STR}" ] ; then
exit 1
fi

echo "Coherence CE 22.06.11"
COHERENCE_CLIENT_REQUEST_TIMEOUT=180.0 \
COHERENCE_VERSION=$COH_VER \
COHERENCE_BASE_IMAGE=$BASE_IMAGE \
PROFILES=$PROFILE_STR \
make clean test-cluster-shutdown remove-app-images build-test-images test-cluster-startup just-wait test

echo "Coherence CE 22.06.11 with SSL"
RUN_SECURE=true COHERENCE_IGNORE_INVALID_CERTS=true \
COHERENCE_TLS_CERTS_PATH=$(pwd)/tests/utils/certs/guardians-ca.crt \
COHERENCE_TLS_CLIENT_CERT=$(pwd)/tests/utils/certs/star-lord.crt \
COHERENCE_TLS_CLIENT_KEY=$(pwd)/tests/utils/certs/star-lord.pem \
if [[ "${COH_VER}" =~ "22.06" ]] ; then
echo "Coherence CE ${COH_VER}"
COHERENCE_CLIENT_REQUEST_TIMEOUT=180.0 \
COHERENCE_VERSION=$COH_VER \
COHERENCE_BASE_IMAGE=$BASE_IMAGE \
PROFILES=$PROFILE_STR,secure \
make clean certs test-cluster-shutdown remove-app-images \
build-test-images test-cluster-startup just-wait test
COHERENCE_VERSION=$COH_VER \
COHERENCE_BASE_IMAGE=$BASE_IMAGE \
PROFILES=$PROFILE_STR \
make clean test-cluster-shutdown remove-app-images build-test-images test-cluster-startup just-wait test
else
echo "Coherence CE ${COH_VER}"
COHERENCE_CLIENT_REQUEST_TIMEOUT=180.0 \
COHERENCE_VERSION=$COH_VER \
COHERENCE_BASE_IMAGE=$BASE_IMAGE \
PROFILES=$PROFILE_STR \
make clean test-cluster-shutdown remove-app-images build-test-images test-cluster-startup just-wait test-with-ai
fi

# Run tests with SSL
if [[ "${COH_VER}" =~ "22.06" ]] ; then
echo "Coherence CE ${COH_VER} with SSL"
RUN_SECURE=true COHERENCE_IGNORE_INVALID_CERTS=true \
COHERENCE_TLS_CERTS_PATH=$(pwd)/tests/utils/certs/guardians-ca.crt \
COHERENCE_TLS_CLIENT_CERT=$(pwd)/tests/utils/certs/star-lord.crt \
COHERENCE_TLS_CLIENT_KEY=$(pwd)/tests/utils/certs/star-lord.pem \
COHERENCE_CLIENT_REQUEST_TIMEOUT=180.0 \
COHERENCE_VERSION=$COH_VER \
COHERENCE_BASE_IMAGE=$BASE_IMAGE \
PROFILES=$PROFILE_STR,secure \
make clean certs test-cluster-shutdown remove-app-images \
build-test-images test-cluster-startup just-wait test
else
echo "Coherence CE ${COH_VER} with SSL"
RUN_SECURE=true COHERENCE_IGNORE_INVALID_CERTS=true \
COHERENCE_TLS_CERTS_PATH=$(pwd)/tests/utils/certs/guardians-ca.crt \
COHERENCE_TLS_CLIENT_CERT=$(pwd)/tests/utils/certs/star-lord.crt \
COHERENCE_TLS_CLIENT_KEY=$(pwd)/tests/utils/certs/star-lord.pem \
COHERENCE_CLIENT_REQUEST_TIMEOUT=180.0 \
COHERENCE_VERSION=$COH_VER \
COHERENCE_BASE_IMAGE=$BASE_IMAGE \
PROFILES=$PROFILE_STR,secure \
make clean certs test-cluster-shutdown remove-app-images \
build-test-images test-cluster-startup just-wait test-with-ai
fi