Skip to content

Commit

Permalink
Enable Mirror of inherited variables
Browse files Browse the repository at this point in the history
Re ECFLOW-1999
  • Loading branch information
marcosbento committed Feb 3, 2025
1 parent fef041c commit c7aa1bc
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
3 changes: 3 additions & 0 deletions libs/node/src/ecflow/node/MirrorAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ void MirrorAttr::mirror() {

// ** Node Variables
std::vector<Variable> all_variables = notification.data().regular_variables;
for (const auto& variable : notification.data().inherited_variables) {
all_variables.push_back(variable);
}
for (const auto& variable : notification.data().generated_variables) {
all_variables.push_back(variable);
}
Expand Down
18 changes: 18 additions & 0 deletions libs/node/src/ecflow/node/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2652,6 +2652,24 @@ size_t Node::position() const {
return std::numeric_limits<std::size_t>::max();
}

std::vector<Variable> Node::get_all_inherited_variables() const {
std::vector<Variable> all;
const Node* current = this->parent();

std::set<std::string> cache;
while (current) {
for (const Variable& var : current->variables()) {
if (auto found = std::find(std::begin(cache), std::end(cache), var.name()); found == std::end(cache)) {
cache.insert(var.name());
all.push_back(var);
}
}
current = current->parent();
}

return all;
}

std::vector<Variable> Node::get_all_generated_variables() const {
std::vector<Variable> all;
const Node* current = this;
Expand Down
1 change: 1 addition & 0 deletions libs/node/src/ecflow/node/Node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ class Node : public std::enable_shared_from_this<Node> {
void replace_meters(const std::vector<Meter>& meters);
void replace_events(const std::vector<Event>& events);

std::vector<Variable> get_all_inherited_variables() const;
std::vector<Variable> get_all_generated_variables() const;

// Add functions: ===============================================================
Expand Down
1 change: 1 addition & 0 deletions libs/service/src/ecflow/service/mirror/MirrorClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ MirrorData MirrorClient::get_node_status(const std::string& remote_host,

// ** Node Variables
data.regular_variables = node->variables();
data.inherited_variables = node->get_all_inherited_variables();
data.generated_variables = node->get_all_generated_variables();

// Filter out the Definitions structural variables (SUITE, to avoid conflicts with "local" side definitions
Expand Down
11 changes: 10 additions & 1 deletion libs/service/src/ecflow/service/mirror/MirrorClient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,19 @@ namespace ecf::service::mirror {

struct MirrorData
{
MirrorData() : state{0}, regular_variables{}, generated_variables{}, labels{}, meters{}, events{} {}
MirrorData()
: state{0},
regular_variables{},
inherited_variables{},
generated_variables{},
labels{},
meters{},
events{} {}

explicit MirrorData(int state)
: state{state},
regular_variables{},
inherited_variables{},
generated_variables{},
labels{},
meters{},
Expand All @@ -35,6 +43,7 @@ struct MirrorData
int state;

std::vector<Variable> regular_variables;
std::vector<Variable> inherited_variables;
std::vector<Variable> generated_variables;

std::vector<Label> labels;
Expand Down

0 comments on commit c7aa1bc

Please sign in to comment.