Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check for expected keys to TaskComposerGraph #477

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

17 changes: 11 additions & 6 deletions tesseract_task_composer/core/src/task_composer_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
#include <yaml-cpp/yaml.h>
#include <tesseract_common/serialization.h>
#include <tesseract_common/plugin_info.h>
#include <tesseract_common/yaml_utils.h>
TESSERACT_COMMON_IGNORE_WARNINGS_POP

#include <tesseract_task_composer/core/task_composer_graph.h>
Expand Down Expand Up @@ -70,13 +71,20 @@ TaskComposerGraph::TaskComposerGraph(std::string name,
const TaskComposerPluginFactory& plugin_factory)
: TaskComposerNode(std::move(name), type, TaskComposerNodePorts{}, config)
{
static const std::set<std::string> graph_expected_keys{ "conditional", "inputs", "outputs",
"nodes", "edges", "terminals" };
tesseract_common::checkForUnknownKeys(config, graph_expected_keys);

std::unordered_map<std::string, boost::uuids::uuid> node_uuids;
YAML::Node nodes = config["nodes"];
if (!nodes.IsMap())
throw std::runtime_error("Task Composer Graph '" + name_ + "' 'nodes' entry is not a map");

for (auto node_it = nodes.begin(); node_it != nodes.end(); ++node_it)
{
static const std::set<std::string> nodes_expected_keys{ "class", "task", "config" };
tesseract_common::checkForUnknownKeys(node_it->second, nodes_expected_keys);

auto node_name = node_it->first.as<std::string>();
if (YAML::Node fn = node_it->second["class"])
{
Expand All @@ -103,6 +111,9 @@ TaskComposerGraph::TaskComposerGraph(std::string name,

if (YAML::Node tc = node_it->second["config"])
{
static const std::set<std::string> tasks_expected_keys{ "conditional", "abort_terminal", "remapping" };
tesseract_common::checkForUnknownKeys(tc, tasks_expected_keys);

if (YAML::Node n = tc["conditional"])
task_node->setConditional(n.as<bool>());

Expand All @@ -115,12 +126,6 @@ TaskComposerGraph::TaskComposerGraph(std::string name,
throw std::runtime_error("YAML entry 'abort_terminal' is only supported for GRAPH and PIPELINE types");
}

if (tc["input_remapping"]) // NOLINT
throw std::runtime_error("TaskComposerGraph, input_remapping is no longer supported use 'remapping'");

if (tc["output_remapping"]) // NOLINT
throw std::runtime_error("TaskComposerGraph, output_remapping is no longer supported use 'remapping'");

if (YAML::Node n = tc["remapping"])
{
auto remapping = n.as<std::map<std::string, std::string>>();
Expand Down
Loading