mirror of
https://github.com/qdrant/qdrant.git
synced 2026-08-04 00:51:06 -05:00
Add pyo3 signature annotations with default values for all Py* structs (#7891)
* Add pyo3 signature annotations with default values for all Py* structs - Added #[pyo3(signature = (...))] attributes to all Py* structs with optional parameters - Ensured non-default parameters come before parameters with defaults - Follows the pattern established in PyScrollRequest - Updated structs: PySearchRequest, PySearchParams, PyQuantizationSearchParams, PyAcornSearchParams, PyQueryRequest, PyPrefetch, PyOrderBy, PyMmr, PyPoint, PyFormula, PyShard::load, PySparseVectorDataConfig, PySparseIndexConfig * fix params ordering
This commit is contained in:
committed by
generall
parent
93d866f18c
commit
8cdc8dea94
@@ -36,6 +36,7 @@ impl PySparseVectorDataConfig {
|
||||
#[pymethods]
|
||||
impl PySparseVectorDataConfig {
|
||||
#[new]
|
||||
#[pyo3(signature = (index, storage_type, modifier = None))]
|
||||
pub fn new(
|
||||
index: PySparseIndexConfig,
|
||||
storage_type: PySparseVectorStorageType,
|
||||
@@ -98,14 +99,15 @@ pub struct PySparseIndexConfig(SparseIndexConfig);
|
||||
#[pymethods]
|
||||
impl PySparseIndexConfig {
|
||||
#[new]
|
||||
#[pyo3(signature = (index_type, full_scan_threshold = None, datatype = None))]
|
||||
pub fn new(
|
||||
full_scan_threshold: Option<usize>,
|
||||
index_type: PySparseIndexType,
|
||||
full_scan_threshold: Option<usize>,
|
||||
datatype: Option<PyVectorStorageDatatype>,
|
||||
) -> Self {
|
||||
Self(SparseIndexConfig {
|
||||
full_scan_threshold,
|
||||
index_type: SparseIndexType::from(index_type),
|
||||
full_scan_threshold,
|
||||
datatype: datatype.map(VectorStorageDatatype::from),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@ pub struct PyShard(Option<edge::Shard>);
|
||||
#[pymethods]
|
||||
impl PyShard {
|
||||
#[new]
|
||||
#[pyo3(signature = (path, config = None))]
|
||||
pub fn load(path: PathBuf, config: Option<PySegmentConfig>) -> Result<Self> {
|
||||
let shard = edge::Shard::load(&path, config.map(SegmentConfig::from))?;
|
||||
Ok(Self(Some(shard)))
|
||||
|
||||
@@ -25,28 +25,41 @@ pub struct PyQueryRequest(ShardQueryRequest);
|
||||
#[pymethods]
|
||||
impl PyQueryRequest {
|
||||
#[new]
|
||||
#[pyo3(signature = (
|
||||
limit,
|
||||
offset = None,
|
||||
query = None,
|
||||
prefetches = None,
|
||||
with_vector = None,
|
||||
with_payload = None,
|
||||
filter = None,
|
||||
score_threshold = None,
|
||||
params = None,
|
||||
))]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
prefetches: Vec<PyPrefetch>,
|
||||
limit: usize,
|
||||
offset: Option<usize>,
|
||||
query: Option<PyScoringQuery>,
|
||||
prefetches: Option<Vec<PyPrefetch>>,
|
||||
with_vector: Option<PyWithVector>,
|
||||
with_payload: Option<PyWithPayload>,
|
||||
filter: Option<PyFilter>,
|
||||
score_threshold: Option<f32>,
|
||||
limit: usize,
|
||||
offset: usize,
|
||||
params: Option<PySearchParams>,
|
||||
with_vector: PyWithVector,
|
||||
with_payload: PyWithPayload,
|
||||
) -> Self {
|
||||
Self(ShardQueryRequest {
|
||||
prefetches: PyPrefetch::peel_vec(prefetches),
|
||||
prefetches: PyPrefetch::peel_vec(prefetches.unwrap_or_default()),
|
||||
limit,
|
||||
offset: offset.unwrap_or(0),
|
||||
with_vector: with_vector.map(WithVector::from).unwrap_or_default(),
|
||||
with_payload: with_payload
|
||||
.map(WithPayloadInterface::from)
|
||||
.unwrap_or_default(),
|
||||
query: query.map(ScoringQuery::from),
|
||||
filter: filter.map(Filter::from),
|
||||
score_threshold: score_threshold.map(OrderedFloat),
|
||||
limit,
|
||||
offset,
|
||||
params: params.map(SearchParams::from),
|
||||
with_vector: WithVector::from(with_vector),
|
||||
with_payload: WithPayloadInterface::from(with_payload),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -128,18 +141,26 @@ pub struct PyPrefetch(ShardPrefetch);
|
||||
#[pymethods]
|
||||
impl PyPrefetch {
|
||||
#[new]
|
||||
#[pyo3(signature = (
|
||||
limit,
|
||||
query = None,
|
||||
prefetches = None,
|
||||
params = None,
|
||||
filter = None,
|
||||
score_threshold = None,
|
||||
))]
|
||||
pub fn new(
|
||||
prefetches: Vec<PyPrefetch>,
|
||||
query: Option<PyScoringQuery>,
|
||||
limit: usize,
|
||||
query: Option<PyScoringQuery>,
|
||||
prefetches: Option<Vec<PyPrefetch>>,
|
||||
params: Option<PySearchParams>,
|
||||
filter: Option<PyFilter>,
|
||||
score_threshold: Option<f32>,
|
||||
) -> Self {
|
||||
Self(ShardPrefetch {
|
||||
prefetches: PyPrefetch::peel_vec(prefetches),
|
||||
query: query.map(ScoringQuery::from),
|
||||
prefetches: PyPrefetch::peel_vec(prefetches.unwrap_or_default()),
|
||||
limit,
|
||||
query: query.map(ScoringQuery::from),
|
||||
params: params.map(SearchParams::from),
|
||||
filter: filter.map(Filter::from),
|
||||
score_threshold: score_threshold.map(OrderedFloat),
|
||||
@@ -341,6 +362,7 @@ pub struct PyOrderBy(OrderBy);
|
||||
#[pymethods]
|
||||
impl PyOrderBy {
|
||||
#[new]
|
||||
#[pyo3(signature = (key, direction = None, start_from = None))]
|
||||
pub fn new(
|
||||
key: PyJsonPath,
|
||||
direction: Option<PyDirection>,
|
||||
@@ -561,11 +583,12 @@ pub struct PyMmr(MmrInternal);
|
||||
#[pymethods]
|
||||
impl PyMmr {
|
||||
#[new]
|
||||
#[pyo3(signature = (vector, lambda, candidates_limit, using = None))]
|
||||
pub fn new(
|
||||
vector: PyNamedVectorInternal,
|
||||
using: Option<String>,
|
||||
lambda: f32,
|
||||
candidates_limit: usize,
|
||||
using: Option<String>,
|
||||
) -> Self {
|
||||
let mmr = MmrInternal {
|
||||
vector: VectorInternal::from(vector),
|
||||
|
||||
@@ -16,23 +16,33 @@ pub struct PySearchRequest(CoreSearchRequest);
|
||||
#[pymethods]
|
||||
impl PySearchRequest {
|
||||
#[new]
|
||||
#[pyo3(signature = (
|
||||
query,
|
||||
limit,
|
||||
offset = None,
|
||||
filter = None,
|
||||
params = None,
|
||||
with_vector = None,
|
||||
with_payload = None,
|
||||
score_threshold = None,
|
||||
))]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
query: PyQuery,
|
||||
limit: usize,
|
||||
offset: Option<usize>,
|
||||
filter: Option<PyFilter>,
|
||||
params: Option<PySearchParams>,
|
||||
limit: usize,
|
||||
offset: usize,
|
||||
with_vector: Option<PyWithVector>,
|
||||
with_payload: Option<PyWithPayload>,
|
||||
score_threshold: Option<f32>,
|
||||
) -> Self {
|
||||
Self(CoreSearchRequest {
|
||||
query: QueryEnum::from(query),
|
||||
limit,
|
||||
offset: offset.unwrap_or(0),
|
||||
filter: filter.map(Filter::from),
|
||||
params: params.map(SearchParams::from),
|
||||
limit,
|
||||
offset,
|
||||
with_vector: with_vector.map(WithVector::from),
|
||||
with_payload: with_payload.map(WithPayloadInterface::from),
|
||||
score_threshold,
|
||||
@@ -108,6 +118,13 @@ pub struct PySearchParams(pub SearchParams);
|
||||
#[pymethods]
|
||||
impl PySearchParams {
|
||||
#[new]
|
||||
#[pyo3(signature = (
|
||||
hnsw_ef = None,
|
||||
exact = false,
|
||||
quantization = None,
|
||||
indexed_only = false,
|
||||
acorn = None,
|
||||
))]
|
||||
pub fn new(
|
||||
hnsw_ef: Option<usize>,
|
||||
exact: bool,
|
||||
@@ -175,6 +192,7 @@ pub struct PyQuantizationSearchParams(QuantizationSearchParams);
|
||||
#[pymethods]
|
||||
impl PyQuantizationSearchParams {
|
||||
#[new]
|
||||
#[pyo3(signature = (ignore = false, rescore = None, oversampling = None))]
|
||||
pub fn new(ignore: bool, rescore: Option<bool>, oversampling: Option<f64>) -> Self {
|
||||
Self(QuantizationSearchParams {
|
||||
ignore,
|
||||
@@ -222,6 +240,7 @@ pub struct PyAcornSearchParams(AcornSearchParams);
|
||||
#[pymethods]
|
||||
impl PyAcornSearchParams {
|
||||
#[new]
|
||||
#[pyo3(signature = (enable = false, max_selectivity = None))]
|
||||
pub fn new(enable: bool, max_selectivity: Option<f64>) -> Self {
|
||||
Self(AcornSearchParams {
|
||||
enable,
|
||||
|
||||
@@ -27,10 +27,14 @@ pub struct PyFormula(pub ParsedFormula);
|
||||
#[pymethods]
|
||||
impl PyFormula {
|
||||
#[new]
|
||||
pub fn new(formula: PyExpression, defaults: HashMap<String, PyValue>) -> PyResult<Self> {
|
||||
#[pyo3(signature = (formula, defaults = None))]
|
||||
pub fn new(
|
||||
formula: PyExpression,
|
||||
defaults: Option<HashMap<String, PyValue>>,
|
||||
) -> PyResult<Self> {
|
||||
let formula = FormulaInternal {
|
||||
formula: ExpressionInternal::from(formula),
|
||||
defaults: PyValue::peel_map(defaults),
|
||||
defaults: PyValue::peel_map(defaults.unwrap_or_default()),
|
||||
};
|
||||
|
||||
let formula = ParsedFormula::try_from(formula)
|
||||
|
||||
@@ -16,6 +16,7 @@ pub struct PyPoint(PointStructPersisted);
|
||||
#[pymethods]
|
||||
impl PyPoint {
|
||||
#[new]
|
||||
#[pyo3(signature = (id, vector, payload = None))]
|
||||
pub fn new(id: PyPointId, vector: PyVector, payload: Option<PyPayload>) -> Self {
|
||||
let point = PointStructPersisted {
|
||||
id: PointIdType::from(id),
|
||||
|
||||
Reference in New Issue
Block a user