Skip to content

Commit

Permalink
Fix -arch-content bug in report yaml parser
Browse files Browse the repository at this point in the history
  • Loading branch information
colby-nyce authored and klingaard committed Jan 7, 2025
1 parent e736f0d commit 45621c7
Showing 1 changed file with 57 additions and 45 deletions.
102 changes: 57 additions & 45 deletions sparta/src/Report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,10 @@ class ReportFileParserYAML
std::stringstream ss;
ss << "Unexpected key \"content\" within a \"content\" section";
addError_(ss.str());
}else{
if (!tryHandleArchContent_(key)) {
return false;
}
}
return true; // Handle normally
}else{
Expand All @@ -753,51 +757,8 @@ class ReportFileParserYAML
in_content_stack_.push(false);
return false;
}else{
const auto idx = key.find("-arch-content");
if (idx != std::string::npos) {
app::Simulation *sim = nullptr;
if (base_report_) {
if (auto ctx = base_report_->getContext()) {
sim = ctx->getSimulation();
}
}

if (!sim) {
throw SpartaException("Could not get the app::Simulation to parse key: ") << key;
}

if (auto sim_config = sim->getSimulationConfiguration()) {
skip_content_leaves_ = true;
bool dash_arch_given = false;
for (const auto &kvp : sim_config->getRunMetadata()) {
if (kvp.first == "arch") {
dash_arch_given = true;
if (kvp.second + "-arch-content" == key) {
skip_content_leaves_ = false;
break;
}
}
}

if (!dash_arch_given) {
skip_content_leaves_ = false;
verbose() << indent_() << "WARNING: You should consider using --arch at "
<< "the command line together with the *-arch-content blocks "
<< "in your report definition YAML file. This content block "
<< "will be treated as normal (not filtered for --arch)."
<< std::endl;
}

if (skip_content_leaves_) {
verbose() << indent_() << "Skipping '" << key << "' block since it does "
<< "not match the --arch given at the command line.";
}

in_content_stack_.push(true);
return false;
} else {
throw SpartaException("Could not get the app::SimulationConfiguration to parse key: ") << key;
}
if (!tryHandleArchContent_(key)) {
return false;
}

//std::stringstream ss;
Expand Down Expand Up @@ -958,6 +919,57 @@ class ReportFileParserYAML
return true; // Handle normally
}

bool tryHandleArchContent_(const std::string& key) {
const auto idx = key.find("-arch-content");
if (idx != std::string::npos) {
app::Simulation *sim = nullptr;
if (base_report_) {
if (auto ctx = base_report_->getContext()) {
sim = ctx->getSimulation();
}
}

if (!sim) {
throw SpartaException("Could not get the app::Simulation to parse key: ") << key;
}

if (auto sim_config = sim->getSimulationConfiguration()) {
skip_content_leaves_ = true;
bool dash_arch_given = false;
for (const auto &kvp : sim_config->getRunMetadata()) {
if (kvp.first == "arch") {
dash_arch_given = true;
if (kvp.second + "-arch-content" == key) {
skip_content_leaves_ = false;
break;
}
}
}

if (!dash_arch_given) {
skip_content_leaves_ = false;
verbose() << indent_() << "WARNING: You should consider using --arch at "
<< "the command line together with the *-arch-content blocks "
<< "in your report definition YAML file. This content block "
<< "will be treated as normal (not filtered for --arch)."
<< std::endl;
}

if (skip_content_leaves_) {
verbose() << indent_() << "Skipping '" << key << "' block since it does "
<< "not match the --arch given at the command line.";
}

in_content_stack_.push(true);
return false;
} else {
throw SpartaException("Could not get the app::SimulationConfiguration to parse key: ") << key;
}
}

return true;
}

/*!
* \brief Hanle next-node generation in a way that a next generation of
* nodes is assigned specific new UIDs based on what report was created
Expand Down

0 comments on commit 45621c7

Please sign in to comment.