From 725e3bb067c0a33d167af59a3e0badab77989298 Mon Sep 17 00:00:00 2001 From: Paul-Sanga Date: Tue, 30 Jun 2026 14:11:52 +0300 Subject: [PATCH 1/2] [Experiments Finalization] --- include/mlflow/client.hpp | 1 + include/mlflow/experiments.hpp | 1 + src/client.cpp | 6 ++++++ src/experiments.cpp | 25 +++++++++++++++++++++++++ tests/test_experiments.cpp | 6 ++++++ 5 files changed, 39 insertions(+) diff --git a/include/mlflow/client.hpp b/include/mlflow/client.hpp index f679aa1..5c379fc 100644 --- a/include/mlflow/client.hpp +++ b/include/mlflow/client.hpp @@ -43,6 +43,7 @@ class MlflowClient { Result get_experiment_by_name(const std::string &name); Result delete_experiment(const std::string& experiment_id); Result restore_experiment(const std::string& experiment_id); + Result update_experiment(const std::string& experiment_id, const std::string& new_name); private: std::unique_ptr transport_; diff --git a/include/mlflow/experiments.hpp b/include/mlflow/experiments.hpp index 722cbeb..7feeb11 100644 --- a/include/mlflow/experiments.hpp +++ b/include/mlflow/experiments.hpp @@ -27,6 +27,7 @@ class Experiments { Result get_experiment_by_name(const std::string &name); Result delete_experiment(const std::string& experiment_id); Result restore_experiment(const std::string& experiment_id); + Result update_experiment(const std::string& experiment_id, const std::string& new_name); private: HttpTransport &transport_; diff --git a/src/client.cpp b/src/client.cpp index fec776f..6a7d7bf 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -38,6 +38,12 @@ MlflowClient::restore_experiment(const std::string& experiment_id) return experiments_sub_.restore_experiment(experiment_id); } +Result +MlflowClient::update_experiment(const std::string& experiment_id, const std::string& new_name) +{ + return experiment_sub_.update_experiment(experiment_id, new_name); +} + Result MlflowClient::create_run(const std::string &experiment_id, const TimestampMs &start_time) { return runs_sub_.create_run(experiment_id, start_time); diff --git a/src/experiments.cpp b/src/experiments.cpp index e782384..3920190 100644 --- a/src/experiments.cpp +++ b/src/experiments.cpp @@ -127,4 +127,29 @@ Experiments::restore_experiment(const std::string& experiment_id) }; } +Result +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 \ No newline at end of file diff --git a/tests/test_experiments.cpp b/tests/test_experiments.cpp index 1dce399..de0ef12 100644 --- a/tests/test_experiments.cpp +++ b/tests/test_experiments.cpp @@ -110,4 +110,10 @@ TEST_F(MlflowCppClientFixture, RestoreExperiment) 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); } \ No newline at end of file From 9300f7432bd4a7274d1e1557691c80ac561535b8 Mon Sep 17 00:00:00 2001 From: Paul-Sanga Date: Tue, 30 Jun 2026 14:46:56 +0300 Subject: [PATCH 2/2] [update experiments] --- src/client.cpp | 2 +- src/experiments.cpp | 2 +- tests/test_experiments.cpp | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index 6a7d7bf..a3b7e0d 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -41,7 +41,7 @@ MlflowClient::restore_experiment(const std::string& experiment_id) Result MlflowClient::update_experiment(const std::string& experiment_id, const std::string& new_name) { - return experiment_sub_.update_experiment(experiment_id, new_name); + return experiments_sub_.update_experiment(experiment_id, new_name); } Result MlflowClient::create_run(const std::string &experiment_id, diff --git a/src/experiments.cpp b/src/experiments.cpp index 3920190..d97403e 100644 --- a/src/experiments.cpp +++ b/src/experiments.cpp @@ -130,7 +130,7 @@ Experiments::restore_experiment(const std::string& experiment_id) Result Experiments::update_experiment(const std::string& experiment_id, const std::string& new_name) { - json payload = {{ "experiment_id", experiment_id }, { "new_name": 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) diff --git a/tests/test_experiments.cpp b/tests/test_experiments.cpp index de0ef12..44f5b30 100644 --- a/tests/test_experiments.cpp +++ b/tests/test_experiments.cpp @@ -116,4 +116,13 @@ 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()); } \ No newline at end of file