Skip to content

Commit

Permalink
revert AVS_DATA_NAMESPACE and AVS_DATA_SET example options to AVS_NAM…
Browse files Browse the repository at this point in the history
…ESPACE and AVS_SET to avoid a breaking change
  • Loading branch information
dwelch-spike committed Aug 1, 2024
1 parent 55be2e7 commit 6bae41b
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ spec:
value: {{ .Values.quoteSearchConfig.avsNamespace | quote }}
- name: AVS_SET
value: {{ .Values.quoteSearchConfig.avsSet | quote }}
- name: AVS_INDEX_NAMESPACE
value: {{ .Values.quoteSearchConfig.avsIndexNamespace | quote }}
- name: AVS_INDEX_SET
value: {{ .Values.quoteSearchConfig.avsIndexSet | quote }}
- name: AVS_VERIFY_TLS
value: {{ .Values.quoteSearchConfig.avsVerifyTls | quote }}
- name: AVS_MAX_RESULTS
Expand Down
8 changes: 4 additions & 4 deletions prism-image-search/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ If not set defaults are used.
| AVS_HOST | localhost | AVS server seed host |
| AVS_PORT | 5000 | AVS server seed host port |
| AVS_ADVERTISED_LISTENER| | An optional advertised listener to use if configured on the AVS server |
| AVS_DATA_NAMESPACE | test | The Aerospike namespace for storing the image records |
| AVS_DATA_SET | image-data | The Aerospike set for storing the image records |
| AVS_DATA_NAMESPACE | test | The Aerospike namespace for storing the HNSW index |
| AVS_DATA_SET | image-index | The Aerospike set for storing the HNSW index |
| AVS_NAMESPACE | test | The Aerospike namespace for storing the image records |
| AVS_SET | image-data | The Aerospike set for storing the image records |
| AVS_NAMESPACE | test | The Aerospike namespace for storing the HNSW index |
| AVS_SET | image-index | The Aerospike set for storing the HNSW index |
| AVS_INDEX_NAME | prism-image-search | The name of the index |
| AVS_MAX_RESULTS | 20 | Maximum number of vector search results to return |
| AVS_IS_LOADBALANCER | False | If true, the first seed address will be treated as a load balancer node.```
Expand Down
4 changes: 2 additions & 2 deletions prism-image-search/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ services:
APP_NUM_QUOTES: "5000"
GRPC_DNS_RESOLVER: native
# comment out the following lines to use the default namespace (test) to store all index and vector data
AVS_DATA_NAMESPACE: avs-data
AVS_DATA_SET: quote-data
AVS_NAMESPACE: avs-data
AVS_SET: quote-data
AVS_INDEX_NAMESPACE: avs-index
AVS_INDEX_SET: quote-index
volumes:
Expand Down
4 changes: 2 additions & 2 deletions prism-image-search/prism/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class Config(object):
AVS_PORT = int(os.environ.get("AVS_PORT") or 5000)
AVS_ADVERTISED_LISTENER = os.environ.get("AVS_ADVERTISED_LISTENER") or None
AVS_INDEX_NAME = os.environ.get("AVS_INDEX_NAME") or "prism-image-search"
AVS_DATA_NAMESPACE = os.environ.get("AVS_DATA_NAMESPACE") or "test"
AVS_DATA_SET = os.environ.get("AVS_DATA_SET") or "image-data"
AVS_NAMESPACE = os.environ.get("AVS_NAMESPACE") or "test"
AVS_SET = os.environ.get("AVS_SET") or "image-data"
AVS_INDEX_NAMESPACE = os.environ.get("AVS_INDEX_NAMESPACE") or "test"
AVS_INDEX_SET = os.environ.get("AVS_INDEX_SET") or "image-index"
AVS_VERIFY_TLS = get_bool_env("VERIFY_TLS", True)
Expand Down
4 changes: 2 additions & 2 deletions prism-image-search/prism/dataset_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def collect_stats():
for filename in filenames:
# Check if record exists
if avs_client.is_indexed(
namespace=Config.AVS_DATA_NAMESPACE,
set_name=Config.AVS_DATA_SET,
namespace=Config.AVS_NAMESPACE,
set_name=Config.AVS_SET,
key=filename,
index_name=Config.AVS_INDEX_NAME,
):
Expand Down
14 changes: 7 additions & 7 deletions prism-image-search/prism/indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ def create_index():
try:
for index in avs_admin_client.index_list():
if (
index["id"]["namespace"] == Config.AVS_DATA_NAMESPACE
index["id"]["namespace"] == Config.AVS_NAMESPACE
and index["id"]["name"] == Config.AVS_INDEX_NAME
):
logger.info("Index already exists")
return

avs_admin_client.index_create(
namespace=Config.AVS_DATA_NAMESPACE,
namespace=Config.AVS_NAMESPACE,
name=Config.AVS_INDEX_NAME,
sets=Config.AVS_DATA_SET,
sets=Config.AVS_SET,
vector_field="image_embedding",
dimensions=MODEL_DIM,
vector_distance_metric=types.VectorDistanceMetric.COSINE,
Expand All @@ -63,8 +63,8 @@ def index_data():
# Check if record exists
try:
if avs_client.is_indexed(
namespace=Config.AVS_DATA_NAMESPACE,
set_name=Config.AVS_DATA_SET,
namespace=Config.AVS_NAMESPACE,
set_name=Config.AVS_SET,
key=filename,
index_name=Config.AVS_INDEX_NAME,
):
Expand Down Expand Up @@ -130,8 +130,8 @@ def index_image(filename):
try:
logger.debug(f"Inserting vector embedding into avs {filename}")
avs_client.upsert(
namespace=Config.AVS_DATA_NAMESPACE,
set_name=Config.AVS_DATA_SET,
namespace=Config.AVS_NAMESPACE,
set_name=Config.AVS_SET,
key=doc["image_id"],
record_data=doc,
)
Expand Down
6 changes: 3 additions & 3 deletions prism-image-search/prism/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def search_internal():
return "image_id is required", 400

record = avs_client.get(
namespace=Config.AVS_DATA_NAMESPACE,
set_name=Config.AVS_DATA_SET,
namespace=Config.AVS_NAMESPACE,
set_name=Config.AVS_SET,
key=image_id,
field_names=["image_embedding"],
)
Expand All @@ -72,7 +72,7 @@ def vector_search(embedding, count=Config.AVS_MAX_RESULTS):
# Execute kNN search over the image dataset
field_names = ["image_id", "image_name", "relative_path"]
return avs_client.vector_search(
namespace=Config.AVS_DATA_NAMESPACE,
namespace=Config.AVS_NAMESPACE,
index_name=Config.AVS_INDEX_NAME,
query=embedding,
limit=count,
Expand Down
8 changes: 4 additions & 4 deletions quote-semantic-search/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ If not set defaults are used.
| AVS_HOST | localhost | AVS server seed host |
| AVS_PORT | 5000 | AVS server seed host port |
| AVS_ADVERTISED_LISTENER| | An optional advertised listener to use if configured on the AVS server |
| AVS_DATA_NAMESPACE | test | The Aerospike namespace for storing the quote records |
| AVS_DATA_SET | quote-data | The Aerospike set for storing the quote records |
| AVS_DATA_NAMESPACE | test | The Aerospike namespace for storing the HNSW index |
| AVS_DATA_SET | quote-index | The Aerospike set for storing the HNSW index |
| AVS_NAMESPACE | test | The Aerospike namespace for storing the quote records |
| AVS_SET | quote-data | The Aerospike set for storing the quote records |
| AVS_NAMESPACE | test | The Aerospike namespace for storing the HNSW index |
| AVS_SET | quote-index | The Aerospike set for storing the HNSW index |
| AVS_INDEX_NAME | quote-search | The name of the index |
| AVS_MAX_RESULTS | 20 | Maximum number of vector search results to return |
| AVS_IS_LOADBALANCER | False | If true, the first seed address will be treated as a load balancer node.```
Expand Down
4 changes: 2 additions & 2 deletions quote-semantic-search/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ services:
APP_NUM_QUOTES: "5000"
GRPC_DNS_RESOLVER: native
# comment out the following lines to use the default namespace (test) to store all index and vector data
AVS_DATA_NAMESPACE: avs-data
AVS_DATA_SET: quote-data
AVS_NAMESPACE: avs-data
AVS_SET: quote-data
AVS_INDEX_NAMESPACE: avs-index
AVS_INDEX_SET: quote-index

Expand Down
4 changes: 2 additions & 2 deletions quote-semantic-search/quote-search/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class Config(object):
AVS_PORT = int(os.environ.get("AVS_PORT") or 5000)
AVS_ADVERTISED_LISTENER = os.environ.get("AVS_ADVERTISED_LISTENER") or None
AVS_INDEX_NAME = os.environ.get("AVS_INDEX_NAME") or "quote-semantic-search"
AVS_DATA_NAMESPACE = os.environ.get("AVS_DATA_NAMESPACE") or "test"
AVS_DATA_SET = os.environ.get("AVS_DATA_SET") or "quote-data"
AVS_NAMESPACE = os.environ.get("AVS_NAMESPACE") or "test"
AVS_SET = os.environ.get("AVS_SET") or "quote-data"
AVS_INDEX_NAMESPACE = os.environ.get("AVS_INDEX_NAMESPACE") or "test"
AVS_INDEX_SET = os.environ.get("AVS_INDEX_SET") or "quote-index"
AVS_VERIFY_TLS = get_bool_env("VERIFY_TLS", True)
Expand Down
4 changes: 2 additions & 2 deletions quote-semantic-search/quote-search/dataset_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def collect_stats():
for quote_id in range(Config.NUM_QUOTES):
# Check if record exists
if avs_client.is_indexed(
namespace=Config.AVS_DATA_NAMESPACE,
set_name=Config.AVS_DATA_SET,
namespace=Config.AVS_NAMESPACE,
set_name=Config.AVS_SET,
key=quote_id,
index_name=Config.AVS_INDEX_NAME,
):
Expand Down
10 changes: 5 additions & 5 deletions quote-semantic-search/quote-search/indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ def create_index():
try:
for index in avs_admin_client.index_list():
if (
index["id"]["namespace"] == Config.AVS_DATA_NAMESPACE
index["id"]["namespace"] == Config.AVS_NAMESPACE
and index["id"]["name"] == Config.AVS_INDEX_NAME
):
return

avs_admin_client.index_create(
namespace=Config.AVS_DATA_NAMESPACE,
namespace=Config.AVS_NAMESPACE,
name=Config.AVS_INDEX_NAME,
sets=Config.AVS_DATA_SET,
sets=Config.AVS_SET,
vector_field="quote_embedding",
dimensions=MODEL_DIM,
vector_distance_metric=types.VectorDistanceMetric.COSINE,
Expand Down Expand Up @@ -110,8 +110,8 @@ def index_quote(id_quote):
# Insert record
try:
avs_client.upsert(
namespace=Config.AVS_DATA_NAMESPACE,
set_name=Config.AVS_DATA_SET,
namespace=Config.AVS_NAMESPACE,
set_name=Config.AVS_SET,
key=doc["quote_id"],
record_data=doc,
)
Expand Down
6 changes: 3 additions & 3 deletions quote-semantic-search/quote-search/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def search_internal():
return "quote_id is required", 400

record = avs_client.get(
namespace=Config.AVS_DATA_NAMESPACE,
set_name=Config.AVS_DATA_SET,
namespace=Config.AVS_NAMESPACE,
set_name=Config.AVS_SET,
key=int(quote_id),
field_names=["quote_embedding"],
)
Expand All @@ -75,7 +75,7 @@ def vector_search(embedding, count=Config.AVS_MAX_RESULTS):
# Execute kNN search over the dataset
field_names = ["quote_id", "quote", "author"]
r = avs_client.vector_search(
namespace=Config.AVS_DATA_NAMESPACE,
namespace=Config.AVS_NAMESPACE,
index_name=Config.AVS_INDEX_NAME,
query=embedding,
limit=count,
Expand Down

0 comments on commit 6bae41b

Please sign in to comment.