Skip to content

Commit

Permalink
ExperimentUtils: Add experimentRootFromString()
Browse files Browse the repository at this point in the history
  • Loading branch information
Lehdari committed Apr 27, 2023
1 parent 1f7f094 commit b380fa5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/util/ExperimentUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
#include <nlohmann/json.hpp>

#include <string>
#include <filesystem>


std::string formatExperimentName(const std::string& name, const nlohmann::json& modelConfig);

// Convert a string to an experiment root path.
// Relative paths are considered to be relative to the experiments directory (doot2::experimentsDirectory)
std::filesystem::path experimentRootFromString(const std::string& experimentRoot);
9 changes: 9 additions & 0 deletions src/util/ExperimentUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//

#include "util/ExperimentUtils.hpp"
#include "Constants.hpp"

#include <sstream>
#include <regex>
Expand All @@ -33,3 +34,11 @@ std::string formatExperimentName(const std::string& name, const nlohmann::json&

return experimentName;
}

std::filesystem::path experimentRootFromString(const std::string& experimentRoot)
{
std::filesystem::path root = experimentRoot;
if (!root.is_absolute())
root = doot2::experimentsDirectory / root;
return root;
}

0 comments on commit b380fa5

Please sign in to comment.