pub struct MLflowClient { /* private fields */ }Expand description
MLflow client for experiment tracking
Implementations§
Source§impl MLflowClient
impl MLflowClient
Sourcepub fn new(config: MLflowConfig) -> Self
pub fn new(config: MLflowConfig) -> Self
Sourcepub fn set_tracking_uri(&mut self, uri: impl Into<String>)
pub fn set_tracking_uri(&mut self, uri: impl Into<String>)
Sourcepub async fn start_experiment(
&mut self,
name: impl Into<String>,
) -> Result<String>
pub async fn start_experiment( &mut self, name: impl Into<String>, ) -> Result<String>
Start a new experiment.
In TrackingMode::Http this looks the experiment up by name
(GET experiments/get-by-name) and creates it
(POST experiments/create) if it doesn’t exist yet – a real round
trip to tracking_uri, which fails with a real transport/HTTP error
if the server is unreachable or rejects the request. In
TrackingMode::LocalOnly no request is made and a synthetic
local-* id is generated instead, so callers can always tell the
two apart.
§Arguments
name- Experiment name
§Returns
Experiment ID
Sourcepub async fn start_run(&mut self, run_name: Option<&str>) -> Result<String>
pub async fn start_run(&mut self, run_name: Option<&str>) -> Result<String>
Start a new run within the current experiment.
Real POST runs/create in TrackingMode::Http; a synthetic
local-* id with no network access in TrackingMode::LocalOnly.
§Arguments
run_name- Optional run name
§Returns
Run ID
Sourcepub async fn end_run(&mut self, status: RunStatus) -> Result<()>
pub async fn end_run(&mut self, status: RunStatus) -> Result<()>
End the current run: flushes any cached metrics/params/tags, then
(in TrackingMode::Http) sets the run’s terminal status via a real
POST runs/update call.
§Arguments
status- Final run status
Sourcepub fn log_param(
&mut self,
key: impl Into<String>,
value: impl ToString,
) -> Result<()>
pub fn log_param( &mut self, key: impl Into<String>, value: impl ToString, ) -> Result<()>
Log a parameter. Cached locally; delivered to the tracking server by
MLflowClient::flush / MLflowClient::end_run (never on every
call – a per-call network round trip for every logged value would
be prohibitively slow for training loops that log every step).
§Arguments
key- Parameter namevalue- Parameter value
Sourcepub fn log_tag(
&mut self,
key: impl Into<String>,
value: impl ToString,
) -> Result<()>
pub fn log_tag( &mut self, key: impl Into<String>, value: impl ToString, ) -> Result<()>
Log a tag. Cached locally, delivered the same way as parameters.
§Arguments
key- Tag namevalue- Tag value
Sourcepub fn log_metric(
&mut self,
key: impl Into<String>,
value: f64,
step: i64,
) -> Result<()>
pub fn log_metric( &mut self, key: impl Into<String>, value: f64, step: i64, ) -> Result<()>
Log a metric at a specific step. Cached locally; see
MLflowClient::log_param for why this does not hit the network
directly.
§Arguments
key- Metric namevalue- Metric valuestep- Step number
Sourcepub fn log_tensor_stats(
&mut self,
prefix: &str,
tensor: &Tensor,
step: i64,
) -> Result<()>
pub fn log_tensor_stats( &mut self, prefix: &str, tensor: &Tensor, step: i64, ) -> Result<()>
Log tensor statistics as metrics
§Arguments
prefix- Metric name prefixtensor- Tensor to analyzestep- Step number
Sourcepub fn log_array_stats(
&mut self,
prefix: &str,
array: &Array1<f64>,
step: i64,
) -> Result<()>
pub fn log_array_stats( &mut self, prefix: &str, array: &Array1<f64>, step: i64, ) -> Result<()>
Log array statistics as metrics
§Arguments
prefix- Metric name prefixarray- Array to analyzestep- Step number
Sourcepub async fn flush(&self) -> Result<()>
pub async fn flush(&self) -> Result<()>
Flush cached metrics, parameters and tags to the MLflow tracking
server via a real POST runs/log-batch call (chunked to respect
MLflow’s per-request limits of 1000 metrics / 100 params / 100 tags).
A no-op in TrackingMode::LocalOnly – the caches themselves are
the record in that mode – and a no-op when there is nothing cached
or no active run.
Sourcepub fn log_artifact(
&self,
local_path: impl AsRef<Path>,
artifact_path: Option<&str>,
artifact_type: ArtifactType,
) -> Result<()>
pub fn log_artifact( &self, local_path: impl AsRef<Path>, artifact_path: Option<&str>, artifact_type: ArtifactType, ) -> Result<()>
Log an artifact (file) to the local artifact_dir cache.
Unlike Self::log_metric/Self::log_param/Self::log_tag,
this method does not upload to the remote MLflow tracking
server’s artifact store, even in TrackingMode::Http – MLflow’s
artifact storage is backend-dependent (local disk, S3, GCS, Azure
Blob, DBFS, …) and there is no single REST endpoint this client
can target without knowing which backend the server is configured
with. Uploading real artifact bytes to a remote MLflow server is
intentionally out of scope for this client; only the experiment/run
lifecycle and metrics/params/tags are delivered over HTTP. Callers
that need artifacts on the actual tracking server must copy from
artifact_dir themselves via whatever channel the server’s artifact
backend expects.
§Arguments
local_path- Path to local fileartifact_path- Optional path within the local artifact cacheartifact_type- Type of artifact
Sourcepub fn log_model(
&self,
model_path: impl AsRef<Path>,
model_name: Option<&str>,
) -> Result<()>
pub fn log_model( &self, model_path: impl AsRef<Path>, model_name: Option<&str>, ) -> Result<()>
Sourcepub fn get_run_info(&self) -> Option<RunInfo>
pub fn get_run_info(&self) -> Option<RunInfo>
Get current run information. The start_time reflects when
MLflowClient::start_run was actually called (real wall-clock ms
since epoch), not a placeholder.
Sourcepub fn get_params(&self) -> HashMap<String, String>
pub fn get_params(&self) -> HashMap<String, String>
Get all logged parameters
Sourcepub fn get_metrics(&self) -> HashMap<String, Vec<MetricPoint>>
pub fn get_metrics(&self) -> HashMap<String, Vec<MetricPoint>>
Get all logged metrics
Get all logged tags
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for MLflowClient
impl !UnwindSafe for MLflowClient
impl Freeze for MLflowClient
impl Send for MLflowClient
impl Sync for MLflowClient
impl Unpin for MLflowClient
impl UnsafeUnpin for MLflowClient
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.