Skip to content

Commit 591a611

Browse files
committed
[RF][HS3] Remove remnants of YAML IO
1 parent 8a60d4a commit 591a611

5 files changed

Lines changed: 0 additions & 160 deletions

File tree

roofit/doc/developers/roofit_hs3.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,6 @@ with other statistical frameworks, and also ease of manipulation, it
1616
may be useful to store statistical models in text form. This library
1717
sets out to achieve exactly that, exporting to and importing from JSON.
1818

19-
### Backend
20-
21-
The default backend for this is the `nlohmann` JSON implementation,
22-
which ships with ROOT as a builtin dependency and will import from and
23-
export to JSON.
24-
In the past, RapidYAML (`RYML`) was supported, but the effort to keep
25-
this implementation up to date was too high. YML users could use YML to
26-
JSON converters to migrate.
27-
2819
### Usage
2920

3021
The main class providing import from and export to JSON is the

roofit/hs3/inc/RooFitHS3/RooJSONFactoryWSTool.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,18 +145,12 @@ class RooJSONFactoryWSTool {
145145
readBinnedData(const RooFit::Detail::JSONNode &n, const std::string &namecomp, RooArgSet const &vars);
146146

147147
bool importJSON(std::string const &filename);
148-
bool importYML(std::string const &filename);
149148
bool importJSON(std::istream &os);
150-
bool importYML(std::istream &os);
151149
bool exportJSON(std::string const &fileName);
152-
bool exportYML(std::string const &fileName);
153150
bool exportJSON(std::ostream &os);
154-
bool exportYML(std::ostream &os);
155151

156152
std::string exportJSONtoString();
157-
std::string exportYMLtoString();
158153
bool importJSONfromString(const std::string &s);
159-
bool importYMLfromString(const std::string &s);
160154
void importJSONElement(const std::string &name, const std::string &jsonString);
161155
void importVariableElement(const RooFit::Detail::JSONNode &n);
162156

roofit/hs3/src/RooJSONFactoryWSTool.cxx

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -2040,18 +2040,6 @@ bool RooJSONFactoryWSTool::importJSONfromString(const std::string &s)
20402040
return importJSON(ss);
20412041
}
20422042

2043-
/**
2044-
* @brief Import the workspace from a YML string.
2045-
*
2046-
* @param s The YML string containing the workspace data.
2047-
* @return bool Returns true on successful import, false otherwise.
2048-
*/
2049-
bool RooJSONFactoryWSTool::importYMLfromString(const std::string &s)
2050-
{
2051-
std::stringstream ss(s);
2052-
return importYML(ss);
2053-
}
2054-
20552043
/**
20562044
* @brief Export the workspace to a JSON string.
20572045
*
@@ -2064,18 +2052,6 @@ std::string RooJSONFactoryWSTool::exportJSONtoString()
20642052
return ss.str();
20652053
}
20662054

2067-
/**
2068-
* @brief Export the workspace to a YML string.
2069-
*
2070-
* @return std::string The YML string representing the exported workspace.
2071-
*/
2072-
std::string RooJSONFactoryWSTool::exportYMLtoString()
2073-
{
2074-
std::stringstream ss;
2075-
exportYML(ss);
2076-
return ss.str();
2077-
}
2078-
20792055
/**
20802056
* @brief Create a new JSON tree with version information.
20812057
*
@@ -2131,35 +2107,6 @@ bool RooJSONFactoryWSTool::exportJSON(std::string const &filename)
21312107
return this->exportJSON(out);
21322108
}
21332109

2134-
/**
2135-
* @brief Export the workspace to YML format and write to the output stream.
2136-
*
2137-
* @param os The output stream to write the YML data to.
2138-
* @return bool Returns true on successful export, false otherwise.
2139-
*/
2140-
bool RooJSONFactoryWSTool::exportYML(std::ostream &os)
2141-
{
2142-
std::unique_ptr<JSONTree> tree = createNewJSONTree();
2143-
JSONNode &n = tree->rootnode();
2144-
this->exportAllObjects(n);
2145-
n.writeYML(os);
2146-
return true;
2147-
}
2148-
2149-
/**
2150-
* @brief Export the workspace to YML format and write to the specified file.
2151-
*
2152-
* @param filename The name of the YML file to create and write the data to.
2153-
* @return bool Returns true on successful export, false otherwise.
2154-
*/
2155-
bool RooJSONFactoryWSTool::exportYML(std::string const &filename)
2156-
{
2157-
std::ofstream out(filename.c_str());
2158-
if (!out.is_open())
2159-
RooJSONFactoryWSTool::error("RooJSONFactoryWSTool() invalid output file '" + filename + "'.");
2160-
return this->exportYML(out);
2161-
}
2162-
21632110
bool RooJSONFactoryWSTool::hasAttribute(const std::string &obj, const std::string &attrib)
21642111
{
21652112
if (!_attributesNode)
@@ -2366,37 +2313,6 @@ bool RooJSONFactoryWSTool::importJSON(std::string const &filename)
23662313
return this->importJSON(infile);
23672314
}
23682315

2369-
/**
2370-
* @brief Imports a YML file from the given input stream to the workspace.
2371-
*
2372-
* @param is The input stream containing the YML data.
2373-
* @return bool Returns true on successful import, false otherwise.
2374-
*/
2375-
bool RooJSONFactoryWSTool::importYML(std::istream &is)
2376-
{
2377-
// import a YML file to the workspace
2378-
std::unique_ptr<JSONTree> tree = JSONTree::create(is);
2379-
JSONNode const &rootnode = tree->rootnode();
2380-
this->importAllNodes(rootnode);
2381-
importParameterStepWidths(*this->workspace(), rootnode);
2382-
return true;
2383-
}
2384-
2385-
/**
2386-
* @brief Imports a YML file from the given filename to the workspace.
2387-
*
2388-
* @param filename The name of the YML file to import.
2389-
* @return bool Returns true on successful import, false otherwise.
2390-
*/
2391-
bool RooJSONFactoryWSTool::importYML(std::string const &filename)
2392-
{
2393-
// import a YML file to the workspace
2394-
std::ifstream infile(filename.c_str());
2395-
if (!infile.is_open())
2396-
RooJSONFactoryWSTool::error("RooJSONFactoryWSTool() invalid input file '" + filename + "'.");
2397-
return this->importYML(infile);
2398-
}
2399-
24002316
void RooJSONFactoryWSTool::importJSONElement(const std::string &name, const std::string &jsonString)
24012317
{
24022318
// Create the JSON Tree from the string

roofit/jsoninterface/inc/RooFit/Detail/JSONInterface.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,17 +210,7 @@ class JSONTree {
210210
static std::unique_ptr<JSONTree> create(std::istream &is);
211211
static std::unique_ptr<JSONTree> create(std::string const &str);
212212

213-
static std::string getBackend();
214-
static void setBackend(std::string const &name);
215-
216-
static bool hasBackend(std::string const &name);
217-
218213
private:
219-
// Internally, we store the backend type with an enum to be more memory efficient.
220-
enum class Backend { NlohmannJson, Ryml };
221-
222-
static Backend &getBackendEnum();
223-
224214
template <typename... Args>
225215
static std::unique_ptr<JSONTree> createImpl(Args &&...args);
226216
};

roofit/jsoninterface/src/JSONInterface.cxx

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
#include <RooFit/Detail/JSONInterface.h>
1414

1515
#include "JSONParser.h"
16-
#ifdef ROOFIT_WITH_RYML
17-
#include "RYMLParser.h"
18-
#endif
1916

2017
#include <sstream>
2118

@@ -79,13 +76,6 @@ std::ostream &operator<<(std::ostream &os, JSONNode const &s)
7976
template <typename... Args>
8077
std::unique_ptr<JSONTree> JSONTree::createImpl(Args &&...args)
8178
{
82-
if (getBackendEnum() == Backend::Ryml) {
83-
#ifdef ROOFIT_WITH_RYML
84-
return std::make_unique<TRYMLTree>(std::forward<Args>(args)...);
85-
#else
86-
throw std::runtime_error("Requesting JSON tree with rapidyaml backend, which is currently unsupported.");
87-
#endif
88-
}
8979
return std::make_unique<TJSONTree>(std::forward<Args>(args)...);
9080
}
9181

@@ -105,46 +95,5 @@ std::unique_ptr<JSONTree> JSONTree::create(std::string const &str)
10595
return JSONTree::create(ss);
10696
}
10797

108-
/// Check if ROOT was compiled with support for a certain JSON backend library.
109-
/// \param[in] name Name of the backend.
110-
bool JSONTree::hasBackend(std::string const &name)
111-
{
112-
if (name == "rapidyaml") {
113-
#ifdef ROOFIT_WITH_RYML
114-
return true;
115-
#else
116-
return false;
117-
#endif
118-
}
119-
if (name == "nlohmann-json")
120-
return true;
121-
return false;
122-
}
123-
124-
JSONTree::Backend &JSONTree::getBackendEnum()
125-
{
126-
static Backend backend = Backend::NlohmannJson;
127-
return backend;
128-
}
129-
130-
/// Returns the name of the library that serves as the backend for the JSON
131-
/// interface, which is either `"nlohmann-json"` or `"rapidyaml"`.
132-
/// \return Backend name as a string.
133-
std::string JSONTree::getBackend()
134-
{
135-
return getBackendEnum() == Backend::Ryml ? "rapidyaml" : "nlohmann-json";
136-
}
137-
138-
/// Set the library that serves as the backend for the JSON interface. Note that the `"rapidyaml"` backend is only
139-
/// supported if rapidyaml was found on the system when ROOT was compiled. \param[in] name Name of the backend, can be
140-
/// either `"nlohmann-json"` or `"rapidyaml"`.
141-
void JSONTree::setBackend(std::string const &name)
142-
{
143-
if (name == "rapidyaml")
144-
getBackendEnum() = Backend::Ryml;
145-
if (name == "nlohmann-json")
146-
getBackendEnum() = Backend::NlohmannJson;
147-
}
148-
14998
} // namespace Detail
15099
} // namespace RooFit

0 commit comments

Comments
 (0)