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,
impl<E, R> MlflowTrackingRecorder<E, R>where
E: Env,
R: ReplayBufferBase,
Sourcepub fn new(
base_url: &String,
experiment_id: &String,
run: Run,
artifact_base: PathBuf,
) -> Result<Self>
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
pub fn log_params(&self, params: impl Serialize) -> Result<()>
Trait Implementations§
Source§impl<E, R> Drop for MlflowTrackingRecorder<E, R>where
E: Env,
R: ReplayBufferBase,
impl<E, R> Drop for MlflowTrackingRecorder<E, R>where
E: Env,
R: ReplayBufferBase,
Source§impl<E, R> Recorder<E, R> for MlflowTrackingRecorder<E, R>where
E: Env,
R: ReplayBufferBase,
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<()>
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<()>
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.