Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/mlflow/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class MlflowClient {
Result<std::string> get_experiment_by_name(const std::string &name);
Result<std::string> delete_experiment(const std::string& experiment_id);
Result<std::string> restore_experiment(const std::string& experiment_id);
Result<std::string> update_experiment(const std::string& experiment_id, const std::string& new_name);

private:
std::unique_ptr<HttpTransport> transport_;
Expand Down
1 change: 1 addition & 0 deletions include/mlflow/experiments.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Experiments {
Result<std::string> get_experiment_by_name(const std::string &name);
Result<std::string> delete_experiment(const std::string& experiment_id);
Result<std::string> restore_experiment(const std::string& experiment_id);
Result<std::string> update_experiment(const std::string& experiment_id, const std::string& new_name);

private:
HttpTransport &transport_;
Expand Down
6 changes: 6 additions & 0 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ MlflowClient::restore_experiment(const std::string& experiment_id)
return experiments_sub_.restore_experiment(experiment_id);
}

Result<std::string>
MlflowClient::update_experiment(const std::string& experiment_id, const std::string& new_name)
{
return experiments_sub_.update_experiment(experiment_id, new_name);
}

Result<Run> MlflowClient::create_run(const std::string &experiment_id,
const TimestampMs &start_time) {
return runs_sub_.create_run(experiment_id, start_time);
Expand Down
25 changes: 25 additions & 0 deletions src/experiments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,29 @@ Experiments::restore_experiment(const std::string& experiment_id)
};
}

Result<std::string>
Experiments::update_experiment(const std::string& experiment_id, const std::string& new_name)
{
json payload = {{ "experiment_id", experiment_id }, { "new_name", new_name }};
auto res = transport_.post("/experiments/update", payload.dump());

if(res.status_code != 200)
{
return
{
.data = "",
.success = false,
.error_message = ""
};
}

auto res_json = json::parse(res.body);
return
{
.data = "",
.success = true,
.error_message = ""
};
}

} // namespace mlflow
15 changes: 15 additions & 0 deletions tests/test_experiments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,21 @@ TEST_F(MlflowCppClientFixture, RestoreExperiment)
ASSERT_TRUE(del_exp_res.data.empty());

auto res = client.restore_experiment(exp_res.data);
ASSERT_TRUE(res.success);
ASSERT_TRUE(res.data.empty());
}

TEST_F(MlflowCppClientFixture, UpdateExperiment)
{
std::string name = unique_name("update_experiment");
auto exp_res = client.create_experiment(name);

ASSERT_TRUE(exp_res.success);
EXPECT_FALSE(exp_res.data.empty());

std::string new_name = unique_name("new_experiment");
auto res = client.update_experiment(exp_res.data, new_name);

ASSERT_TRUE(res.success);
ASSERT_TRUE(res.data.empty());
}