Skip to content

Commit

Permalink
DPL: add edge validator for expendable tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
ktf committed Nov 23, 2023
1 parent 5029fe4 commit 791e1a6
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion Framework/Core/src/WorkflowHelpers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1232,12 +1232,31 @@ std::vector<InputSpec> WorkflowHelpers::computeDanglingOutputs(WorkflowSpec cons
return results;
}

bool validateExpendable(std::ostream& errors, DataProcessorSpec const& producer, OutputSpec const& output, DataProcessorSpec const& consumer, InputSpec const& input)
{
auto isExpendable = [](DataProcessorLabel const& label) {
return label.value == "expendable";
};
auto isResilient = [](DataProcessorLabel const& label) {
return label.value == "expendable" || label.value == "resilient";
};
bool producerExpendable = std::find_if(producer.labels.begin(), producer.labels.end(), isExpendable) != producer.labels.end();
bool consumerCritical = std::find_if(consumer.labels.begin(), consumer.labels.end(), isResilient) == consumer.labels.end();
if (producerExpendable && consumerCritical) {
errors << fmt::format("Critical consumer {} depends on expendable producer {}\n",
consumer.name,
producer.name);
return false;
}
return true;
}

using Validator = std::function<bool(std::ostream& errors, DataProcessorSpec const& producer, OutputSpec const& output, DataProcessorSpec const& consumer, InputSpec const& input)>;
void WorkflowHelpers::validateEdges(WorkflowSpec const& workflow,
std::vector<DeviceConnectionEdge> const& edges,
std::vector<OutputSpec> const& outputs)
{
std::vector<Validator> defaultValidators = {};
std::vector<Validator> defaultValidators = {validateExpendable};
std::stringstream errors;
// Iterate over all the edges.
// Get the input lifetime and the output lifetime.
Expand Down

0 comments on commit 791e1a6

Please sign in to comment.