pub struct Client { /* private fields */ }Expand description
The main client for interacting with the modelexpress_server via gRPC
Implementations§
Source§impl Client
impl Client
Sourcepub async fn new(config: Config) -> CommonResult<Self>
pub async fn new(config: Config) -> CommonResult<Self>
Create a new client with the given configuration
Sourcepub async fn new_with_cache(
config: Config,
cache_config: CacheConfig,
) -> CommonResult<Self>
pub async fn new_with_cache( config: Config, cache_config: CacheConfig, ) -> CommonResult<Self>
Create a new client with cache configuration
Sourcepub async fn delete_model_on_server(
&mut self,
model_name: &str,
provider: ModelProvider,
) -> CommonResult<()>
pub async fn delete_model_on_server( &mut self, model_name: &str, provider: ModelProvider, ) -> CommonResult<()>
Delete a model’s record from the server-side registry. This complements
removing the model’s local files, so a cleared model does not leave behind a
stale DOWNLOADED record that would satisfy a later download request without
re-fetching the files.
pub async fn get_model_path( &self, model_name: &str, provider: ModelProvider, ) -> Result<PathBuf>
Sourcepub async fn health_check(&mut self) -> CommonResult<Status>
pub async fn health_check(&mut self) -> CommonResult<Status>
Get the server health status
Sourcepub async fn send_request<T: DeserializeOwned>(
&mut self,
action: impl Into<String>,
payload: Option<HashMap<String, Value>>,
) -> CommonResult<T>
pub async fn send_request<T: DeserializeOwned>( &mut self, action: impl Into<String>, payload: Option<HashMap<String, Value>>, ) -> CommonResult<T>
Send a request to the server
Sourcepub async fn request_model_on_server(
&mut self,
model_name: impl Into<String>,
provider: ModelProvider,
ignore_weights: bool,
) -> CommonResult<()>
pub async fn request_model_on_server( &mut self, model_name: impl Into<String>, provider: ModelProvider, ignore_weights: bool, ) -> CommonResult<()>
Request a model on the server at its default revision.
Sourcepub async fn request_model_on_server_revision(
&mut self,
model_name: impl Into<String>,
provider: ModelProvider,
ignore_weights: bool,
revision: Option<&str>,
) -> CommonResult<Option<String>>
pub async fn request_model_on_server_revision( &mut self, model_name: impl Into<String>, provider: ModelProvider, ignore_weights: bool, revision: Option<&str>, ) -> CommonResult<Option<String>>
Request a model on the server at a specific branch, tag, or commit SHA.
Returns the immutable revision the server resolved the request to, or None for
providers that do not expose revisions.
Sourcepub async fn request_model(
&mut self,
model_name: impl Into<String>,
provider: ModelProvider,
ignore_weights: bool,
) -> CommonResult<()>
pub async fn request_model( &mut self, model_name: impl Into<String>, provider: ModelProvider, ignore_weights: bool, ) -> CommonResult<()>
Request a model through the client, using the server as the source of truth. When shared_storage is disabled, files will be streamed from server to client.
Sourcepub async fn request_model_revision(
&mut self,
model_name: impl Into<String>,
provider: ModelProvider,
ignore_weights: bool,
revision: Option<&str>,
) -> CommonResult<ModelDownloadResult>
pub async fn request_model_revision( &mut self, model_name: impl Into<String>, provider: ModelProvider, ignore_weights: bool, revision: Option<&str>, ) -> CommonResult<ModelDownloadResult>
Request a model at a specific branch, tag, or commit SHA, reporting the snapshot path and the immutable revision the request resolved to.
When shared_storage is disabled, files are streamed from the server into the local cache under that resolved revision.
Sourcepub async fn request_model_with_smart_fallback(
model_name: impl Into<String>,
provider: ModelProvider,
config: Config,
ignore_weights: bool,
) -> CommonResult<()>
pub async fn request_model_with_smart_fallback( model_name: impl Into<String>, provider: ModelProvider, config: Config, ignore_weights: bool, ) -> CommonResult<()>
Request a model with automatic server fallback, creating client connection only if needed. This function will try to download via server if possible, otherwise download directly only if the initial client connection cannot be established.
Sourcepub async fn request_model_with_smart_fallback_revision(
model_name: impl Into<String>,
provider: ModelProvider,
config: Config,
ignore_weights: bool,
revision: Option<&str>,
) -> CommonResult<ModelDownloadResult>
pub async fn request_model_with_smart_fallback_revision( model_name: impl Into<String>, provider: ModelProvider, config: Config, ignore_weights: bool, revision: Option<&str>, ) -> CommonResult<ModelDownloadResult>
Revision-aware Client::request_model_with_smart_fallback. The direct-download
fallback honours the same revision, so a pinned request cannot silently land on a
different commit just because the server was unreachable.
Auto Trait Implementations§
impl !Freeze for Client
impl !RefUnwindSafe for Client
impl !UnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request