Skip to content

Commit d47e46a

Browse files
authored
fix!: rename env variables for Azure AI (#1597)
* rename env variables
1 parent b701e7a commit d47e46a

File tree

8 files changed

+35
-35
lines changed

8 files changed

+35
-35
lines changed

integrations/azure_ai_search/example/document_store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""
66
This example demonstrates how to use the AzureAISearchDocumentStore to write and filter documents.
77
To run this example, you'll need an Azure Search service endpoint and API key, which can either be
8-
set as environment variables (AZURE_SEARCH_SERVICE_ENDPOINT and AZURE_SEARCH_API_KEY) or
8+
set as environment variables (AZURE_AI_SEARCH_ENDPOINT and AZURE_AI_SEARCH_API_KEY) or
99
provided directly to AzureAISearchDocumentStore(as params "api_key", "azure_endpoint").
1010
Otherwise you can use DefaultAzureCredential to authenticate with Azure services.
1111
See more details at https://learn.microsoft.com/en-us/azure/search/keyless-connections?tabs=python%2Cazure-cli

integrations/azure_ai_search/example/embedding_retrieval.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
This example demonstrates how to use the AzureAISearchEmbeddingRetriever to retrieve documents
1010
using embeddings based on a query. To run this example, you'll need an Azure Search service endpoint
1111
and API key, which can either be
12-
set as environment variables (AZURE_SEARCH_SERVICE_ENDPOINT and AZURE_SEARCH_API_KEY) or
12+
set as environment variables (AZURE_AI_SEARCH_ENDPOINT and AZURE_AI_SEARCH_API_KEY) or
1313
provided directly to AzureAISearchDocumentStore(as params "api_key", "azure_endpoint").
1414
Otherwise you can use DefaultAzureCredential to authenticate with Azure services.
1515
See more details at https://learn.microsoft.com/en-us/azure/search/keyless-connections?tabs=python%2Cazure-cli

integrations/azure_ai_search/src/haystack_integrations/document_stores/azure_ai_search/document_store.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ class AzureAISearchDocumentStore:
6363
def __init__(
6464
self,
6565
*,
66-
api_key: Secret = Secret.from_env_var("AZURE_SEARCH_API_KEY", strict=False), # noqa: B008
67-
azure_endpoint: Secret = Secret.from_env_var("AZURE_SEARCH_SERVICE_ENDPOINT", strict=True), # noqa: B008
66+
api_key: Secret = Secret.from_env_var("AZURE_AI_SEARCH_API_KEY", strict=False), # noqa: B008
67+
azure_endpoint: Secret = Secret.from_env_var("AZURE_AI_SEARCH_ENDPOINT", strict=True), # noqa: B008
6868
index_name: str = "default",
6969
embedding_dimension: int = 768,
7070
metadata_fields: Optional[Dict[str, type]] = None,
@@ -97,12 +97,12 @@ def __init__(
9797
For more information on parameters, see the [official Azure AI Search documentation](https://learn.microsoft.com/en-us/azure/search/).
9898
"""
9999

100-
azure_endpoint = azure_endpoint or os.environ.get("AZURE_SEARCH_SERVICE_ENDPOINT") or None
100+
azure_endpoint = azure_endpoint or os.environ.get("AZURE_AI_SEARCH_ENDPOINT") or None
101101
if not azure_endpoint:
102-
msg = "Please provide an Azure endpoint or set the environment variable AZURE_SEARCH_SERVICE_ENDPOINT."
102+
msg = "Please provide an Azure endpoint or set the environment variable AZURE_AI_SEARCH_ENDPOINT."
103103
raise ValueError(msg)
104104

105-
api_key = api_key or os.environ.get("AZURE_SEARCH_API_KEY") or None
105+
api_key = api_key or os.environ.get("AZURE_AI_SEARCH_API_KEY") or None
106106

107107
self._client = None
108108
self._index_client = None

integrations/azure_ai_search/tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ def cleanup_indexes():
8989
Only runs if Azure credentials are available.
9090
Automatically runs after all tests.
9191
"""
92-
azure_endpoint = os.getenv("AZURE_SEARCH_SERVICE_ENDPOINT")
93-
api_key = os.getenv("AZURE_SEARCH_API_KEY")
92+
azure_endpoint = os.getenv("AZURE_AI_SEARCH_ENDPOINT")
93+
api_key = os.getenv("AZURE_AI_SEARCH_API_KEY")
9494

9595
# Skip cleanup if credentials aren't available
9696
if not azure_endpoint or not api_key:

integrations/azure_ai_search/tests/test_bm25_retriever.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ def test_to_dict():
4141
"init_parameters": {
4242
"azure_endpoint": {
4343
"type": "env_var",
44-
"env_vars": ["AZURE_SEARCH_SERVICE_ENDPOINT"],
44+
"env_vars": ["AZURE_AI_SEARCH_ENDPOINT"],
4545
"strict": True,
4646
},
47-
"api_key": {"type": "env_var", "env_vars": ["AZURE_SEARCH_API_KEY"], "strict": False},
47+
"api_key": {"type": "env_var", "env_vars": ["AZURE_AI_SEARCH_API_KEY"], "strict": False},
4848
"index_name": "default",
4949
"embedding_dimension": 768,
5050
"metadata_fields": None,

integrations/azure_ai_search/tests/test_document_store.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323

2424
@patch("haystack_integrations.document_stores.azure_ai_search.document_store.AzureAISearchDocumentStore")
2525
def test_to_dict(monkeypatch):
26-
monkeypatch.setenv("AZURE_SEARCH_API_KEY", "test-api-key")
27-
monkeypatch.setenv("AZURE_SEARCH_SERVICE_ENDPOINT", "test-endpoint")
26+
monkeypatch.setenv("AZURE_AI_SEARCH_API_KEY", "test-api-key")
27+
monkeypatch.setenv("AZURE_AI_SEARCH_ENDPOINT", "test-endpoint")
2828
document_store = AzureAISearchDocumentStore()
2929
res = document_store.to_dict()
3030
assert res == {
3131
"type": "haystack_integrations.document_stores.azure_ai_search.document_store.AzureAISearchDocumentStore",
3232
"init_parameters": {
33-
"azure_endpoint": {"env_vars": ["AZURE_SEARCH_SERVICE_ENDPOINT"], "strict": True, "type": "env_var"},
34-
"api_key": {"env_vars": ["AZURE_SEARCH_API_KEY"], "strict": False, "type": "env_var"},
33+
"azure_endpoint": {"env_vars": ["AZURE_AI_SEARCH_ENDPOINT"], "strict": True, "type": "env_var"},
34+
"api_key": {"env_vars": ["AZURE_AI_SEARCH_API_KEY"], "strict": False, "type": "env_var"},
3535
"index_name": "default",
3636
"embedding_dimension": 768,
3737
"metadata_fields": None,
@@ -53,14 +53,14 @@ def test_to_dict(monkeypatch):
5353

5454
@patch("haystack_integrations.document_stores.azure_ai_search.document_store.AzureAISearchDocumentStore")
5555
def test_from_dict(monkeypatch):
56-
monkeypatch.setenv("AZURE_SEARCH_API_KEY", "test-api-key")
57-
monkeypatch.setenv("AZURE_SEARCH_SERVICE_ENDPOINT", "test-endpoint")
56+
monkeypatch.setenv("AZURE_AI_SEARCH_API_KEY", "test-api-key")
57+
monkeypatch.setenv("AZURE_AI_SEARCH_ENDPOINT", "test-endpoint")
5858

5959
data = {
6060
"type": "haystack_integrations.document_stores.azure_ai_search.document_store.AzureAISearchDocumentStore",
6161
"init_parameters": {
62-
"azure_endpoint": {"env_vars": ["AZURE_SEARCH_SERVICE_ENDPOINT"], "strict": True, "type": "env_var"},
63-
"api_key": {"env_vars": ["AZURE_SEARCH_API_KEY"], "strict": False, "type": "env_var"},
62+
"azure_endpoint": {"env_vars": ["AZURE_AI_SEARCH_ENDPOINT"], "strict": True, "type": "env_var"},
63+
"api_key": {"env_vars": ["AZURE_AI_SEARCH_API_KEY"], "strict": False, "type": "env_var"},
6464
"embedding_dimension": 768,
6565
"index_name": "default",
6666
"metadata_fields": None,
@@ -101,8 +101,8 @@ def test_init(_mock_azure_search_client):
101101

102102
@pytest.mark.integration
103103
@pytest.mark.skipif(
104-
not os.environ.get("AZURE_SEARCH_SERVICE_ENDPOINT", None) and not os.environ.get("AZURE_SEARCH_API_KEY", None),
105-
reason="Missing AZURE_SEARCH_SERVICE_ENDPOINT or AZURE_SEARCH_API_KEY.",
104+
not os.environ.get("AZURE_AI_SEARCH_ENDPOINT", None) and not os.environ.get("AZURE_AI_SEARCH_API_KEY", None),
105+
reason="Missing AZURE_AI_SEARCH_ENDPOINT or AZURE_AI_SEARCH_API_KEY.",
106106
)
107107
class TestDocumentStore(CountDocumentsTest, WriteDocumentsTest, DeleteDocumentsTest):
108108

@@ -147,8 +147,8 @@ def _random_embeddings(n):
147147

148148
@pytest.mark.integration
149149
@pytest.mark.skipif(
150-
not os.environ.get("AZURE_SEARCH_SERVICE_ENDPOINT", None) and not os.environ.get("AZURE_SEARCH_API_KEY", None),
151-
reason="Missing AZURE_SEARCH_SERVICE_ENDPOINT or AZURE_SEARCH_API_KEY.",
150+
not os.environ.get("AZURE_AI_SEARCH_ENDPOINT", None) and not os.environ.get("AZURE_AI_SEARCH_API_KEY", None),
151+
reason="Missing AZURE_AI_SEARCH_ENDPOINT or AZURE_AI_SEARCH_API_KEY.",
152152
)
153153
@pytest.mark.parametrize(
154154
"document_store",

integrations/azure_ai_search/tests/test_embedding_retriever.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ def test_to_dict():
4444
"init_parameters": {
4545
"azure_endpoint": {
4646
"type": "env_var",
47-
"env_vars": ["AZURE_SEARCH_SERVICE_ENDPOINT"],
47+
"env_vars": ["AZURE_AI_SEARCH_ENDPOINT"],
4848
"strict": True,
4949
},
50-
"api_key": {"type": "env_var", "env_vars": ["AZURE_SEARCH_API_KEY"], "strict": False},
50+
"api_key": {"type": "env_var", "env_vars": ["AZURE_AI_SEARCH_API_KEY"], "strict": False},
5151
"index_name": "default",
5252
"embedding_dimension": 768,
5353
"metadata_fields": None,
@@ -82,10 +82,10 @@ def test_from_dict():
8282
"init_parameters": {
8383
"azure_endpoint": {
8484
"type": "env_var",
85-
"env_vars": ["AZURE_SEARCH_SERVICE_ENDPOINT"],
85+
"env_vars": ["AZURE_AI_SEARCH_ENDPOINT"],
8686
"strict": True,
8787
},
88-
"api_key": {"type": "env_var", "env_vars": ["AZURE_SEARCH_API_KEY"], "strict": False},
88+
"api_key": {"type": "env_var", "env_vars": ["AZURE_AI_SEARCH_API_KEY"], "strict": False},
8989
"index_name": "default",
9090
"embedding_dimension": 768,
9191
"metadata_fields": None,
@@ -164,8 +164,8 @@ def test_run_time_params():
164164

165165

166166
@pytest.mark.skipif(
167-
not os.environ.get("AZURE_SEARCH_SERVICE_ENDPOINT", None) and not os.environ.get("AZURE_SEARCH_API_KEY", None),
168-
reason="Missing AZURE_SEARCH_SERVICE_ENDPOINT or AZURE_SEARCH_API_KEY.",
167+
not os.environ.get("AZURE_AI_SEARCH_ENDPOINT", None) and not os.environ.get("AZURE_AI_SEARCH_API_KEY", None),
168+
reason="Missing AZURE_AI_SEARCH_ENDPOINT or AZURE_AI_SEARCH_API_KEY.",
169169
)
170170
@pytest.mark.integration
171171
class TestRetriever:

integrations/azure_ai_search/tests/test_hybrid_retriever.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ def test_to_dict():
4444
"init_parameters": {
4545
"azure_endpoint": {
4646
"type": "env_var",
47-
"env_vars": ["AZURE_SEARCH_SERVICE_ENDPOINT"],
47+
"env_vars": ["AZURE_AI_SEARCH_ENDPOINT"],
4848
"strict": True,
4949
},
50-
"api_key": {"type": "env_var", "env_vars": ["AZURE_SEARCH_API_KEY"], "strict": False},
50+
"api_key": {"type": "env_var", "env_vars": ["AZURE_AI_SEARCH_API_KEY"], "strict": False},
5151
"index_name": "default",
5252
"embedding_dimension": 768,
5353
"metadata_fields": None,
@@ -82,10 +82,10 @@ def test_from_dict():
8282
"init_parameters": {
8383
"azure_endpoint": {
8484
"type": "env_var",
85-
"env_vars": ["AZURE_SEARCH_SERVICE_ENDPOINT"],
85+
"env_vars": ["AZURE_AI_SEARCH_ENDPOINT"],
8686
"strict": True,
8787
},
88-
"api_key": {"type": "env_var", "env_vars": ["AZURE_SEARCH_API_KEY"], "strict": False},
88+
"api_key": {"type": "env_var", "env_vars": ["AZURE_AI_SEARCH_API_KEY"], "strict": False},
8989
"index_name": "default",
9090
"embedding_dimension": 768,
9191
"metadata_fields": None,
@@ -170,8 +170,8 @@ def test_run_time_params():
170170

171171

172172
@pytest.mark.skipif(
173-
not os.environ.get("AZURE_SEARCH_SERVICE_ENDPOINT", None) and not os.environ.get("AZURE_SEARCH_API_KEY", None),
174-
reason="Missing AZURE_SEARCH_SERVICE_ENDPOINT or AZURE_SEARCH_API_KEY.",
173+
not os.environ.get("AZURE_AI_SEARCH_ENDPOINT", None) and not os.environ.get("AZURE_AI_SEARCH_API_KEY", None),
174+
reason="Missing AZURE_AI_SEARCH_ENDPOINT or AZURE_AI_SEARCH_API_KEY.",
175175
)
176176
@pytest.mark.integration
177177
class TestRetriever:

0 commit comments

Comments
 (0)