Merge claude/arch-names-high: names, explicit imports and env readers of the engine, gateway and deploy side (STRA-338 debt c)
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
"allow-unused-imports:leleka-cpu-sys": 48,
|
||||
"allow-unused-imports:leleka-cuda-driver": 863,
|
||||
"allow-unused-imports:leleka-engine-core": 18,
|
||||
"allow-unused-imports:leleka-engine-qwen35-cuda": 396,
|
||||
"allow-unused-imports:leleka-engine-qwen35-cuda": 224,
|
||||
"allow-unused-imports:leleka-experimental-ref": 1,
|
||||
"allow-unused-imports:leleka-gateway-text": 4,
|
||||
"allow-unused-imports:leleka-gguf": 5,
|
||||
@@ -23,7 +23,7 @@
|
||||
"allow-unused-imports:leleka-openvino": 5,
|
||||
"allow-unused-imports:leleka-runtime-client": 3,
|
||||
"allow-unused-imports:leleka-tokenizer": 3,
|
||||
"allow-unused-imports:strata-control": 63,
|
||||
"allow-unused-imports:strata-control": 48,
|
||||
"allow-unused-imports:strata-desktop-core": 9,
|
||||
"dyn-trait:leleka-backend-api": 1,
|
||||
"dyn-trait:leleka-cpu-worker": 4,
|
||||
@@ -65,15 +65,14 @@
|
||||
"env-read:leleka-npu-worker": 1,
|
||||
"env-read:leleka-obs": 2,
|
||||
"env-read:leleka-tokenizer": 2,
|
||||
"env-read:strata-control": 19,
|
||||
"env-read:strata-desktop-core": 15,
|
||||
"env-read:strata-control": 14,
|
||||
"env-read:strata-desktop-core": 13,
|
||||
"glob-super-import:leleka-cpu-kernels": 2,
|
||||
"glob-super-import:leleka-cpu-sys": 13,
|
||||
"glob-super-import:leleka-cpu-worker": 1,
|
||||
"glob-super-import:leleka-cuda-driver": 571,
|
||||
"glob-super-import:leleka-deploy": 79,
|
||||
"glob-super-import:leleka-engine-qwen35-cuda": 328,
|
||||
"glob-super-import:leleka-gateway-domain": 2,
|
||||
"glob-super-import:leleka-deploy": 15,
|
||||
"glob-super-import:leleka-engine-qwen35-cuda": 70,
|
||||
"glob-super-import:leleka-gguf": 5,
|
||||
"glob-super-import:leleka-gptoss": 17,
|
||||
"glob-super-import:leleka-gptoss-igpu": 2,
|
||||
@@ -85,8 +84,8 @@
|
||||
"glob-super-import:leleka-native-cpu-expert": 15,
|
||||
"glob-super-import:leleka-openvino": 5,
|
||||
"glob-super-import:leleka-tokenizer": 1,
|
||||
"glob-super-import:strata-control": 37,
|
||||
"glob-super-import:strata-desktop-core": 16,
|
||||
"glob-super-import:strata-control": 9,
|
||||
"glob-super-import:strata-desktop-core": 12,
|
||||
"instant-now:leleka-backend-api": 2,
|
||||
"instant-now:leleka-cpu-worker": 9,
|
||||
"instant-now:leleka-cuda-driver": 25,
|
||||
|
||||
@@ -168,6 +168,6 @@ pub use control_vector::*;
|
||||
mod methods;
|
||||
#[allow(unused_imports)]
|
||||
pub use methods::*;
|
||||
mod optional_env;
|
||||
mod process_env;
|
||||
#[allow(unused_imports)]
|
||||
pub use optional_env::*;
|
||||
pub use process_env::*;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
//! The methods of `Config`: loading the file and environment, provisioning assets, host checks.
|
||||
|
||||
use super::{
|
||||
Config, Duration, FileConfig, FileEngine, FileExtraWorker, OsString, Path, PathBuf, SocketAddr, WorkerConfig, env,
|
||||
fs, optional_env,
|
||||
Config, Duration, FileConfig, FileEngine, FileExtraWorker, OsString, Path, PathBuf, SocketAddr, WorkerConfig, fs,
|
||||
optional_env, optional_env_os,
|
||||
};
|
||||
|
||||
mod load;
|
||||
mod load_checks;
|
||||
mod load_engine;
|
||||
mod load_parts;
|
||||
mod config_assembly;
|
||||
mod load_sections;
|
||||
mod load_with_path;
|
||||
mod provision;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//! The stages of `Config::load_with_path` that check one part of the file against the engine section, in the order
|
||||
//! the single function used to run them. Each fails with the same message as before.
|
||||
|
||||
use super::load_parts::{EngineSide, Identity, Surface};
|
||||
use super::{Config, FileConfig, Path, PathBuf, WorkerConfig, env, fs, optional_env};
|
||||
use super::config_assembly::{EngineSide, Identity, Surface};
|
||||
use super::{Config, FileConfig, Path, PathBuf, WorkerConfig, fs, optional_env, optional_env_os};
|
||||
|
||||
/// The file named by the CLI path or the environment, parsed, with its asset bundles and native model validated.
|
||||
pub(super) fn read_checked_file(
|
||||
@@ -20,7 +20,7 @@ pub(super) fn read_checked_file(
|
||||
fn read_file(path: Option<&Path>) -> Result<(Option<PathBuf>, FileConfig), crate::BoxError> {
|
||||
let config_path = path
|
||||
.map(|p| p.as_os_str().to_owned())
|
||||
.or_else(|| env::var_os("STRATA_CONFIG"))
|
||||
.or_else(|| optional_env_os("STRATA_CONFIG"))
|
||||
.map(PathBuf::from);
|
||||
let file = match &config_path {
|
||||
Some(path) => serde_json::from_str::<FileConfig>(&fs::read_to_string(path)?)?,
|
||||
@@ -39,7 +39,7 @@ fn tokenizer_setting(
|
||||
file: &FileConfig,
|
||||
worker: Option<&WorkerConfig>,
|
||||
) -> Result<Option<PathBuf>, crate::BoxError> {
|
||||
let mut tokenizer_dir = env::var_os("STRATA_TOKENIZER_DIR")
|
||||
let mut tokenizer_dir = optional_env_os("STRATA_TOKENIZER_DIR")
|
||||
.map(PathBuf::from)
|
||||
.or_else(|| {
|
||||
file.engine
|
||||
@@ -96,7 +96,7 @@ fn gptoss_setting(
|
||||
worker: Option<&WorkerConfig>,
|
||||
tokenizer_dir: Option<&PathBuf>,
|
||||
) -> Result<Option<PathBuf>, crate::BoxError> {
|
||||
let gptoss_gguf = env::var_os("STRATA_GPTOSS_GGUF")
|
||||
let gptoss_gguf = optional_env_os("STRATA_GPTOSS_GGUF")
|
||||
.map(PathBuf::from)
|
||||
.or_else(|| {
|
||||
file.engine
|
||||
@@ -176,7 +176,7 @@ fn model_id(from_file: Option<String>) -> Result<Option<String>, crate::BoxError
|
||||
fn api_key_setting(
|
||||
from_file: Option<PathBuf>,
|
||||
) -> Result<Option<std::sync::Arc<crate::auth::ApiKey>>, crate::BoxError> {
|
||||
let key = env::var_os("STRATA_API_KEY_FILE")
|
||||
let key = optional_env_os("STRATA_API_KEY_FILE")
|
||||
.map(PathBuf::from)
|
||||
.or(from_file)
|
||||
.map(|path| crate::auth::ApiKey::from_file(&path).map(std::sync::Arc::new))
|
||||
@@ -186,7 +186,7 @@ fn api_key_setting(
|
||||
|
||||
/// `STRATA_RESPONSE_HISTORY_DIR` or the file's: absolute, not the root, no `..`.
|
||||
fn history_dir_setting(from_file: Option<PathBuf>) -> Result<Option<PathBuf>, crate::BoxError> {
|
||||
let dir = env::var_os("STRATA_RESPONSE_HISTORY_DIR")
|
||||
let dir = optional_env_os("STRATA_RESPONSE_HISTORY_DIR")
|
||||
.map(PathBuf::from)
|
||||
.or(from_file);
|
||||
if dir.as_ref().is_some_and(|p| {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//! same order as when it was one function.
|
||||
|
||||
use super::load_engine as engine;
|
||||
use super::{Config, FileConfig, OsString, Path, SocketAddr, WorkerConfig, env, optional_env};
|
||||
use super::{Config, FileConfig, OsString, Path, SocketAddr, WorkerConfig, optional_env, optional_env_os};
|
||||
|
||||
pub(super) struct Limits {
|
||||
pub(super) bind: SocketAddr,
|
||||
@@ -102,7 +102,7 @@ impl Config {
|
||||
}
|
||||
|
||||
pub(super) fn read_engine(file: &FileConfig) -> Result<EngineSection, crate::BoxError> {
|
||||
let executable = env::var_os("STRATA_ENGINE_EXE").or_else(|| {
|
||||
let executable = optional_env_os("STRATA_ENGINE_EXE").or_else(|| {
|
||||
file.engine
|
||||
.as_ref()
|
||||
.map(|engine| OsString::from(&engine.executable))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! `Config::load_with_path`: the file, the environment, and the cross-checks between the sections.
|
||||
|
||||
use super::load_checks as check;
|
||||
use super::load_parts::CheckedSections;
|
||||
use super::config_assembly::CheckedSections;
|
||||
use super::{Config, Path};
|
||||
|
||||
impl Config {
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
//! Functions: `optional_env`.
|
||||
//! Split out of `config` to keep its files under the line limit.
|
||||
|
||||
use super::env;
|
||||
|
||||
pub(super) fn optional_env(name: &str) -> Result<Option<String>, env::VarError> {
|
||||
match env::var(name) {
|
||||
Ok(value) => Ok(Some(value)),
|
||||
Err(env::VarError::NotPresent) => Ok(None),
|
||||
Err(error) => Err(error),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
//! The only place the run configuration reads the process environment (`STRATA_*`): one reader, so the keys the
|
||||
//! operator can set are all asked here and a test can see where they enter. Separate from `config` for that reason.
|
||||
|
||||
use std::ffi::OsString;
|
||||
|
||||
use super::env;
|
||||
|
||||
/// The value of the variable; `Ok(None)` when it is unset, an error when it is set but not valid Unicode.
|
||||
pub(super) fn optional_env(name: &str) -> Result<Option<String>, env::VarError> {
|
||||
match env::var(name) {
|
||||
Ok(value) => Ok(Some(value)),
|
||||
Err(env::VarError::NotPresent) => Ok(None),
|
||||
Err(error) => Err(error),
|
||||
}
|
||||
}
|
||||
|
||||
/// The value of the variable as an OS string (a path); `None` when it is unset.
|
||||
pub(super) fn optional_env_os(name: &str) -> Option<OsString> {
|
||||
env::var_os(name)
|
||||
}
|
||||
@@ -180,9 +180,9 @@ pub struct Summary {
|
||||
pub provenance_path: PathBuf,
|
||||
}
|
||||
|
||||
mod shared;
|
||||
mod sidecar_and_tensor_locations;
|
||||
#[allow(unused_imports)]
|
||||
pub use shared::*;
|
||||
pub use sidecar_and_tensor_locations::*;
|
||||
mod base_provenance;
|
||||
#[allow(unused_imports)]
|
||||
pub use base_provenance::*;
|
||||
|
||||
@@ -10,11 +10,11 @@ impl BaseProvenance {
|
||||
match (self.schema.as_str(), self.ple_part_elements) {
|
||||
("strata-next/sharded-stream-provenance-v4", None) => true,
|
||||
("strata-next/sharded-stream-provenance-v5", Some(limit)) => {
|
||||
(32..=crate::stream_parts::MAX_PART_ELEMENTS).contains(&limit)
|
||||
(32..=crate::kar_shard_plan::MAX_PART_ELEMENTS).contains(&limit)
|
||||
&& self
|
||||
.partitioned_tensors
|
||||
.iter()
|
||||
.any(|tensor| tensor.parent_name == crate::stream_parts::PLE_TENSOR_NAME)
|
||||
.any(|tensor| tensor.parent_name == crate::kar_shard_plan::PLE_TENSOR_NAME)
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::{
|
||||
derived_mixed, gguf, gguf_f32_stream,
|
||||
kar::{self, VerifiedRangeDecoder},
|
||||
model::Manifest,
|
||||
prepare_preview, stream_parts,
|
||||
prepare_preview, kar_shard_plan,
|
||||
};
|
||||
|
||||
const SAMPLE_ELEMENTS: u64 = 4096;
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
//! Split out of `kar_quality` to keep its files under the line limit.
|
||||
|
||||
use super::{
|
||||
File, Manifest, Path, Report, SourceShards, VerifiedRangeDecoder, derived_mixed, prepare_preview, previous,
|
||||
sample_records, stream_parts,
|
||||
File, Manifest, Path, Report, SourceShards, VerifiedRangeDecoder, derived_mixed, kar_shard_plan, prepare_preview,
|
||||
previous, sample_records,
|
||||
};
|
||||
|
||||
pub fn analyze(
|
||||
@@ -19,7 +19,7 @@ pub fn analyze(
|
||||
if summary.source_digest != identity.derived_sha256 {
|
||||
return Err("KAR source digest changed after verification".into());
|
||||
}
|
||||
let parts = stream_parts::plan_shards(&identity, source_dir)?;
|
||||
let parts = kar_shard_plan::plan_shards(&identity, source_dir)?;
|
||||
let source = SourceShards {
|
||||
dir: source_dir,
|
||||
identity: &identity,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
use super::{
|
||||
File, Path, RecordError, Report, SAMPLE_ELEMENTS, SampleWindow, VerifiedRangeDecoder, Write, derived_mixed, gguf,
|
||||
sample, stream_parts,
|
||||
kar_shard_plan, sample,
|
||||
};
|
||||
|
||||
pub(super) fn parse_digest(value: &str) -> Result<[u8; 32], String> {
|
||||
@@ -18,7 +18,7 @@ pub(super) fn parse_digest(value: &str) -> Result<[u8; 32], String> {
|
||||
pub(super) struct SourceShards<'a> {
|
||||
pub(super) dir: &'a Path,
|
||||
pub(super) identity: &'a derived_mixed::ShardedIdentity,
|
||||
pub(super) parts: &'a [Vec<stream_parts::PartIdentity>],
|
||||
pub(super) parts: &'a [Vec<kar_shard_plan::PartIdentity>],
|
||||
}
|
||||
|
||||
fn sample_all(
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
|
||||
use super::{
|
||||
File, HashMap, Manifest, Path, Provenance, ProvenancePart, ProvenancePartition, ProvenanceShard, ProvenanceTensor,
|
||||
derived_mixed, gguf, kar, parse_digest, stream_parts,
|
||||
derived_mixed, gguf, kar, kar_shard_plan, parse_digest,
|
||||
};
|
||||
use crate::model::ModelFile;
|
||||
|
||||
type Groups = Vec<Vec<stream_parts::PartIdentity>>;
|
||||
type Groups = Vec<Vec<kar_shard_plan::PartIdentity>>;
|
||||
type Partitions<'a> = HashMap<&'a str, &'a ProvenancePartition>;
|
||||
|
||||
/// The recorded provenance with the identity and part layout rebuilt from it and the source shards.
|
||||
@@ -209,8 +209,8 @@ fn check_tensor_metadata(
|
||||
fn recorded_part(
|
||||
tensor: &gguf::TensorInfo,
|
||||
part: &ProvenancePart,
|
||||
) -> Result<stream_parts::PartIdentity, String> {
|
||||
Ok(stream_parts::PartIdentity {
|
||||
) -> Result<kar_shard_plan::PartIdentity, String> {
|
||||
Ok(kar_shard_plan::PartIdentity {
|
||||
name: part.name.clone(),
|
||||
parent_name: tensor.name.clone(),
|
||||
parent_dimensions: tensor.dimensions.clone(),
|
||||
@@ -228,8 +228,8 @@ fn recorded_part(
|
||||
fn whole_part(
|
||||
tensor: &gguf::TensorInfo,
|
||||
recorded: &derived_mixed::TensorIdentity,
|
||||
) -> stream_parts::PartIdentity {
|
||||
stream_parts::PartIdentity {
|
||||
) -> kar_shard_plan::PartIdentity {
|
||||
kar_shard_plan::PartIdentity {
|
||||
name: tensor.name.clone(),
|
||||
parent_name: tensor.name.clone(),
|
||||
parent_dimensions: tensor.dimensions.clone(),
|
||||
@@ -248,7 +248,7 @@ fn part_group(
|
||||
tensor: &gguf::TensorInfo,
|
||||
recorded: &derived_mixed::TensorIdentity,
|
||||
partitioned: &Partitions<'_>,
|
||||
) -> Result<Vec<stream_parts::PartIdentity>, String> {
|
||||
) -> Result<Vec<kar_shard_plan::PartIdentity>, String> {
|
||||
let Some(split) = partitioned.get(tensor.name.as_str()) else {
|
||||
return Ok(vec![whole_part(tensor, recorded)]);
|
||||
};
|
||||
@@ -263,7 +263,7 @@ fn part_group(
|
||||
}
|
||||
|
||||
fn check_group_cover(
|
||||
group: &[stream_parts::PartIdentity],
|
||||
group: &[kar_shard_plan::PartIdentity],
|
||||
tensor: &gguf::TensorInfo,
|
||||
recorded: &derived_mixed::TensorIdentity,
|
||||
) -> Result<(), String> {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Per-part sampling of the original GGUF payload against the KAR reconstruction.
|
||||
|
||||
use super::{
|
||||
File, RecordError, SampleWindow, VerifiedRangeDecoder, gguf, gguf_f32_stream, sample_windows, stream_parts,
|
||||
File, RecordError, SampleWindow, VerifiedRangeDecoder, gguf, gguf_f32_stream, kar_shard_plan, sample_windows,
|
||||
};
|
||||
|
||||
/// Open source shard and archive decoder used while sampling the parts of one shard.
|
||||
@@ -39,7 +39,7 @@ impl Sums {
|
||||
|
||||
fn window_offset(
|
||||
tensor_start: Option<u64>,
|
||||
part: &stream_parts::PartIdentity,
|
||||
part: &kar_shard_plan::PartIdentity,
|
||||
window: &SampleWindow,
|
||||
block: (u64, u64),
|
||||
) -> Result<u64, String> {
|
||||
@@ -52,7 +52,7 @@ fn window_offset(
|
||||
impl Sampler<'_> {
|
||||
fn original(
|
||||
&mut self,
|
||||
part: &stream_parts::PartIdentity,
|
||||
part: &kar_shard_plan::PartIdentity,
|
||||
window: &SampleWindow,
|
||||
absolute: u64,
|
||||
source_bytes: u64,
|
||||
@@ -82,7 +82,7 @@ impl Sampler<'_> {
|
||||
|
||||
fn reconstructed(
|
||||
&mut self,
|
||||
part: &stream_parts::PartIdentity,
|
||||
part: &kar_shard_plan::PartIdentity,
|
||||
window: &SampleWindow,
|
||||
expected_len: usize,
|
||||
) -> Result<Vec<f32>, String> {
|
||||
@@ -101,7 +101,7 @@ impl Sampler<'_> {
|
||||
fn window(
|
||||
&mut self,
|
||||
tensor_start: Option<u64>,
|
||||
part: &stream_parts::PartIdentity,
|
||||
part: &kar_shard_plan::PartIdentity,
|
||||
window: &SampleWindow,
|
||||
block: (u64, u64),
|
||||
) -> Result<(Vec<f32>, Vec<f32>), String> {
|
||||
@@ -116,7 +116,7 @@ impl Sampler<'_> {
|
||||
pub(super) fn shard(
|
||||
&mut self,
|
||||
index: &gguf::TensorIndex,
|
||||
parts: &[Vec<stream_parts::PartIdentity>],
|
||||
parts: &[Vec<kar_shard_plan::PartIdentity>],
|
||||
records: &mut Vec<RecordError>,
|
||||
) -> Result<(), String> {
|
||||
for (number, tensor) in index.tensors.iter().enumerate() {
|
||||
@@ -133,7 +133,7 @@ impl Sampler<'_> {
|
||||
pub(super) fn record(
|
||||
&mut self,
|
||||
tensor_start: Option<u64>,
|
||||
part: &stream_parts::PartIdentity,
|
||||
part: &kar_shard_plan::PartIdentity,
|
||||
) -> Result<RecordError, String> {
|
||||
let block = gguf::block_geometry(part.source_kind).ok_or("unsupported GGUF source kind")?;
|
||||
let elements = part.derived_bytes / 4;
|
||||
|
||||
@@ -105,9 +105,9 @@ mod archive_plan;
|
||||
mod write_archive;
|
||||
#[allow(unused_imports)]
|
||||
pub use write_archive::*;
|
||||
mod write_archive_inner;
|
||||
mod archive_write_steps;
|
||||
#[allow(unused_imports)]
|
||||
pub use write_archive_inner::*;
|
||||
pub use archive_write_steps::*;
|
||||
mod write_nested_section;
|
||||
#[allow(unused_imports)]
|
||||
pub use write_nested_section::*;
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
//! Functions: `write_archive_inner`, `check_request`, `temporary_path`, `publish`.
|
||||
//! Split out of `kar_writer` to keep its files under the line limit.
|
||||
//! `write_archive_inner`: check the request, write the archive to a `.part` file, verify it and publish it with a hard
|
||||
//! link that never replaces an existing destination. Separate from `kar_writer` so that order reads on its own.
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use super::archive_file::write_archive_file;
|
||||
@@ -1,4 +1,4 @@
|
||||
use super::*;
|
||||
use super::{Path, USAGE};
|
||||
use std::{
|
||||
ffi::CString,
|
||||
fs::{File, OpenOptions},
|
||||
|
||||
@@ -82,7 +82,7 @@ pub mod responses;
|
||||
pub mod runtime_config;
|
||||
pub mod service_install;
|
||||
pub mod service_unit;
|
||||
pub mod stream_parts;
|
||||
pub mod kar_shard_plan;
|
||||
pub mod tensor_export;
|
||||
pub use leleka_tokenizer as tokenizer;
|
||||
pub mod tokenizer_assets;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
//! Methods of `Blocks`: `event`, `message_start`, `open_text`, `text_delta` and 4 more.
|
||||
//! Functions: `adapt`, `stream_response`. Defines `Step`, `Blocks`.
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use super::*;
|
||||
use super::{
|
||||
Body, Event, Events, IntoResponse, NativeEvents, Response, Sse, StatusCode, Value, close_text, error_value, json,
|
||||
message, mpsc, send, stop, tool, usage,
|
||||
};
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
type Step = Result<ControlFlow<()>, &'static str>;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
//! `POST /v1/messages/count_tokens`: the Messages request counted through the native token counter.
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use super::*;
|
||||
use super::{
|
||||
AppState, CountRequest, IntoResponse, Json, JsonRejection, Response, State, StatusCode, Value, error, json,
|
||||
responses, to_bytes,
|
||||
};
|
||||
|
||||
pub async fn count_tokens(
|
||||
State(state): State<AppState>,
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
//! The Messages route layers and error envelope, the handler of `POST /v1/messages` and the stream of its events.
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use super::*;
|
||||
use super::{
|
||||
AppState, Context, Event, Events, HttpRequest, Infallible, IntoResponse, Json, JsonRejection, MAX_EVENT, Next, Pin,
|
||||
Poll, Request, Response, State, StatusCode, Stream, Value, header, json, message, mpsc, responses, stream_response,
|
||||
to_bytes,
|
||||
};
|
||||
pub(crate) fn error_value(status: StatusCode, message: &str) -> Value {
|
||||
leleka_gateway_domain::messages::error_value(status.as_u16(), message)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
//! Model manifest handling: verify, fetch with retry, the HTTP client and the Hugging Face request rules.
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use super::*;
|
||||
use super::{
|
||||
ACCEPT_ENCODING, Client, Component, Duration, Error, FETCH_ATTEMPTS, Manifest, ModelFile, Path, RANGE,
|
||||
RequestBuilder, Result, StatusCode, fetch_one, fs, io, preflight_space, verify_one,
|
||||
};
|
||||
|
||||
impl Manifest {
|
||||
pub async fn load(path: &Path) -> Result<Self> {
|
||||
|
||||
@@ -6,7 +6,7 @@ use std::{
|
||||
path::{Component, Path},
|
||||
};
|
||||
|
||||
use crate::{gguf, kar, model, prepare_preview, stream_parts};
|
||||
use crate::{gguf, kar, model, prepare_preview, kar_shard_plan};
|
||||
|
||||
pub enum PreviewOutcome {
|
||||
Created(prepare_preview::PreviewSummary),
|
||||
@@ -164,7 +164,7 @@ fn require_streamed_request(
|
||||
"streamed sharded preparation requires 1..=8 KAR levels",
|
||||
)?;
|
||||
if let Some(limit) = ple_part_elements {
|
||||
stream_parts::validate_ple_limit(limit)?;
|
||||
kar_shard_plan::validate_ple_limit(limit)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ use crate::{
|
||||
derived_iq3, derived_mixed, gguf, gguf_f32_stream, iq3_s, kar, kar_codec, kar_sample,
|
||||
kar_stream_encode, kar_writer,
|
||||
model::{self, Manifest},
|
||||
stream_parts,
|
||||
kar_shard_plan,
|
||||
};
|
||||
|
||||
const MAX_SOURCE_BYTES: u64 = 64 * 1024 * 1024;
|
||||
@@ -100,11 +100,11 @@ pub use encode_preview_tensor::*;
|
||||
mod verify_derived;
|
||||
#[allow(unused_imports)]
|
||||
pub use verify_derived::*;
|
||||
mod preview_common;
|
||||
use preview_common::*;
|
||||
mod staging_and_raw_tensor_reads;
|
||||
use staging_and_raw_tensor_reads::*;
|
||||
mod sharded_encode;
|
||||
use sharded_encode::*;
|
||||
mod streamed_encode;
|
||||
use streamed_encode::*;
|
||||
mod verify_sharded_parts;
|
||||
use verify_sharded_parts::*;
|
||||
mod sharded_archive_verification;
|
||||
use sharded_archive_verification::*;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
//! Functions: `relative_l2_error`, `prepared_tensor`, `encode_preview_tensor`, `verify_iq3` and 5 more.
|
||||
|
||||
use super::{
|
||||
Manifest, PartLimits, Path, PreparedTensor, PreviewKind, StreamPolicy, derived_mixed, kar, kar_codec, kar_writer,
|
||||
plan_verified_parts, require_sharded_header, require_sharded_provenance, require_sharded_sources, stream_parts,
|
||||
verify_derived,
|
||||
Manifest, PartLimits, Path, PreparedTensor, PreviewKind, StreamPolicy, derived_mixed, kar, kar_codec,
|
||||
kar_shard_plan, kar_writer, plan_verified_parts, require_sharded_header, require_sharded_provenance,
|
||||
require_sharded_sources, verify_derived,
|
||||
};
|
||||
|
||||
/// The calibrated planes of one tensor, before they are written as a section.
|
||||
@@ -145,7 +145,7 @@ pub fn verify_sharded(
|
||||
archive_path: &Path,
|
||||
) -> Result<kar::Summary, String> {
|
||||
let limits = PartLimits {
|
||||
max_part_elements: stream_parts::MAX_PART_ELEMENTS,
|
||||
max_part_elements: kar_shard_plan::MAX_PART_ELEMENTS,
|
||||
ple_part_elements: None,
|
||||
};
|
||||
verify_sharded_inner(manifest, source_dir, archive_path, None, limits)
|
||||
@@ -161,7 +161,7 @@ pub fn verify_sharded_streamed(
|
||||
return Err("streamed sharded verification requires 1..=8 KAR levels".into());
|
||||
}
|
||||
let limits = PartLimits {
|
||||
max_part_elements: stream_parts::MAX_PART_ELEMENTS,
|
||||
max_part_elements: kar_shard_plan::MAX_PART_ELEMENTS,
|
||||
ple_part_elements: None,
|
||||
};
|
||||
verify_sharded_inner(manifest, source_dir, archive_path, Some(levels), limits)
|
||||
@@ -174,12 +174,12 @@ pub fn verify_sharded_streamed_ple(
|
||||
levels: u8,
|
||||
ple_part_elements: u64,
|
||||
) -> Result<kar::Summary, String> {
|
||||
stream_parts::validate_ple_limit(ple_part_elements)?;
|
||||
kar_shard_plan::validate_ple_limit(ple_part_elements)?;
|
||||
if !(1..=8).contains(&levels) {
|
||||
return Err("streamed sharded verification requires 1..=8 KAR levels".into());
|
||||
}
|
||||
let limits = PartLimits {
|
||||
max_part_elements: stream_parts::MAX_PART_ELEMENTS,
|
||||
max_part_elements: kar_shard_plan::MAX_PART_ELEMENTS,
|
||||
ple_part_elements: Some(ple_part_elements),
|
||||
};
|
||||
verify_sharded_inner(manifest, source_dir, archive_path, Some(levels), limits)
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
use super::{
|
||||
MAX_SOURCE_BYTES, MAX_TENSORS, Manifest, PartLimits, Path, PreviewSummary, ShardedEncoding, derived_mixed,
|
||||
encode_shards, hash_file, kar_writer, nested_tensors, prepare_sharded_streamed_with_policy, require_architecture,
|
||||
require_levels, sharded_provenance_value, staging_dir, stream_parts, write_sibling_provenance,
|
||||
encode_shards, hash_file, kar_shard_plan, kar_writer, nested_tensors, prepare_sharded_streamed_with_policy,
|
||||
require_architecture, require_levels, sharded_provenance_value, staging_dir, write_sibling_provenance,
|
||||
};
|
||||
|
||||
pub fn prepare_sharded(
|
||||
@@ -88,7 +88,7 @@ pub fn prepare_sharded_streamed(
|
||||
source_dir,
|
||||
destination,
|
||||
levels,
|
||||
stream_parts::MAX_PART_ELEMENTS,
|
||||
kar_shard_plan::MAX_PART_ELEMENTS,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -99,14 +99,14 @@ pub fn prepare_sharded_streamed_ple(
|
||||
levels: u8,
|
||||
ple_part_elements: u64,
|
||||
) -> Result<PreviewSummary, String> {
|
||||
stream_parts::validate_ple_limit(ple_part_elements)?;
|
||||
kar_shard_plan::validate_ple_limit(ple_part_elements)?;
|
||||
prepare_sharded_streamed_with_policy(
|
||||
manifest,
|
||||
source_dir,
|
||||
destination,
|
||||
levels,
|
||||
PartLimits {
|
||||
max_part_elements: stream_parts::MAX_PART_ELEMENTS,
|
||||
max_part_elements: kar_shard_plan::MAX_PART_ELEMENTS,
|
||||
ple_part_elements: Some(ple_part_elements),
|
||||
},
|
||||
)
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
use super::{
|
||||
Manifest, PartLimits, Path, PreviewSummary, StreamedEncoding, StreamedRun, StreamedTensor, apply_stream_policy,
|
||||
derived_mixed, fs, hash_file, kar, kar_writer, minimum_part_payload_bytes, model, nested_file_data,
|
||||
provenance_path, require_architecture, require_levels, sharded_provenance_value, staging_dir, stream_parts,
|
||||
derived_mixed, fs, hash_file, kar, kar_shard_plan, kar_writer, minimum_part_payload_bytes, model, nested_file_data,
|
||||
provenance_path, require_architecture, require_levels, sharded_provenance_value, staging_dir,
|
||||
write_sibling_provenance,
|
||||
};
|
||||
|
||||
@@ -49,16 +49,16 @@ fn plan_stream_parts(
|
||||
identity: &derived_mixed::ShardedIdentity,
|
||||
source_dir: &Path,
|
||||
limits: PartLimits,
|
||||
) -> Result<Vec<Vec<stream_parts::PartIdentity>>, String> {
|
||||
) -> Result<Vec<Vec<kar_shard_plan::PartIdentity>>, String> {
|
||||
if let Some(limit) = limits.ple_part_elements {
|
||||
stream_parts::plan_shards_with_ple_limit(identity, source_dir, limit)
|
||||
kar_shard_plan::plan_shards_with_ple_limit(identity, source_dir, limit)
|
||||
} else {
|
||||
stream_parts::plan_shards_with_limit(identity, source_dir, limits.max_part_elements)
|
||||
kar_shard_plan::plan_shards_with_limit(identity, source_dir, limits.max_part_elements)
|
||||
}
|
||||
}
|
||||
|
||||
fn require_stream_budget(
|
||||
archive_parts: &[Vec<stream_parts::PartIdentity>],
|
||||
archive_parts: &[Vec<kar_shard_plan::PartIdentity>],
|
||||
archive_tensor_count: usize,
|
||||
destination: &Path,
|
||||
levels: u8,
|
||||
|
||||
+9
-8
@@ -1,11 +1,12 @@
|
||||
//! Stages of the sharded archive verification (STRA-338 size-fn).
|
||||
//! The stages of verifying a sharded archive: the header, the recorded sources and parts, and the stream policy.
|
||||
//! Separate from `prepare_preview`, which prepares archives; this is the read-back side.
|
||||
|
||||
use super::{
|
||||
Path, apply_stream_policy, derived_mixed, hash_file, kar, read_recorded_provenance, sharded_provenance_value,
|
||||
stream_parts,
|
||||
Path, apply_stream_policy, derived_mixed, hash_file, kar, kar_shard_plan, read_recorded_provenance,
|
||||
sharded_provenance_value,
|
||||
};
|
||||
|
||||
type Parts = [Vec<stream_parts::PartIdentity>];
|
||||
type Parts = [Vec<kar_shard_plan::PartIdentity>];
|
||||
|
||||
/// The streamed-preparation policy a sharded archive is verified against.
|
||||
#[derive(Clone, Copy)]
|
||||
@@ -25,11 +26,11 @@ pub(super) fn plan_verified_parts(
|
||||
identity: &derived_mixed::ShardedIdentity,
|
||||
source_dir: &Path,
|
||||
limits: PartLimits,
|
||||
) -> Result<Vec<Vec<stream_parts::PartIdentity>>, String> {
|
||||
) -> Result<Vec<Vec<kar_shard_plan::PartIdentity>>, String> {
|
||||
if let Some(limit) = limits.ple_part_elements {
|
||||
stream_parts::plan_shards_with_ple_limit(identity, source_dir, limit)
|
||||
kar_shard_plan::plan_shards_with_ple_limit(identity, source_dir, limit)
|
||||
} else {
|
||||
stream_parts::plan_shards_with_limit(identity, source_dir, limits.max_part_elements)
|
||||
kar_shard_plan::plan_shards_with_limit(identity, source_dir, limits.max_part_elements)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +81,7 @@ pub(super) fn require_sharded_sources(
|
||||
|
||||
fn require_part_source(
|
||||
record: &kar::TensorSource,
|
||||
part: &stream_parts::PartIdentity,
|
||||
part: &kar_shard_plan::PartIdentity,
|
||||
) -> Result<(), String> {
|
||||
let record_bytes = record_source_bytes(record)?;
|
||||
if record.name != part.name
|
||||
+4
-3
@@ -1,8 +1,9 @@
|
||||
//! Helpers shared by the preview preparation and verification paths (STRA-338 size-fn).
|
||||
//! What the preview preparation and verification share: the staging directory, the checked sizes and offsets, raw
|
||||
//! tensor reads and their digests. Separate from `prepare_preview` so both directions use one set of checks.
|
||||
|
||||
use super::{
|
||||
Digest, File, Path, PathBuf, PreparedTensor, Read, Seek, SeekFrom, Sha256, StagingDir, derived_mixed, fs, gguf,
|
||||
hash_file, kar_writer, partitioned_provenance, provenance_path, stream_parts, write_provenance,
|
||||
hash_file, kar_shard_plan, kar_writer, partitioned_provenance, provenance_path, write_provenance,
|
||||
};
|
||||
|
||||
pub(super) fn require_levels(levels: u8, message: &str) -> Result<(), String> {
|
||||
@@ -164,7 +165,7 @@ pub(super) fn require_shard_unchanged(
|
||||
pub(super) fn apply_stream_policy(
|
||||
value: &mut serde_json::Value,
|
||||
levels: u8,
|
||||
parts: &[Vec<stream_parts::PartIdentity>],
|
||||
parts: &[Vec<kar_shard_plan::PartIdentity>],
|
||||
ple_part_elements: Option<u64>,
|
||||
) {
|
||||
value["schema"] = serde_json::json!(if ple_part_elements.is_some() {
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
use super::{
|
||||
File, Path, PathBuf, PreparedTensor, StagingDir, StreamedTensor, TensorDistortion, checked_offset, derived_mixed,
|
||||
gguf, gguf_f32_stream, kar_codec, kar_sample, kar_stream_encode, open_shard, require_shard_unchanged,
|
||||
spool_raw_f32, stream_parts, tensor_elements,
|
||||
gguf, gguf_f32_stream, kar_codec, kar_sample, kar_shard_plan, kar_stream_encode, open_shard,
|
||||
require_shard_unchanged, spool_raw_f32, tensor_elements,
|
||||
};
|
||||
|
||||
type Parts = [Vec<stream_parts::PartIdentity>];
|
||||
type Parts = [Vec<kar_shard_plan::PartIdentity>];
|
||||
|
||||
pub(super) struct StreamedEncoding {
|
||||
pub(super) prepared: Vec<StreamedTensor>,
|
||||
@@ -34,7 +34,7 @@ struct EncodedPart {
|
||||
impl StreamedEncoding {
|
||||
fn record(
|
||||
&mut self,
|
||||
part: &stream_parts::PartIdentity,
|
||||
part: &kar_shard_plan::PartIdentity,
|
||||
section_path: PathBuf,
|
||||
done: EncodedPart,
|
||||
) {
|
||||
@@ -131,7 +131,7 @@ impl StreamedRun<'_> {
|
||||
}
|
||||
|
||||
/// Where the part's source bytes sit in the shard file, and how many elements they decode to.
|
||||
fn part_span(absolute: u64, part: &stream_parts::PartIdentity) -> gguf_f32_stream::TensorSpan {
|
||||
fn part_span(absolute: u64, part: &kar_shard_plan::PartIdentity) -> gguf_f32_stream::TensorSpan {
|
||||
gguf_f32_stream::TensorSpan {
|
||||
absolute_offset: absolute,
|
||||
source_kind: part.source_kind,
|
||||
@@ -143,7 +143,7 @@ fn part_span(absolute: u64, part: &stream_parts::PartIdentity) -> gguf_f32_strea
|
||||
fn encode_part(
|
||||
source: &mut File,
|
||||
absolute: u64,
|
||||
part: &stream_parts::PartIdentity,
|
||||
part: &kar_shard_plan::PartIdentity,
|
||||
section_path: &Path,
|
||||
levels: u8,
|
||||
) -> Result<EncodedPart, String> {
|
||||
@@ -163,7 +163,7 @@ fn encode_part(
|
||||
fn encode_nested_part(
|
||||
source: &mut File,
|
||||
absolute: u64,
|
||||
part: &stream_parts::PartIdentity,
|
||||
part: &kar_shard_plan::PartIdentity,
|
||||
calibration: &kar_codec::Calibration,
|
||||
section_path: &Path,
|
||||
) -> Result<EncodedPart, String> {
|
||||
@@ -190,7 +190,7 @@ fn encode_nested_part(
|
||||
fn encode_raw_part(
|
||||
source: &mut File,
|
||||
absolute: u64,
|
||||
part: &stream_parts::PartIdentity,
|
||||
part: &kar_shard_plan::PartIdentity,
|
||||
section_path: &Path,
|
||||
) -> Result<EncodedPart, String> {
|
||||
let result = spool_raw_f32(
|
||||
|
||||
@@ -11,7 +11,7 @@ fn ple_shard(payload: &[u8]) -> Vec<u8> {
|
||||
string(&mut gguf, "general.architecture");
|
||||
gguf.extend_from_slice(&8u32.to_le_bytes());
|
||||
string(&mut gguf, "qwen35");
|
||||
string(&mut gguf, stream_parts::PLE_TENSOR_NAME);
|
||||
string(&mut gguf, kar_shard_plan::PLE_TENSOR_NAME);
|
||||
gguf.extend_from_slice(&2u32.to_le_bytes());
|
||||
gguf.extend_from_slice(&32u64.to_le_bytes());
|
||||
gguf.extend_from_slice(&16u64.to_le_bytes());
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
use super::{
|
||||
DerivedIdentity, Digest, File, Path, PathBuf, PreviewKind, Read, Sha256, derived_iq3, derived_mixed, fs, iq3_s,
|
||||
kar, kar_codec, read_recorded_provenance, stream_parts,
|
||||
kar, kar_codec, kar_shard_plan, read_recorded_provenance,
|
||||
};
|
||||
|
||||
fn load_derived_identity(source_path: &Path, kind: PreviewKind) -> Result<DerivedIdentity, String> {
|
||||
@@ -203,7 +203,7 @@ pub(super) fn sharded_provenance_value(
|
||||
}
|
||||
|
||||
pub(super) fn partitioned_provenance(
|
||||
parts: &[Vec<stream_parts::PartIdentity>],
|
||||
parts: &[Vec<kar_shard_plan::PartIdentity>],
|
||||
) -> serde_json::Value {
|
||||
serde_json::json!(
|
||||
parts
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! The series table: every Prometheus metric the control plane exposes and where its value comes from.
|
||||
|
||||
use super::*;
|
||||
use super::{Series, counter, gauge, labelled, labelled_counter};
|
||||
|
||||
pub(super) const SERIES: &[Series] = &[
|
||||
counter(
|
||||
|
||||
@@ -2,8 +2,13 @@
|
||||
// The error value is the finished HTTP response: the handler returns it as it is, so it is large by design.
|
||||
#![allow(clippy::result_large_err)]
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use super::*;
|
||||
use super::{
|
||||
AppState, CONTEXT_MARGIN_TOKENS, CreateRequest, Event, Finish, Generate, GenerationCommand, GenerationResult,
|
||||
IntoResponse, Json, JsonRejection, NEXT_RESPONSE_ID, Ordering, OutputItem, Prepared, Response, ResponseIdentity,
|
||||
ResponseTrace, SharedCodec, State, StatusCode, StreamEnv, Usage, Value, WorkerState, api_error, at_end_plan,
|
||||
drop_unsupported_samplers, finish_generation, log_generation_failure, mpsc, oneshot, parse_request,
|
||||
prepare_input_tokens, queue_error, reasoning_plan, stream_live_text, unsupported_sampler, validate_live_subset,
|
||||
};
|
||||
|
||||
mod admit;
|
||||
mod answer;
|
||||
|
||||
@@ -3,7 +3,10 @@
|
||||
// The error value is the finished HTTP response: the handler returns it as it is, so it is large by design.
|
||||
#![allow(clippy::result_large_err)]
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
AppState, CONTEXT_MARGIN_TOKENS, CreateRequest, Generate, Prepared, Response, SharedCodec, StatusCode, WorkerState,
|
||||
api_error, drop_unsupported_samplers, reasoning_plan, unsupported_sampler, validate_live_subset,
|
||||
};
|
||||
|
||||
pub(super) fn server_refusal(code: &'static str, message: &str, status: StatusCode) -> Response {
|
||||
api_error(status, "server_error", code, None, message)
|
||||
|
||||
@@ -2,7 +2,12 @@
|
||||
// The error value is the finished HTTP response: the handler returns it as it is, so it is large by design.
|
||||
#![allow(clippy::result_large_err)]
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
AppState, CreateRequest, Event, Finish, Generate, GenerationCommand, GenerationResult, IntoResponse, Json,
|
||||
NEXT_RESPONSE_ID, Ordering, OutputItem, Response, ResponseIdentity, ResponseTrace, SharedCodec, StatusCode,
|
||||
StreamEnv, Usage, Value, api_error, at_end_plan, finish_generation, log_generation_failure, mpsc, oneshot,
|
||||
queue_error, stream_live_text,
|
||||
};
|
||||
use crate::{ports::engine::SharedEngine, wire::Done};
|
||||
use leleka_gateway_domain::output::{OutputError, OutputEvent, output_items};
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
//! The error answers of the Responses handlers: the JSON error body, and the queue, vision and lookup failures.
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use super::*;
|
||||
use super::{IntoResponse, Json, Response, StatusCode, json};
|
||||
|
||||
pub(super) fn api_error(
|
||||
status: StatusCode,
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
//! the code as it was before it moved from this crate to `leleka-gateway-domain` (STRA-338 S21), and are compared
|
||||
//! as text, so the JSON key order and the SSE framing are part of what is checked.
|
||||
|
||||
use super::*;
|
||||
use super::{CreateRequest, Finish, OutputItem, ResponseIdentity, ResponseTrace, Usage, Value, json, render_request};
|
||||
#[cfg(test)]
|
||||
use super::tests;
|
||||
use std::{fs, path::PathBuf};
|
||||
|
||||
fn fixture_path() -> PathBuf {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
//! The in-memory response history (64 entries, a byte limit) and its checksummed disk snapshot, and the paging of a
|
||||
//! stored response's input items.
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use super::*;
|
||||
use super::{Arc, Deserialize, HashMap, InputItemsQuery, Query, Serialize, Value, VecDeque, json};
|
||||
|
||||
mod pages;
|
||||
mod restore;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Paging a stored response's input items: where a page starts and how one stored item is projected for the client.
|
||||
|
||||
use super::*;
|
||||
use super::{StoredResponse, Value, json};
|
||||
|
||||
impl StoredResponse {
|
||||
/// The position of the first item of the page: after the cursor `after` in the requested order.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Reading the checksummed disk snapshot back: the decode, the per-entry checks and the rebuild.
|
||||
|
||||
use super::*;
|
||||
use super::{Deserialize, MAX_STORED_RESPONSES, ResponseHistory, StoredResponse, Value};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//! (`history_store`). The history keeps the rules (64 entries, byte limit, snapshot checksum); this file only puts it
|
||||
//! behind the port and decides which calls may block (a durable commit runs on the blocking pool).
|
||||
|
||||
use super::*;
|
||||
use super::{Arc, ResponseHistory, RwLock, Value};
|
||||
use crate::ports::{
|
||||
BoxFuture, ResponseStore, SharedResponseStore, response_store::InputItemsQuery,
|
||||
};
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
//! Request intake: the body read as traced JSON, the decode, validation and model check of a create request, and the
|
||||
//! prompt prepared for the engine (token ids, with every picture expanded to its rows).
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use super::*;
|
||||
use super::{
|
||||
AppState, Arc, CreateRequest, Family, IntoResponse, Json, JsonRejection, Response, SharedCodec, State, StatusCode,
|
||||
TextCodec, Tokenizer, Value, api_error, append_input, harmony_prompt, json, render_request, validate_live_subset,
|
||||
vision_error,
|
||||
};
|
||||
|
||||
mod parts;
|
||||
use parts::{
|
||||
mod intake_stages;
|
||||
use intake_stages::{
|
||||
check_model, decode_request, image_marks, invalid_prompt, no_encoder, refuse, render_prompt,
|
||||
resolve_previous, tokenize_prompt,
|
||||
};
|
||||
|
||||
+4
-1
@@ -1,7 +1,10 @@
|
||||
//! The stages of request intake: the body decode, the model check, the previous-response transcript, the render and the
|
||||
//! tokenization, and the picture marks.
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
AppState, CreateRequest, Family, IMAGE_PAD, Response, SharedCodec, StatusCode, Tokenizer, VISION_START, Value,
|
||||
api_error, append_input, harmony_prompt, render_request,
|
||||
};
|
||||
|
||||
/// An error answer as the `Box<Response>` the intake stages return.
|
||||
pub(super) fn refuse(
|
||||
@@ -1,7 +1,6 @@
|
||||
//! The prompt of a request. The rendering is `leleka-gateway-domain`; this crate adds the `render_template` stage span.
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use super::*;
|
||||
use super::{CreateRequest, LiteralMarks, render_request_with};
|
||||
|
||||
/// The rendered prompt and the sources of its pictures, in prompt order; see
|
||||
/// [`leleka_gateway_domain::responses::render_request_with`] for how control-token text is kept literal.
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
//! The stored-response routes: retrieve, list input items and delete.
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use super::*;
|
||||
use super::{
|
||||
AppState, InputItemsQuery, IntoResponse, Json, Path, RawQuery, Response, State, StatusCode, api_error, json,
|
||||
resource_not_found,
|
||||
};
|
||||
|
||||
pub(super) fn resource_query_error(query: Option<String>) -> Option<Response> {
|
||||
query.filter(|value| !value.is_empty()).map(|_| {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
//! `POST /v1/responses` as the route sees it: the handler `create` behind the admission and API key layers.
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use super::*;
|
||||
use super::{AppState, JsonRejection, Response, State, TracedJson, create};
|
||||
|
||||
/// The `/v1/responses` route: [`create`] with the body read and parse timed.
|
||||
pub async fn create_route(
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
//! Server-sent-event streaming of a Responses API generation: plain text, buffered and tool calls.
|
||||
//! Moved out of responses.rs (STRA-338 S6); everything here is private to the `responses` module tree.
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
Catalog, Context, CreateRequest, Event, Finish, Infallible, IntoResponse, NEXT_RESPONSE_ID, Ordering, OutputItem,
|
||||
Pin, Poll, Response, ResponseIdentity, ResponseTrace, SharedClock, SharedCodec, SharedResponseStore, Sse, SseEvent,
|
||||
Stream, Usage, Value, at_end_plan, debug_failed_output, finish_generation, is_structured, json,
|
||||
log_generation_failure, log_tool_notes, mpsc, reasoning_enabled, text_part, tool_call_recovery,
|
||||
};
|
||||
|
||||
/// What a stream fails with when its model has no live reading of its output (it always reasons).
|
||||
pub(super) const NO_LIVE_READING: &str = "the output of this model cannot be read live";
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
//! Buffered streaming for structured output and reasoning (moved from responses.rs, STRA-338 S6).
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
Collected, CreateRequest, Event, Finish, Flow, Next, OutputItem, Response, ResponseIdentity, ResponseTrace,
|
||||
SharedCodec, StreamEnv, Usage, Value, at_end_plan, classify, done_usage, failed_response, failure_message,
|
||||
finish_generation, json, log_generation_failure, mpsc, response_id, send_prelude, send_stream_event,
|
||||
send_trace_tail, sse_response, store_response, zero_usage,
|
||||
};
|
||||
use crate::wire::Done;
|
||||
use leleka_gateway_domain::output::{AtEndDecoder, GENERATION_ENDED, OutputEvent, output_items};
|
||||
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
//! Plain-text streaming of a Responses API generation (moved from responses.rs, STRA-338 S6).
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
Collected, CreateRequest, Event, Finish, Flow, NO_LIVE_READING, Next, OutputItem, Response, ResponseIdentity,
|
||||
ResponseTrace, SharedCodec, StreamEnv, Value, classify, done_usage, failed_response, failure_message,
|
||||
is_structured, json, log_generation_failure, mpsc, reasoning_enabled, response_id, send_prelude, send_stream_event,
|
||||
send_trace_tail, sse_response, store_response, stream_live_buffered, stream_live_tools, zero_usage,
|
||||
};
|
||||
use crate::wire::Done;
|
||||
use leleka_gateway_domain::output::{LiveDecoder, LivePlan, OutputEvent};
|
||||
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
//! Streaming of a response whose request declares tools: text and calls are published as the worker produces them.
|
||||
|
||||
use super::tools::ToolStream;
|
||||
use super::*;
|
||||
use super::{
|
||||
Catalog, Collected, CreateRequest, Event, Finish, Flow, NO_LIVE_READING, Next, OutputItem, Response,
|
||||
ResponseIdentity, ResponseTrace, SharedCodec, StreamEnv, Value, classify, debug_failed_output, done_usage,
|
||||
failed_response, failure_message, json, log_generation_failure, log_tool_notes, mpsc, response_id, send_prelude,
|
||||
sse_response, store_response, tool_call_recovery, zero_usage,
|
||||
};
|
||||
use crate::wire::Done;
|
||||
use leleka_gateway_domain::output::{LiveDecoder, LivePlan, OutputEvent};
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
//! Streaming of tool calls (moved from responses.rs, STRA-338 S6).
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
Catalog, CreateRequest, OutputItem, ResponseIdentity, ResponseTrace, Value, json, mpsc, send_stream_event,
|
||||
text_part, zero_usage,
|
||||
};
|
||||
use leleka_gateway_domain::output::OutputEvent;
|
||||
|
||||
pub(super) struct ToolStream {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
//! Reading tool calls out of the model's text: the process-wide switch of the experimental recovery, and the wrappers
|
||||
//! that give the domain parsers that switch and write the log lines for calls accepted beyond the template form.
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use super::*;
|
||||
use super::{CreateRequest, Finish, Ordering, TextCodec, debug_failed_output, flat_tools, reasoning_enabled};
|
||||
use leleka_gateway_domain::output::{AtEndDecoder, AtEndPlan, OutputError, OutputEvent};
|
||||
|
||||
/// EXPERIMENTAL `tool_call_recovery` (config key or `STRATA_TOOL_CALL_RECOVERY`): off unless `main` turns it on at
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
//! Methods of `SplitFlags`: `take`. Functions: `parse`, `options_from`, `validate_name`, `install_options` and 5 more.
|
||||
//! Defines `SplitFlags`.
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use super::*;
|
||||
use super::{CONTROL_USAGE, INSTALL_READY_USAGE, Options, PathBuf, USAGE};
|
||||
|
||||
pub(super) fn parse(args: &[String]) -> Result<Options, String> {
|
||||
let mut values = std::collections::BTreeMap::new();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//! Methods of `Profile`: `readiness`, `control`.
|
||||
//! Functions: `provision_budget`, `ready_budget`, `check_profile_ids`, `arguments` and 8 more.
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use super::*;
|
||||
use super::{BTreeMap, Catalog, Duration, PathBuf, Profile, USAGE, Value, storage};
|
||||
#[cfg(unix)]
|
||||
|
||||
pub(super) fn provision_budget() -> u64 {
|
||||
3600
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
//! The unix body of `service-switch`: one transaction between two installed native user services (STRA-338).
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use super::*;
|
||||
use super::{
|
||||
BTreeMap, Catalog, Digest, Path, Profile, Sha256, Value, discover, inactive, json, pid, prepare, storage,
|
||||
validate_auto,
|
||||
};
|
||||
#[cfg(unix)]
|
||||
use crate::wait_ready::Waiter;
|
||||
use storage::{Journal, digest, read};
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
//! Execution deadline, startup timeout and the stall watchdog.
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
Arc, Duration, Event, Generate, GenerationResult, RwLock, WorkerState, WorkerStatus, answer_within, fixture_config,
|
||||
generate_command, join_within, mpsc, oneshot, run, start_rig, supervise, timeout, wait_for, watch,
|
||||
};
|
||||
|
||||
#[tokio::test]
|
||||
async fn execution_deadline_covers_blocked_engine_stdin() {
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
//! One generation through the supervisor: exchange, cancellation, shutdown and stop.
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
Duration, Event, GenerationResult, Rig, STOP_DRAIN_TIMEOUT, WorkerState, answer_within,
|
||||
assert_one_request_cancelled, assert_worker_is_ready, command, first_streamed_token, fixture_config,
|
||||
generate_command, join_within, marker_config, mpsc, oneshot, start_rig, wait_for_file,
|
||||
};
|
||||
|
||||
/// A sampled generation of two prompt tokens: three events plus DONE, and the metrics that follow.
|
||||
async fn exchange_sampled_generation(rig: &Rig) {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
//! The READY handshake, shutdown and readiness revocation.
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
Arc, Duration, RwLock, WorkerState, WorkerStatus, fixture_config, parse_ready, run, timeout, wait_for, watch,
|
||||
};
|
||||
|
||||
#[tokio::test]
|
||||
async fn ready_requires_handshake_and_shutdown_sends_quit() {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
//! The rig the supervisor tests share: a worker task on the mock engine with a request channel, and small waits.
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
Arc, Duration, Event, Generate, GenerationCommand, GenerationResult, Path, RwLock, WorkerConfig, WorkerState,
|
||||
WorkerStatus, command, fixture_config, mpsc, oneshot, run_with_requests, timeout, wait_for, watch,
|
||||
};
|
||||
|
||||
type Buffered = oneshot::Receiver<Result<Vec<Event>, String>>;
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
//! Load and unload: unload, lazy start, idle unload, the before-load command.
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
BeforeLoad, Duration, Event, RwLock, SessionExit, Supervised, WorkerConfig, WorkerState, WorkerStatus,
|
||||
fixture_config, lifecycle_request, lines_of, scratch, supervise, wait_for, watch,
|
||||
};
|
||||
|
||||
async fn assert_context_survives_unload(worker: &Supervised) {
|
||||
let status = worker.status.read().await;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Reasoning-budget wrap-up through the supervisor.
|
||||
|
||||
use super::*;
|
||||
use super::{Event, Path, Supervised, WorkerState, budget_request, fixture_config, scratch, supervise, wait_for, wire};
|
||||
|
||||
/// A supervised mock engine in budget mode, logging its requests under a scratch directory.
|
||||
async fn budget_worker(name: &str) -> (Supervised, std::path::PathBuf) {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
//! Crash handling: restart budget, backoff, startup failure, drain guard.
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
Arc, Duration, Event, GenerationResult, Path, Rig, RwLock, WorkerState, WorkerStatus, answer_within, command,
|
||||
generate_command, mpsc, restart_fixture, run, start_rig, timeout, wait_for, wait_for_file, watch,
|
||||
};
|
||||
|
||||
/// How many times the mock engine booted (one line per boot in the fixture directory).
|
||||
fn boot_count(root: &Path) -> usize {
|
||||
|
||||
@@ -171,6 +171,6 @@ pub use rope_scaling_type::*;
|
||||
mod fill_rope_table;
|
||||
#[allow(unused_imports)]
|
||||
pub use fill_rope_table::*;
|
||||
mod setup_rope_error_display_error;
|
||||
mod setup_rope_error_and_resolve;
|
||||
#[allow(unused_imports)]
|
||||
pub use setup_rope_error_display_error::*;
|
||||
pub use setup_rope_error_and_resolve::*;
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
//! Implements `Display for SetupRopeError`, `Error for SetupRopeError`. Functions: `setup_resolve_rope`.
|
||||
//! Split out of `rope_scaling` to keep its files under the line limit.
|
||||
//! `SetupRopeError` (`Display`, `Error`) and `setup_resolve_rope`, the setup's resolution of the rope scaling.
|
||||
//! Separate from `rope_scaling` so the error and its one producer read together.
|
||||
|
||||
use super::{RopeScalingType, SetupRopeError, derived_factor, fmt};
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
//! `leleka up`: run the plan, then print or serialize the summary of the installed service.
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
Context, Mode, Step, StepState, UnitScopeTag, UpOptions, Value, env_var, gather, gather_fs, json, json_plan,
|
||||
plan_steps, print_report, render_plan, say, steps, supervisor,
|
||||
};
|
||||
|
||||
pub async fn up(opts: UpOptions) -> i32 {
|
||||
let ctx = gather(&opts, &env_var);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! The human view of the engine telemetry (`machine` of `/v1/status`).
|
||||
|
||||
use super::*;
|
||||
use super::{Value, render_settings};
|
||||
|
||||
fn gib(mib: &Value) -> String {
|
||||
mib.as_f64()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! The sections of `leleka verify --quick`: model files, service, logs and requests.
|
||||
|
||||
use super::*;
|
||||
use super::{Value, render_supervisor, steps, unix_now};
|
||||
use crate::{config::RunConfig, layout::Paths, profile::KarSource};
|
||||
use leleka_model_format::verify_stamp::{FileIdentity, VerifyStamps};
|
||||
use std::path::Path;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! `leleka reconfigure`: ask the supervisor, persist the settings or restart, and render the effective values.
|
||||
|
||||
use super::*;
|
||||
use super::{PersistTarget, ReconfigureArgs, UpOptions, Value, json};
|
||||
|
||||
/// `leleka reconfigure`.
|
||||
///
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! `leleka status`: the installed scope, the supervisor document and its human rendering.
|
||||
|
||||
use super::*;
|
||||
use super::{PathBuf, UnitScopeTag, UpOptions, Value, json, render_machine, steps, supervisor};
|
||||
|
||||
/// Which systemd unit of this deployment exists (system first), judged by the unit file.
|
||||
pub(super) fn installed_scope(paths: &crate::layout::Paths) -> Option<UnitScopeTag> {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! `leleka verify`: the quick offline check and the full verification against a running engine.
|
||||
|
||||
use super::quick_health::{Health, report_logs_and_requests, report_model_files, report_service};
|
||||
use super::*;
|
||||
use super::{PathBuf, UpOptions, say};
|
||||
use crate::{config::RunConfig, layout::Paths};
|
||||
use leleka_model_format::verify_stamp::{FileIdentity, VerifyStamps, sha256_of_file};
|
||||
use std::path::Path;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
//! The command line parser: picks the command and hands the rest to it.
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
Command, Environment, PathBuf, ServiceAction, logs_command, number, parse_flags, reconfigure_command,
|
||||
report_command, text, up_options,
|
||||
};
|
||||
|
||||
pub fn parse(args: &[String], env: &Environment) -> Result<Command, String> {
|
||||
let Some((command, rest)) = args.split_first() else {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Flag parsing shared by the commands: values, ranges, ports and the `up` options.
|
||||
|
||||
use super::*;
|
||||
use super::{Dirs, Environment, Flags, ModeChoice, PathBuf, Ports, ReconfigureArgs, UP_FLAGS, UpOptions};
|
||||
|
||||
impl ReconfigureArgs {
|
||||
/// The budget and the preset are fixed when the CUDA context is created.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! The `reconfigure` arguments: settings, budget, preset and persist taken out of the `up` flags.
|
||||
|
||||
use super::*;
|
||||
use super::{Command, parse_as};
|
||||
|
||||
#[test]
|
||||
fn reconfigure_collects_the_settings_and_locates_the_service_with_the_up_flags() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! What the engine process is started with: arguments, verify arguments, archive argument, MTP profile and environment.
|
||||
|
||||
use super::*;
|
||||
use super::{BTreeMap, KarArg, KarSource, MTP_PROFILE, NATIVE_MTP_PROFILE, Paths, RUNTIME_TOKEN_ENV, RunConfig};
|
||||
|
||||
impl RunConfig {
|
||||
/// Arguments of `leleka-inference`, in the order its parser requires (seven fixed pairs first, then the
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! The JSON documents the service writes for the daemon and the gateway.
|
||||
|
||||
use super::*;
|
||||
use super::{GATEWAY_TOKEN_ENV, RUNTIME_TOKEN_ENV, RunConfig, Value, json};
|
||||
|
||||
impl RunConfig {
|
||||
pub fn daemon_json(&self) -> Value {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
//! Digests, file states and the provisioning of the ranked expert table.
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
Digest, EMBEDDED, EMBEDDED_ORIGIN, FileState, MAX_BYTES, Outcome, PINNED_BYTES, PINNED_SHA256, Path, PathBuf,
|
||||
Profile, Request, RunConfig, Sha256, SystemTime, TierReport, UNIX_EPOCH, tier_report_with,
|
||||
};
|
||||
|
||||
/// The embedded table when it is the one with digest `expected` (a profile that pins another digest gets `None`).
|
||||
pub fn embedded_for(expected: &str) -> Option<&'static [u8]> {
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
//! The pinned numbers and the table embedded in the binary: installed offline before any download.
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
EMBEDDED, EMBEDDED_ORIGIN, FIXTURE, FileState, MAX_BYTES, Outcome, PINNED_BYTES, PINNED_SHA256, Path, Request,
|
||||
SOURCES, UPSTREAM_COMMIT, embedded_for, file_state, fixture_digest, provision, sha256_hex, short_digest, temp,
|
||||
};
|
||||
#[cfg(test)]
|
||||
use super::with_suffix;
|
||||
|
||||
#[test]
|
||||
fn the_pinned_numbers_are_consistent() {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
//! The on/off report of the expert tier and the table the engine receives.
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
FIXTURE, FileState, PROFILE_ENV, Path, SLOTS_ENV, config, fixture_digest, short_digest, start_environment, temp,
|
||||
tier_report, tier_report_with,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn the_report_says_on_with_the_digest_or_off_with_the_reason() {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
//! Downloads, local files and wrong files: verified, installed or refused, never deleted.
|
||||
|
||||
use super::*;
|
||||
use super::{FIXTURE, Outcome, Path, RefCell, Request, fixture_digest, provision, temp};
|
||||
#[cfg(test)]
|
||||
use super::with_suffix;
|
||||
|
||||
#[test]
|
||||
fn a_download_is_verified_then_installed_and_a_present_file_is_left_alone() {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
//! The expert-tier report and the engine's start environment.
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
BTreeMap, FileState, PROFILE_ENV, Path, RunConfig, SLOTS_ENV, TierReport, expected_digest, short_digest,
|
||||
tier_report,
|
||||
};
|
||||
|
||||
/// [`tier_report`] with the file's state supplied by the caller (`shown` is the path to print; `state` is only called
|
||||
/// when needed).
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
//! Linux probe of the host facts: /proc, nvidia-smi, ports and the CUDA libraries in the loader path.
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
DirFact, Facts, Path, PathBuf, ProbeRequest, count_physical_cores, find_library, fs_type_for, is_wsl,
|
||||
parse_cgroup_max, parse_meminfo, parse_nvidia_smi,
|
||||
};
|
||||
#[cfg(target_os = "linux")]
|
||||
use super::lab_holder_running;
|
||||
use std::{net::TcpListener, process::Command};
|
||||
|
||||
fn read(path: &str) -> String {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
//! Collecting, joining and summarizing the log entries and request records.
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
Entry, Filter, Map, Path, RECORDS_SCAN_BYTES, TAIL_SCAN_BYTES, Value, VecDeque, for_each_line, format_utc_ms,
|
||||
generations, json, parse_duration_ms, parse_line, parse_utc_ms, sources_in,
|
||||
};
|
||||
|
||||
/// The entries of the log directory that pass `filter`, oldest first, at most `filter.tail` (the newest ones).
|
||||
pub fn collect(dir: &Path, filter: &Filter) -> Vec<Entry> {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
//! Parsing and rendering one log line, the rotated generations and the entry filter.
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
BufRead, Entry, Filter, Level, Map, Path, PathBuf, SOURCES, Seek, SeekFrom, Value, format_utc_ms, parse_utc_ms,
|
||||
};
|
||||
|
||||
pub(super) fn legacy_level(raw: &str) -> Level {
|
||||
let lower = raw.to_ascii_lowercase();
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
//! `leleka logs`: the filter, the printing, following and the redaction of a report.
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
Entry, Filter, Level, LogsArgs, Path, PathBuf, Read, ReportArgs, ReportInputs, Seek, SeekFrom, UpOptions, Value,
|
||||
Write, collect, format_utc_ms, generations, join_requests, json, now_ms, parse_line, parse_since, redact,
|
||||
render_entry, sources_in, summarize,
|
||||
};
|
||||
|
||||
pub fn filter_from(args: &LogsArgs, now: u64) -> Result<Filter, String> {
|
||||
let mut filter = Filter {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//! `--expert-profile-file`) and verified before any large download, so that a failure costs seconds and the
|
||||
//! configuration is never written without it.
|
||||
|
||||
use super::*;
|
||||
use super::{Context, ExpertProfileState, Step, StepState, step};
|
||||
use crate::expert_profile::{
|
||||
PINNED_BYTES, PINNED_SHA256, SOURCES, embedded_for, expected_digest, short_digest,
|
||||
};
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
//! The plan steps that prepare the host: checks, directories, binaries, cuBLAS and the secrets.
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
BINARIES, CUBLAS_BYTES, CUBLAS_SHA256, CUBLAS_URL, CUBLAS_VERSION, Context, FsState, Step, StepState, step,
|
||||
};
|
||||
|
||||
pub(super) fn preflight_step(ctx: &Context) -> Step {
|
||||
let state = match &ctx.report {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
//! The plan steps that bring the model in: the shards, the KAR archive, the MTP pack, the tokenizer and the configs.
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
ARCHIVE_BYTES, Context, FsState, KarSource, MANIFEST, MTP_FILES, Step, StepState, gib_text, step, strata_next,
|
||||
windows_shards_present,
|
||||
};
|
||||
|
||||
/// The archive is accepted as it is (`--trust-archive`): the engine verifies it at each load.
|
||||
pub(super) fn trusts_archive(ctx: &Context, fs: &FsState) -> bool {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! The text of a plan for `--dry-run` and `preflight`.
|
||||
|
||||
use super::*;
|
||||
use super::{Context, KarArg, KarSource, RunConfig, Step, StepState};
|
||||
|
||||
/// A human rendering of the plan, with the engine command the service will run.
|
||||
pub fn render_plan(ctx: &Context, steps: &[Step]) -> String {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Unit scope and run mode: how the mode follows from the options and the host.
|
||||
|
||||
use super::*;
|
||||
use super::{Facts, Mode, ModeChoice, UnitScope, UnitScopeTag};
|
||||
|
||||
impl UnitScopeTag {
|
||||
pub fn scope(self) -> UnitScope {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! The plan steps that run the service: the unit, the start and the readiness wait.
|
||||
|
||||
use super::*;
|
||||
use super::{Context, FsState, Mode, Step, StepState, UnitScopeTag, step};
|
||||
|
||||
/// The `service` and `start` steps of the chosen mode.
|
||||
pub(super) fn service_steps(ctx: &Context, fs: &FsState) -> [Step; 2] {
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
//! The ordered install plan: every step the `up` command may run, with its state.
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
Context, FsState, Paths, Step, StepState, binaries_step, config_step, cublas_step, expert_profile_step, kar_state,
|
||||
kar_step, layout_step, model_step, mtp_pack_step, preflight_step, ready_step, secrets_step, service_steps,
|
||||
tokenizer_step, trusts_archive,
|
||||
};
|
||||
|
||||
pub fn plan_steps(ctx: &Context, fs: &FsState) -> Vec<Step> {
|
||||
let mut steps = vec![
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! The state of one plan step and the constructor of a step.
|
||||
|
||||
use super::*;
|
||||
use super::{Step, StepState};
|
||||
|
||||
impl StepState {
|
||||
pub fn tag(&self) -> &'static str {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
//! The expert-profile step: its place in the plan, its states and the digest that decides a download.
|
||||
|
||||
use super::*;
|
||||
use super::{
|
||||
Context, ExpertProfileState, FsState, Mode, Profile, StepState, context, expert_profile_state, expert_step, gather,
|
||||
options, plan_steps, state_of,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn the_expert_profile_is_planned_before_the_big_downloads() {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user