forked from chroma-core/chroma
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Small refactoring to address comments for review
- Loading branch information
Showing
8 changed files
with
204 additions
and
126 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from functools import partial | ||
from typing import Any, Callable, Dict | ||
from chromadb.auth import AuthzResourceTypes | ||
|
||
|
||
def find_key_with_value_of_type( | ||
type: AuthzResourceTypes, **kwargs: Any | ||
) -> Dict[str, Any]: | ||
from chromadb.server.fastapi.types import ( | ||
CreateCollection, | ||
CreateDatabase, | ||
CreateTenant, | ||
) | ||
|
||
for key, value in kwargs.items(): | ||
if type == AuthzResourceTypes.DB and isinstance(value, CreateDatabase): | ||
return dict(value) | ||
elif type == AuthzResourceTypes.COLLECTION and isinstance( | ||
value, CreateCollection | ||
): | ||
return dict(value) | ||
elif type == AuthzResourceTypes.TENANT and isinstance(value, CreateTenant): | ||
return dict(value) | ||
return {} | ||
|
||
|
||
def attr_from_resource_object( | ||
type: AuthzResourceTypes, **kwargs: Any | ||
) -> Callable[..., Dict[str, Any]]: | ||
obj = find_key_with_value_of_type(type, **kwargs) | ||
return partial(lambda **kwargs: obj, **kwargs) |
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
Oops, something went wrong.