class gpr::track::MlflowRun

Overview

One MLflow run. More…

#include <gpr/auxiliary/MlflowFileStore.h>
 
class MlflowRun {
public:
    // enums
 
    enum Status;
 
    // structs
 
    struct Options;
    struct PendingMetric;
 
    // construction
 
    MlflowRun(const MlflowRun&);
    ~MlflowRun();
 
    // methods
 
    static std::unique_ptr<MlflowRun> start(const Options& options);
    MlflowRun& operator=(const MlflowRun&);
    void logParam(std::string_view key, std::string_view value);
    void logParam(std::string_view key, double value);
    void logParam(std::string_view key, long value);
    void logMetric(std::string_view key, double value, long step = 0);
    void setTag(std::string_view key, std::string_view value);
    void logArtifact(const std::filesystem::path& file, const std::string& name = “”);
    void appendRecord(std::string_view stream, const JsonRecord& record);
    void flush();
    void finish(Status status);
    const std::string& runId() const;
    const std::string& experimentId() const;
    const std::filesystem::path& runDirectory() const;
    bool streaming() const;
    std::string identityJson() const;
};

Detailed Documentation

One MLflow run. It is written directly in the tracking file-store layout under a store directory (mlruns/EXPERIMENT_ID/RUN_ID/{meta.yaml, params,metrics,tags,artifacts}, readable by mlflow ui --backend-store-uri `file:// <file://>`__<store>), and streamed to a running tracking server when a tracking URI is given: the run is created there with the same id, metrics/params/tags go out in log-batch requests on flush(), and the record streams are uploaded as artifacts at finish() when the server proxies artifacts. Metrics carry a step; records are JSON lines appended to a named stream under artifacts/, for the vectors a post-mortem of the surrogate needs.

Methods

static std::unique_ptr<MlflowRun> start(const Options& options)

Nullptr when neither a store nor a tracking URI is given. Throws on an unwritable store; a server that cannot be reached disables streaming with a warning and the local store continues.

void logArtifact(const std::filesystem::path& file, const std::string& name = “”)

Copy a file into artifacts/ (optionally under a relative name).

void appendRecord(std::string_view stream, const JsonRecord& record)

Append one JSON line to artifacts/STREAM_NAME.jsonl.

void flush()

Send buffered metrics, params and tags to the tracking server.

std::string identityJson() const

The run’s identity as JSON, for a caller that attaches later (the validation stage of a campaign runner).