Make eland_import_hub_model script compatible with serverless (#698)

Checks for build_flavor == serverless rather than a version
This commit is contained in:
David Kyle 2024-06-07 14:46:12 +01:00 committed by GitHub
parent 35a96ab3f0
commit 632074c0f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -32,6 +32,7 @@ import textwrap
from elastic_transport.client_utils import DEFAULT
from elasticsearch import AuthenticationException, Elasticsearch
from eland._version import __version__
from eland.common import parse_es_version
MODEL_HUB_URL = "https://huggingface.co"
@ -195,6 +196,17 @@ def get_es_client(cli_args, logger):
def check_cluster_version(es_client, logger):
es_info = es_client.info()
if (
"build_flavor" in es_info["version"]
and es_info["version"]["build_flavor"] == "serverless"
):
logger.info(f"Connected to serverless cluster '{es_info['cluster_name']}'")
# Serverless is compatible
# Return the latest known semantic version, i.e. this version
return parse_es_version(__version__)
# check the semantic version for none serverless clusters
logger.info(
f"Connected to cluster named '{es_info['cluster_name']}' (version: {es_info['version']['number']})"
)