-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUG] Fix circular import when initializing a client with basic auth (#…
…1775) ## Description of changes *Summarize the changes made by this PR.* - Improvements & Bug fixes - Fixes #1554 (again) ## Test plan *How are these changes tested?* - [ ] Tests pass locally with `pytest` for python, `yarn test` for js ## Documentation Changes *Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the [docs repository](https://github.com/chroma-core/docs)?*
- Loading branch information
Showing
6 changed files
with
49 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
chromadb/test/client/create_http_client_with_basic_auth.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# This file is used by test_create_http_client.py to test the initialization | ||
# of an HttpClient class with auth settings. | ||
# | ||
# See https://github.com/chroma-core/chroma/issues/1554 | ||
|
||
import chromadb | ||
from chromadb.config import Settings | ||
import sys | ||
|
||
def main() -> None: | ||
try: | ||
chromadb.HttpClient( | ||
host='localhost', | ||
port=8000, | ||
settings=Settings( | ||
chroma_client_auth_provider="chromadb.auth.basic.BasicAuthClientProvider", | ||
chroma_client_auth_credentials="admin:testDb@home2" | ||
) | ||
) | ||
except ValueError: | ||
# We don't expect to be able to connect to Chroma. We just want to make sure | ||
# there isn't an ImportError. | ||
sys.exit(0) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import subprocess | ||
|
||
# Needs to be a module, not a file, so that local imports work. | ||
TEST_MODULE = "chromadb.test.client.create_http_client_with_basic_auth" | ||
|
||
|
||
def test_main() -> None: | ||
# This is the only way to test what we want to test: pytest does a bunch of | ||
# importing and other module stuff in the background, so we need a clean | ||
# python process to make sure we're not circular-importing. | ||
# | ||
# See https://github.com/chroma-core/chroma/issues/1554 | ||
|
||
res = subprocess.run(['python', '-m', TEST_MODULE]) | ||
assert res.returncode == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters