Skip to content
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

refactor: optimize API keys reading #6655

Merged
merged 3 commits into from
Jan 5, 2024
Merged

Conversation

anakin87
Copy link
Member

@anakin87 anakin87 commented Dec 28, 2023

Related Issues

Proposed Changes:

I improved the API keys reading logic and adopted it in all components that need it.

How did you test it?

Local tests, CI

Checklist

@anakin87 anakin87 requested a review from a team as a code owner December 28, 2023 12:00
@anakin87 anakin87 requested review from vblagoje and removed request for a team December 28, 2023 12:00
@github-actions github-actions bot added topic:tests 2.x Related to Haystack v2.0 type:documentation Improvements on the docs labels Dec 28, 2023
"Set the AZURE_AI_API_KEY environment variable (recommended) or pass it explicitly."
) from e

self.api_key = api_key
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found out that the parameter self.api_key was never used, so I removed it.

@@ -10,7 +10,7 @@
class TestAzureOCRDocumentConverter:
def test_init_fail_wo_api_key(self, monkeypatch):
monkeypatch.delenv("AZURE_AI_API_KEY", raising=False)
with pytest.raises(ValueError, match="AzureOCRDocumentConverter expects an Azure Credential key"):
with pytest.raises(ValueError):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message changed, but I think we don't want to rely on error messages anymore.
So I only check the error type.

@anakin87 anakin87 added the ignore-for-release-notes PRs with this flag won't be included in the release notes. label Dec 28, 2023
Copy link
Member

@vblagoje vblagoje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@anakin87 anakin87 merged commit bb2b1a2 into main Jan 5, 2024
19 checks passed
@anakin87 anakin87 deleted the optimize-reading-api-keys branch January 5, 2024 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x Related to Haystack v2.0 ignore-for-release-notes PRs with this flag won't be included in the release notes. topic:tests type:documentation Improvements on the docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants