Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

The main client for interacting with the modelexpress_server via gRPC

Implementations§

Source§

impl Client

Source

pub async fn new(config: Config) -> CommonResult<Self>

Create a new client with the given configuration

Source

pub async fn new_with_cache( config: Config, cache_config: CacheConfig, ) -> CommonResult<Self>

Create a new client with cache configuration

Source

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.

Source

pub async fn get_model_path( &self, model_name: &str, provider: ModelProvider, ) -> Result<PathBuf>

Source

pub async fn health_check(&mut self) -> CommonResult<Status>

Get the server health status

Source

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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more