SimilarityIndexDetector#
SimilarityIndexDetector is a class that can be used to detect similarity indexes in views and update them. To see how to use it, see the How-To: Update Similarity Indexes guide.
dbally.similarity.detector.SimilarityIndexDetector
#
SimilarityIndexDetector(module: ModuleType, chosen_view_name: Optional[str] = None, chosen_method_name: Optional[str] = None, chosen_argument_name: Optional[str] = None)
Class used to detect similarity indexes. Works with method-based views that inherit from MethodsBaseView (including all built-in dbally views). Automatically detects similarity indexes on arguments of view's filter methods.
PARAMETER | DESCRIPTION |
---|---|
module |
The module to search for similarity indexes
TYPE:
|
chosen_view_name |
The name of the view to search in (optional, all views if None)
TYPE:
|
chosen_method_name |
The name of the method to search in (optional, all methods if None)
TYPE:
|
chosen_argument_name |
The name of the argument to search in (optional, all arguments if None)
TYPE:
|
Source code in src/dbally/similarity/detector.py
from_path
classmethod
#
from_path(path: str) -> SimilarityIndexDetector
Create a SimilarityIndexDetector object from a path string in the format "path.to.module:ViewName.method_name.argument_name" where each part after the colon is optional.
PARAMETER | DESCRIPTION |
---|---|
path |
The path to the object
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
SimilarityIndexDetector
|
The SimilarityIndexDetector object |
RAISES | DESCRIPTION |
---|---|
SimilarityIndexDetectorException
|
If the module is not found |
Source code in src/dbally/similarity/detector.py
get_module_from_path
staticmethod
#
Get the module from the given path
PARAMETER | DESCRIPTION |
---|---|
module_path |
The path to the module
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ModuleType
|
The module |
RAISES | DESCRIPTION |
---|---|
SimilarityIndexDetectorException
|
If the module is not found |
Source code in src/dbally/similarity/detector.py
list_views
#
list_views() -> List[Type[MethodsBaseView]]
List method-based views in the module, filtering by the chosen view name if given during initialization.
RETURNS | DESCRIPTION |
---|---|
List[Type[MethodsBaseView]]
|
List of views |
RAISES | DESCRIPTION |
---|---|
SimilarityIndexDetectorException
|
If the chosen view is not found |
Source code in src/dbally/similarity/detector.py
list_filters
#
list_filters(view: Type[MethodsBaseView]) -> List[ExposedFunction]
List filters in the given view, filtering by the chosen method name if given during initialization.
PARAMETER | DESCRIPTION |
---|---|
view |
The view
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
List[ExposedFunction]
|
List of filter names |
RAISES | DESCRIPTION |
---|---|
SimilarityIndexDetectorException
|
If the chosen method is not found |
Source code in src/dbally/similarity/detector.py
list_arguments
#
list_arguments(method: ExposedFunction) -> List[MethodParamWithTyping]
List arguments in the given method, filtering by the chosen argument name if given during initialization.
PARAMETER | DESCRIPTION |
---|---|
method |
The method
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
List[MethodParamWithTyping]
|
List of argument names |
RAISES | DESCRIPTION |
---|---|
SimilarityIndexDetectorException
|
If the chosen argument is not found |
Source code in src/dbally/similarity/detector.py
list_indexes
#
list_indexes(view: Optional[Type[MethodsBaseView]] = None) -> Dict[AbstractSimilarityIndex, List[str]]
List similarity indexes in the module, filtering by the chosen view, method and argument names if given during initialization.
PARAMETER | DESCRIPTION |
---|---|
view |
The view to search in (optional, all views if None)
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Dict[AbstractSimilarityIndex, List[str]]
|
Dictionary mapping indexes to method arguments that use them |
RAISES | DESCRIPTION |
---|---|
SimilarityIndexDetectorException
|
If any of the chosen path parts is not found |
Source code in src/dbally/similarity/detector.py
update_indexes
async
#
Update similarity indexes in the module, filtering by the chosen view, method and argument names if given during initialization.
RAISES | DESCRIPTION |
---|---|
SimilarityIndexDetectorException
|
If any of the chosen path parts is not found |