mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-01 17:00:21 +08:00
Remove ranked minimal selection compatibility helper
This commit is contained in:
@@ -4,8 +4,8 @@ use aether_scheduler_core::{
|
||||
auth_constraints_allow_api_format, collect_global_model_names_for_required_capability,
|
||||
enumerate_minimal_candidate_selection, normalize_api_format,
|
||||
resolve_requested_global_model_name, row_supports_requested_model,
|
||||
BuildMinimalCandidateSelectionInput, SchedulerAuthConstraints,
|
||||
SchedulerMinimalCandidateSelectionCandidate, SchedulerPriorityMode,
|
||||
EnumerateMinimalCandidateSelectionInput, SchedulerAuthConstraints,
|
||||
SchedulerMinimalCandidateSelectionCandidate,
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
use std::collections::BTreeSet;
|
||||
@@ -77,7 +77,7 @@ pub(crate) async fn enumerate_minimal_candidate_selection_with_required_capabili
|
||||
return Ok(Vec::new());
|
||||
};
|
||||
let auth_constraints = auth_snapshot.map(auth_snapshot_constraints);
|
||||
enumerate_minimal_candidate_selection(BuildMinimalCandidateSelectionInput {
|
||||
enumerate_minimal_candidate_selection(EnumerateMinimalCandidateSelectionInput {
|
||||
rows,
|
||||
normalized_api_format: &normalized_api_format,
|
||||
requested_model_name,
|
||||
@@ -85,8 +85,6 @@ pub(crate) async fn enumerate_minimal_candidate_selection_with_required_capabili
|
||||
require_streaming,
|
||||
required_capabilities,
|
||||
auth_constraints: auth_constraints.as_ref(),
|
||||
affinity_key: None,
|
||||
priority_mode: SchedulerPriorityMode::Provider,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -172,12 +170,6 @@ pub(crate) async fn read_global_model_names_for_api_format(
|
||||
Ok(model_names.into_iter().collect())
|
||||
}
|
||||
|
||||
fn auth_snapshot_affinity_key(auth_snapshot: Option<&GatewayAuthApiKeySnapshot>) -> Option<&str> {
|
||||
auth_snapshot
|
||||
.map(|snapshot| snapshot.api_key_id.trim())
|
||||
.filter(|value| !value.is_empty())
|
||||
}
|
||||
|
||||
fn auth_snapshot_constraints(snapshot: &GatewayAuthApiKeySnapshot) -> SchedulerAuthConstraints {
|
||||
SchedulerAuthConstraints {
|
||||
allowed_providers: snapshot
|
||||
|
||||
@@ -24,8 +24,8 @@ use aether_data_contracts::repository::video_tasks::{
|
||||
UpsertVideoTask, VideoTaskLookupKey, VideoTaskStatus, VideoTaskWriteRepository,
|
||||
};
|
||||
use aether_scheduler_core::{
|
||||
build_ranked_minimal_candidate_selection, BuildMinimalCandidateSelectionInput,
|
||||
SchedulerAuthConstraints, SchedulerPriorityMode,
|
||||
enumerate_minimal_candidate_selection, EnumerateMinimalCandidateSelectionInput,
|
||||
SchedulerAuthConstraints,
|
||||
};
|
||||
use serde_json::json;
|
||||
|
||||
@@ -622,18 +622,17 @@ async fn data_state_reads_minimal_candidate_selection_with_auth_filters() {
|
||||
.map(|items| items.to_vec()),
|
||||
};
|
||||
|
||||
let selection = build_ranked_minimal_candidate_selection(BuildMinimalCandidateSelectionInput {
|
||||
rows,
|
||||
normalized_api_format: "openai:chat",
|
||||
requested_model_name: "gpt-4.1",
|
||||
resolved_global_model_name: "gpt-4.1",
|
||||
require_streaming: false,
|
||||
required_capabilities: None,
|
||||
auth_constraints: Some(&auth_constraints),
|
||||
affinity_key: Some(auth_snapshot.api_key_id.as_str()),
|
||||
priority_mode: SchedulerPriorityMode::Provider,
|
||||
})
|
||||
.expect("selection should read");
|
||||
let selection =
|
||||
enumerate_minimal_candidate_selection(EnumerateMinimalCandidateSelectionInput {
|
||||
rows,
|
||||
normalized_api_format: "openai:chat",
|
||||
requested_model_name: "gpt-4.1",
|
||||
resolved_global_model_name: "gpt-4.1",
|
||||
require_streaming: false,
|
||||
required_capabilities: None,
|
||||
auth_constraints: Some(&auth_constraints),
|
||||
})
|
||||
.expect("selection should read");
|
||||
|
||||
assert_eq!(selection.len(), 2);
|
||||
assert_eq!(selection[0].provider_id, "provider-1");
|
||||
|
||||
@@ -10,8 +10,10 @@ use aether_data_contracts::repository::candidates::{
|
||||
RequestCandidateStatus, StoredRequestCandidate,
|
||||
};
|
||||
use aether_scheduler_core::{
|
||||
build_ranked_minimal_candidate_selection, BuildMinimalCandidateSelectionInput,
|
||||
SchedulerMinimalCandidateSelectionCandidate, SchedulerPriorityMode,
|
||||
apply_scheduler_candidate_ranking, enumerate_minimal_candidate_selection,
|
||||
EnumerateMinimalCandidateSelectionInput, SchedulerMinimalCandidateSelectionCandidate,
|
||||
SchedulerPriorityMode, SchedulerRankableCandidate, SchedulerRankingContext,
|
||||
SchedulerRankingMode,
|
||||
};
|
||||
|
||||
use crate::cache::SchedulerAffinityTarget;
|
||||
@@ -94,18 +96,36 @@ async fn same_priority_candidates_are_distributed_by_affinity_key() {
|
||||
.await
|
||||
.expect("selection rows should read")
|
||||
.expect("selection rows should match requested model");
|
||||
let selection = build_ranked_minimal_candidate_selection(BuildMinimalCandidateSelectionInput {
|
||||
rows,
|
||||
normalized_api_format: "openai:chat",
|
||||
requested_model_name: "gpt-4.1",
|
||||
resolved_global_model_name: "gpt-4.1",
|
||||
require_streaming: false,
|
||||
required_capabilities: None,
|
||||
auth_constraints: None,
|
||||
affinity_key: Some(auth_snapshot.api_key_id.as_str()),
|
||||
priority_mode: SchedulerPriorityMode::Provider,
|
||||
})
|
||||
.expect("selection should succeed");
|
||||
let mut selection =
|
||||
enumerate_minimal_candidate_selection(EnumerateMinimalCandidateSelectionInput {
|
||||
rows,
|
||||
normalized_api_format: "openai:chat",
|
||||
requested_model_name: "gpt-4.1",
|
||||
resolved_global_model_name: "gpt-4.1",
|
||||
require_streaming: false,
|
||||
required_capabilities: None,
|
||||
auth_constraints: None,
|
||||
})
|
||||
.expect("selection should succeed");
|
||||
let rankables = selection
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(index, candidate)| {
|
||||
SchedulerRankableCandidate::from_candidate(candidate, index).with_affinity_hash(Some(
|
||||
candidate_affinity_hash(auth_snapshot.api_key_id.as_str(), candidate),
|
||||
))
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
apply_scheduler_candidate_ranking(
|
||||
&mut selection,
|
||||
&rankables,
|
||||
SchedulerRankingContext {
|
||||
priority_mode: SchedulerPriorityMode::Provider,
|
||||
ranking_mode: SchedulerRankingMode::CacheAffinity,
|
||||
include_health: false,
|
||||
load_balance_seed: 0,
|
||||
},
|
||||
);
|
||||
|
||||
assert_eq!(selection.len(), 2);
|
||||
|
||||
|
||||
@@ -481,30 +481,9 @@ fn scheduler_candidate_runtime_paths_depend_on_scheduler_core_and_state_trait()
|
||||
}
|
||||
|
||||
assert!(
|
||||
workspace_file_exists("crates/aether-scheduler-core/src/candidate/selection.rs"),
|
||||
"core candidate/selection.rs should host legacy minimal selection compatibility helper"
|
||||
!workspace_file_exists("crates/aether-scheduler-core/src/candidate/selection.rs"),
|
||||
"core candidate/selection.rs compatibility helper should be removed"
|
||||
);
|
||||
let core_candidate_selection =
|
||||
read_workspace_file("crates/aether-scheduler-core/src/candidate/selection.rs");
|
||||
for expected in [
|
||||
"build_ranked_minimal_candidate_selection",
|
||||
"apply_scheduler_candidate_ranking",
|
||||
] {
|
||||
assert!(
|
||||
core_candidate_selection.contains(expected),
|
||||
"core candidate/selection.rs should host compatibility helper {expected}"
|
||||
);
|
||||
}
|
||||
for forbidden in [
|
||||
"collect_selectable_candidates_from_keys",
|
||||
"reorder_candidates_by_scheduler_health",
|
||||
"compare_candidates_by_priority_mode",
|
||||
] {
|
||||
assert!(
|
||||
!core_candidate_selection.contains(forbidden),
|
||||
"core candidate/selection.rs should not keep removed legacy helper {forbidden}"
|
||||
);
|
||||
}
|
||||
|
||||
let affinity_cache = read_workspace_file("apps/aether-gateway/src/cache/scheduler_affinity.rs");
|
||||
assert!(
|
||||
|
||||
Reference in New Issue
Block a user