Skip to content

Commit e1295ff

Browse files
committed
Warn on unused restart config
1 parent 8fdeb39 commit e1295ff

1 file changed

Lines changed: 26 additions & 7 deletions

File tree

src/IO/JSON/JSONIOHandlerImpl.cpp

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,30 @@ namespace
144144
return *accum_ptr;
145145
}
146146

147-
void warnUnusedJson(openPMD::json::TracingJSON const &jsonConfig)
147+
auto prepend_to_json(nlohmann::json j) -> nlohmann::json
148+
{
149+
return j;
150+
}
151+
152+
template <typename Arg, typename... Args>
153+
auto prepend_to_json(nlohmann::json j, Arg &&arg, Args &&...args)
154+
-> nlohmann::json
155+
{
156+
return nlohmann::json{
157+
{std::forward<Arg>(arg),
158+
prepend_to_json(std::move(j), std::forward<Args>(args)...)}};
159+
}
160+
161+
template <typename... Args>
162+
void warnUnusedJson(
163+
openPMD::json::TracingJSON const &jsonConfig,
164+
Args &&...extra_json_hierarchy)
148165
{
149166
auto shadow = jsonConfig.invertShadow();
150167
if (shadow.size() > 0)
151168
{
169+
shadow = prepend_to_json(
170+
std::move(shadow), std::forward<Args>(extra_json_hierarchy)...);
152171
switch (jsonConfig.originallySpecifiedAs)
153172
{
154173
case openPMD::json::SupportedLanguages::JSON:
@@ -2425,14 +2444,14 @@ JSONIOHandlerImpl::obtainJsonContents(File const &file)
24252444
return std::nullopt;
24262445
}
24272446
}();
2447+
auto manual_config = m_deferredExternalBlockstorageConfig.has_value()
2448+
? std::move(*m_deferredExternalBlockstorageConfig)
2449+
: openPMD::json::TracingJSON();
24282450
parse_external_mode(
2429-
m_deferredExternalBlockstorageConfig.has_value()
2430-
? std::move(*m_deferredExternalBlockstorageConfig)
2431-
: openPMD::json::TracingJSON(),
2432-
previousConfig,
2433-
backendConfigKey(),
2434-
m_datasetMode);
2451+
manual_config, previousConfig, backendConfigKey(), m_datasetMode);
2452+
warnUnusedJson(manual_config, "dataset", "mode");
24352453
m_attributeMode.m_specificationVia = SpecificationVia::Manually;
2454+
24362455
m_deferredExternalBlockstorageConfig.reset();
24372456
}
24382457

0 commit comments

Comments
 (0)