From 54f9e8c4aeb536704e66aea7fee947bdacf7e676 Mon Sep 17 00:00:00 2001 From: trean Date: Wed, 28 Aug 2024 19:52:35 +0200 Subject: [PATCH] Quality check timeout (#228) * rename SearchQualityPannel -> SearchQualityPanel, added timeout as param * fixes --- .../SearchQuality/SearchQuality.jsx | 4 ++-- ...alityPannel.jsx => SearchQualityPanel.jsx} | 21 +++++++++++++------ .../SearchQuality/check-index-precision.js | 9 ++++---- src/components/EditorCommon/index.jsx | 2 +- src/components/FilterEditorWindow/index.jsx | 2 +- 5 files changed, 23 insertions(+), 15 deletions(-) rename src/components/Collections/SearchQuality/{SearchQualityPannel.jsx => SearchQualityPanel.jsx} (95%) diff --git a/src/components/Collections/SearchQuality/SearchQuality.jsx b/src/components/Collections/SearchQuality/SearchQuality.jsx index 5bc89359..2ba44ca6 100644 --- a/src/components/Collections/SearchQuality/SearchQuality.jsx +++ b/src/components/Collections/SearchQuality/SearchQuality.jsx @@ -2,7 +2,7 @@ import React, { useEffect } from 'react'; import PropTypes from 'prop-types'; import { getSnackbarOptions } from '../../Common/utils/snackbarOptions'; import { useClient } from '../../../context/client-context'; -import SearchQualityPannel from './SearchQualityPannel'; +import SearchQualityPanel from './SearchQualityPanel'; import { useSnackbar } from 'notistack'; import { Box, Card, CardHeader } from '@mui/material'; import { CopyButton } from '../../Common/CopyButton'; @@ -51,7 +51,7 @@ const SearchQuality = ({ collectionName }) => { return ( <> {collection?.config?.params?.vectors && ( - { +const SearchQualityPanel = ({ collectionName, vectors, loggingFoo, clearLogsFoo, ...other }) => { const { client } = useClient(); const vectorsNames = Object.keys(vectors); const [precision, setPrecision] = useState(() => { @@ -110,7 +110,8 @@ const SearchQualityPannel = ({ collectionName, vectors, loggingFoo, clearLogsFoo // "value": "field_value" // } // } -// } +// }, +// "timeout": 20 // } `); @@ -153,6 +154,13 @@ const SearchQualityPannel = ({ collectionName, vectors, loggingFoo, clearLogsFoo }, ], }, + timeout: { + description: 'Timeout for search', + type: 'integer', + format: 'uint', + minimum: 1, + nullable: true, + }, }, }); @@ -160,7 +168,7 @@ const SearchQualityPannel = ({ collectionName, vectors, loggingFoo, clearLogsFoo return <>No vectors; } - const onCheckIndexQuality = async ({ using = '', limit = 10, params = null, filter = null }) => { + const onCheckIndexQuality = async ({ using = '', limit = 10, params = null, filter = null, timeout }) => { setInProgress(true); clearLogsFoo && clearLogsFoo(); @@ -191,7 +199,8 @@ const SearchQualityPannel = ({ collectionName, vectors, loggingFoo, clearLogsFoo filter, params, using, - limit + limit, + timeout ); if (precision) { precisions.push(precision); @@ -311,7 +320,7 @@ const SearchQualityPannel = ({ collectionName, vectors, loggingFoo, clearLogsFoo ); }; -SearchQualityPannel.propTypes = { +SearchQualityPanel.propTypes = { collectionName: PropTypes.string, vectors: PropTypes.object.isRequired, loggingFoo: PropTypes.func, @@ -319,4 +328,4 @@ SearchQualityPannel.propTypes = { other: PropTypes.object, }; -export default SearchQualityPannel; +export default SearchQualityPanel; diff --git a/src/components/Collections/SearchQuality/check-index-precision.js b/src/components/Collections/SearchQuality/check-index-precision.js index 85a6ad5d..2208269d 100644 --- a/src/components/Collections/SearchQuality/check-index-precision.js +++ b/src/components/Collections/SearchQuality/check-index-precision.js @@ -8,10 +8,9 @@ export const checkIndexPrecision = async ( filter = null, params = null, vectorName = null, - limit = 10 + limit = 10, + timeout = 20 ) => { - const TIMEOUT = 20; - try { const exactSearchtartTime = new Date().getTime(); @@ -25,7 +24,7 @@ export const checkIndexPrecision = async ( }, filter: filter, using: vectorName, - timeout: TIMEOUT, + timeout, }); const exactSearchElapsed = new Date().getTime() - exactSearchtartTime; @@ -33,7 +32,7 @@ export const checkIndexPrecision = async ( const searchStartTime = new Date().getTime(); const hnsw = await client.query(collectionName, { - timeout: TIMEOUT, + timeout, limit: limit, with_payload: false, with_vectors: false, diff --git a/src/components/EditorCommon/index.jsx b/src/components/EditorCommon/index.jsx index 1721cf61..4df8d1eb 100644 --- a/src/components/EditorCommon/index.jsx +++ b/src/components/EditorCommon/index.jsx @@ -73,7 +73,7 @@ const EditorCommon = ({ beforeMount, customHeight, ...props }) => { EditorCommon.propTypes = { height: PropTypes.string, beforeMount: PropTypes.func, - customHeight: PropTypes.number, + customHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), ...Editor.propTypes, }; diff --git a/src/components/FilterEditorWindow/index.jsx b/src/components/FilterEditorWindow/index.jsx index 062a8afc..89044508 100644 --- a/src/components/FilterEditorWindow/index.jsx +++ b/src/components/FilterEditorWindow/index.jsx @@ -118,6 +118,6 @@ CodeEditorWindow.propTypes = { code: PropTypes.string.isRequired, onChangeResult: PropTypes.func.isRequired, customRequestSchema: PropTypes.func.isRequired, - customHeight: PropTypes.number, + customHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), }; export default CodeEditorWindow;