Make the feature experimental

This commit is contained in:
Kerollmops 2025-02-10 15:02:03 +01:00
parent 491d115c3c
commit 7d0d8f4445
No known key found for this signature in database
GPG Key ID: F250A4C4E3AE5F5F
7 changed files with 49 additions and 9 deletions

View File

@ -105,6 +105,19 @@ impl RoFeatures {
.into()) .into())
} }
} }
pub fn check_get_task_documents_route(&self) -> Result<()> {
if self.runtime.get_task_documents_route {
Ok(())
} else {
Err(FeatureNotEnabledError {
disabled_action: "Getting the documents of an enqueued task",
feature: "get task documents route",
issue_link: "https://github.com/orgs/meilisearch/discussions/808",
}
.into())
}
}
} }
impl FeatureData { impl FeatureData {

View File

@ -10,6 +10,7 @@ pub struct RuntimeTogglableFeatures {
pub edit_documents_by_function: bool, pub edit_documents_by_function: bool,
pub contains_filter: bool, pub contains_filter: bool,
pub network: bool, pub network: bool,
pub get_task_documents_route: bool,
} }
#[derive(Default, Debug, Clone, Copy)] #[derive(Default, Debug, Clone, Copy)]

View File

@ -197,6 +197,7 @@ struct Infos {
experimental_max_number_of_batched_tasks: usize, experimental_max_number_of_batched_tasks: usize,
experimental_limit_batched_tasks_total_size: u64, experimental_limit_batched_tasks_total_size: u64,
experimental_network: bool, experimental_network: bool,
experimental_get_task_documents_route: bool,
gpu_enabled: bool, gpu_enabled: bool,
db_path: bool, db_path: bool,
import_dump: bool, import_dump: bool,
@ -288,6 +289,7 @@ impl Infos {
edit_documents_by_function, edit_documents_by_function,
contains_filter, contains_filter,
network, network,
get_task_documents_route,
} = features; } = features;
// We're going to override every sensible information. // We're going to override every sensible information.
@ -306,6 +308,7 @@ impl Infos {
experimental_enable_logs_route: experimental_enable_logs_route | logs_route, experimental_enable_logs_route: experimental_enable_logs_route | logs_route,
experimental_reduce_indexing_memory_usage, experimental_reduce_indexing_memory_usage,
experimental_network: network, experimental_network: network,
experimental_get_task_documents_route: get_task_documents_route,
gpu_enabled: meilisearch_types::milli::vector::is_cuda_enabled(), gpu_enabled: meilisearch_types::milli::vector::is_cuda_enabled(),
db_path: db_path != PathBuf::from("./data.ms"), db_path: db_path != PathBuf::from("./data.ms"),
import_dump: import_dump.is_some(), import_dump: import_dump.is_some(),

View File

@ -51,6 +51,7 @@ pub fn configure(cfg: &mut web::ServiceConfig) {
edit_documents_by_function: Some(false), edit_documents_by_function: Some(false),
contains_filter: Some(false), contains_filter: Some(false),
network: Some(false), network: Some(false),
get_task_documents_route: Some(false),
})), })),
(status = 401, description = "The authorization header is missing", body = ResponseError, content_type = "application/json", example = json!( (status = 401, description = "The authorization header is missing", body = ResponseError, content_type = "application/json", example = json!(
{ {
@ -91,6 +92,8 @@ pub struct RuntimeTogglableFeatures {
pub contains_filter: Option<bool>, pub contains_filter: Option<bool>,
#[deserr(default)] #[deserr(default)]
pub network: Option<bool>, pub network: Option<bool>,
#[deserr(default)]
pub get_task_documents_route: Option<bool>,
} }
impl From<meilisearch_types::features::RuntimeTogglableFeatures> for RuntimeTogglableFeatures { impl From<meilisearch_types::features::RuntimeTogglableFeatures> for RuntimeTogglableFeatures {
@ -101,6 +104,7 @@ impl From<meilisearch_types::features::RuntimeTogglableFeatures> for RuntimeTogg
edit_documents_by_function, edit_documents_by_function,
contains_filter, contains_filter,
network, network,
get_task_documents_route,
} = value; } = value;
Self { Self {
@ -109,6 +113,7 @@ impl From<meilisearch_types::features::RuntimeTogglableFeatures> for RuntimeTogg
edit_documents_by_function: Some(edit_documents_by_function), edit_documents_by_function: Some(edit_documents_by_function),
contains_filter: Some(contains_filter), contains_filter: Some(contains_filter),
network: Some(network), network: Some(network),
get_task_documents_route: Some(get_task_documents_route),
} }
} }
} }
@ -120,6 +125,7 @@ pub struct PatchExperimentalFeatureAnalytics {
edit_documents_by_function: bool, edit_documents_by_function: bool,
contains_filter: bool, contains_filter: bool,
network: bool, network: bool,
get_task_documents_route: bool,
} }
impl Aggregate for PatchExperimentalFeatureAnalytics { impl Aggregate for PatchExperimentalFeatureAnalytics {
@ -134,6 +140,7 @@ impl Aggregate for PatchExperimentalFeatureAnalytics {
edit_documents_by_function: new.edit_documents_by_function, edit_documents_by_function: new.edit_documents_by_function,
contains_filter: new.contains_filter, contains_filter: new.contains_filter,
network: new.network, network: new.network,
get_task_documents_route: new.get_task_documents_route,
}) })
} }
@ -157,6 +164,7 @@ impl Aggregate for PatchExperimentalFeatureAnalytics {
edit_documents_by_function: Some(false), edit_documents_by_function: Some(false),
contains_filter: Some(false), contains_filter: Some(false),
network: Some(false), network: Some(false),
get_task_documents_route: Some(false),
})), })),
(status = 401, description = "The authorization header is missing", body = ResponseError, content_type = "application/json", example = json!( (status = 401, description = "The authorization header is missing", body = ResponseError, content_type = "application/json", example = json!(
{ {
@ -190,6 +198,10 @@ async fn patch_features(
.unwrap_or(old_features.edit_documents_by_function), .unwrap_or(old_features.edit_documents_by_function),
contains_filter: new_features.0.contains_filter.unwrap_or(old_features.contains_filter), contains_filter: new_features.0.contains_filter.unwrap_or(old_features.contains_filter),
network: new_features.0.network.unwrap_or(old_features.network), network: new_features.0.network.unwrap_or(old_features.network),
get_task_documents_route: new_features
.0
.get_task_documents_route
.unwrap_or(old_features.get_task_documents_route),
}; };
// explicitly destructure for analytics rather than using the `Serialize` implementation, because // explicitly destructure for analytics rather than using the `Serialize` implementation, because
@ -201,6 +213,7 @@ async fn patch_features(
edit_documents_by_function, edit_documents_by_function,
contains_filter, contains_filter,
network, network,
get_task_documents_route,
} = new_features; } = new_features;
analytics.publish( analytics.publish(
@ -210,6 +223,7 @@ async fn patch_features(
edit_documents_by_function, edit_documents_by_function,
contains_filter, contains_filter,
network, network,
get_task_documents_route,
}, },
&req, &req,
); );

View File

@ -679,6 +679,7 @@ async fn get_task_documents_file(
index_scheduler: GuardedData<ActionPolicy<{ actions::TASKS_GET }>, Data<IndexScheduler>>, index_scheduler: GuardedData<ActionPolicy<{ actions::TASKS_GET }>, Data<IndexScheduler>>,
task_uid: web::Path<String>, task_uid: web::Path<String>,
) -> Result<HttpResponse, ResponseError> { ) -> Result<HttpResponse, ResponseError> {
index_scheduler.features().check_get_task_documents_route()?;
let task_uid_string = task_uid.into_inner(); let task_uid_string = task_uid.into_inner();
let task_uid: TaskId = match task_uid_string.parse() { let task_uid: TaskId = match task_uid_string.parse() {

View File

@ -1909,7 +1909,8 @@ async fn import_dump_v6_containing_experimental_features() {
"logsRoute": false, "logsRoute": false,
"editDocumentsByFunction": false, "editDocumentsByFunction": false,
"containsFilter": false, "containsFilter": false,
"network": false "network": false,
"getTaskDocumentsRoute": false
} }
"###); "###);
@ -2071,7 +2072,8 @@ async fn generate_and_import_dump_containing_vectors() {
"logsRoute": false, "logsRoute": false,
"editDocumentsByFunction": false, "editDocumentsByFunction": false,
"containsFilter": false, "containsFilter": false,
"network": false "network": false,
"getTaskDocumentsRoute": false
} }
"###); "###);

View File

@ -22,7 +22,8 @@ async fn experimental_features() {
"logsRoute": false, "logsRoute": false,
"editDocumentsByFunction": false, "editDocumentsByFunction": false,
"containsFilter": false, "containsFilter": false,
"network": false "network": false,
"getTaskDocumentsRoute": false
} }
"###); "###);
@ -35,7 +36,8 @@ async fn experimental_features() {
"logsRoute": false, "logsRoute": false,
"editDocumentsByFunction": false, "editDocumentsByFunction": false,
"containsFilter": false, "containsFilter": false,
"network": false "network": false,
"getTaskDocumentsRoute": false
} }
"###); "###);
@ -48,7 +50,8 @@ async fn experimental_features() {
"logsRoute": false, "logsRoute": false,
"editDocumentsByFunction": false, "editDocumentsByFunction": false,
"containsFilter": false, "containsFilter": false,
"network": false "network": false,
"getTaskDocumentsRoute": false
} }
"###); "###);
@ -62,7 +65,8 @@ async fn experimental_features() {
"logsRoute": false, "logsRoute": false,
"editDocumentsByFunction": false, "editDocumentsByFunction": false,
"containsFilter": false, "containsFilter": false,
"network": false "network": false,
"getTaskDocumentsRoute": false
} }
"###); "###);
@ -76,7 +80,8 @@ async fn experimental_features() {
"logsRoute": false, "logsRoute": false,
"editDocumentsByFunction": false, "editDocumentsByFunction": false,
"containsFilter": false, "containsFilter": false,
"network": false "network": false,
"getTaskDocumentsRoute": false
} }
"###); "###);
} }
@ -97,7 +102,8 @@ async fn experimental_feature_metrics() {
"logsRoute": false, "logsRoute": false,
"editDocumentsByFunction": false, "editDocumentsByFunction": false,
"containsFilter": false, "containsFilter": false,
"network": false "network": false,
"getTaskDocumentsRoute": false
} }
"###); "###);
@ -152,7 +158,7 @@ async fn errors() {
meili_snap::snapshot!(code, @"400 Bad Request"); meili_snap::snapshot!(code, @"400 Bad Request");
meili_snap::snapshot!(meili_snap::json_string!(response), @r###" meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
{ {
"message": "Unknown field `NotAFeature`: expected one of `metrics`, `logsRoute`, `editDocumentsByFunction`, `containsFilter`, `network`", "message": "Unknown field `NotAFeature`: expected one of `metrics`, `logsRoute`, `editDocumentsByFunction`, `containsFilter`, `network`, `getTaskDocumentsRoute`",
"code": "bad_request", "code": "bad_request",
"type": "invalid_request", "type": "invalid_request",
"link": "https://docs.meilisearch.com/errors#bad_request" "link": "https://docs.meilisearch.com/errors#bad_request"