Struct MlflowTrackingRecorder

Source
pub struct MlflowTrackingRecorder<E, R>
where E: Env, R: ReplayBufferBase,
{ /* private fields */ }
Expand description

Record metrics to the MLflow tracking server during training.

Before training, you can use MlflowTrackingRecorder::log_params() to log parameters of the run like hyperparameters of the algorithm, the name of environment on which the agent is trained, etc.

MlflowTrackingRecorder::write() method logs RecordValue::Scalar values in the record as metrics. As an exception, opt_steps is treated as the step field of Mlflow’s metric data (https://mlflow.org/docs/latest/rest-api.html#metric).

Other types of values like RecordValue::Array1 will be ignored.

When dropped, this struct updates run’s status to “FINISHED” (https://mlflow.org/docs/latest/rest-api.html#mlflowrunstatus).

Implementations§

Source§

impl<E, R> MlflowTrackingRecorder<E, R>
where E: Env, R: ReplayBufferBase,

Source

pub fn new( base_url: &String, experiment_id: &String, run: Run, artifact_base: PathBuf, ) -> Result<Self>

Create a new instance of MlflowTrackingRecorder.

This method is used in MlflowTrackingClient::create_recorder().

This method adds a tag “host_start_time” with the current time. This tag is useful when using mlflow-export-import: it losts the original time. See https://github.com/mlflow/mlflow-export-import/issues/72

Source

pub fn log_params(&self, params: impl Serialize) -> Result<()>

Source

pub fn set_tag( &self, key: impl AsRef<str>, value: impl AsRef<str>, ) -> Result<()>

Set tag.

This method does not overwrite tags.

Source

pub fn set_tags<'a, T: AsRef<str> + Debug + 'a>( &self, tags: impl Into<&'a [(T, T)]>, ) -> Result<()>

Trait Implementations§

Source§

impl<E, R> Drop for MlflowTrackingRecorder<E, R>
where E: Env, R: ReplayBufferBase,

Source§

fn drop(&mut self)

Update run’s status to “FINISHED” when dropped.

It also adds tags “host_end_time” and “host_duration” with the current time and duration.

Source§

impl<E, R> Recorder<E, R> for MlflowTrackingRecorder<E, R>
where E: Env, R: ReplayBufferBase,

Source§

fn save_model(&self, base: &Path, agent: &Box<dyn Agent<E, R>>) -> Result<()>

Save model parameters as MLflow artifacts.

MLflow server is assumed to be running on the same host as the program using this struct. Under this condition, this method saves model parameters under the mlruns directory managed by the MLflow server. This method recognizes the environment variable MLFLOW_DEFAULT_ARTIFACT_ROOT as the location of the mlruns directory.

Source§

fn load_model( &self, base: &Path, agent: &mut Box<dyn Agent<E, R>>, ) -> Result<()>

Loads model parameters previously saved as MLflow artifacts.

This method uses MLFLOW_DEFAULT_ARTIFACT_ROOT environment variable as the directory where artifacts, like model parameters, will be saved. It is recommended to set this environment variable mlruns directory to which the tracking server persists experiment and run data.

Source§

fn write(&mut self, record: Record)

Writes a record to the recorder’s output destination. Read more
Source§

fn flush(&mut self, step: i64)

Writes aggregated values from stored records. Read more
Source§

fn store(&mut self, record: Record)

Stores a record for later processing or aggregation. Read more

Auto Trait Implementations§

§

impl<E, R> Freeze for MlflowTrackingRecorder<E, R>

§

impl<E, R> !RefUnwindSafe for MlflowTrackingRecorder<E, R>

§

impl<E, R> Send for MlflowTrackingRecorder<E, R>
where E: Send, R: Send,

§

impl<E, R> Sync for MlflowTrackingRecorder<E, R>
where E: Sync, R: Sync,

§

impl<E, R> Unpin for MlflowTrackingRecorder<E, R>
where E: Unpin, R: Unpin,

§

impl<E, R> !UnwindSafe for MlflowTrackingRecorder<E, R>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

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