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

Get ExecGraph hosts #178

Merged
merged 5 commits into from
Nov 23, 2021
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
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FAABRIC_VERSION=0.2.1
FAABRIC_CLI_IMAGE=faasm/faabric:0.2.1
FAABRIC_VERSION=0.2.2
FAABRIC_CLI_IMAGE=faasm/faabric:0.2.2
COMPOSE_PROJECT_NAME=faabric-dev
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
REDIS_QUEUE_HOST: redis
REDIS_STATE_HOST: redis
container:
image: faasm/faabric:0.2.1
image: faasm/faabric:0.2.2
defaults:
run:
working-directory: /code/faabric
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
REDIS_QUEUE_HOST: redis
REDIS_STATE_HOST: redis
container:
image: faasm/faabric:0.2.1
image: faasm/faabric:0.2.2
defaults:
run:
working-directory: /code/faabric
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
REDIS_QUEUE_HOST: redis
REDIS_STATE_HOST: redis
container:
image: faasm/faabric:0.2.1
image: faasm/faabric:0.2.2
defaults:
run:
working-directory: /code/faabric
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.1
0.2.2
2 changes: 1 addition & 1 deletion docker/faabric.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM faasm/faabric-base:0.2.0
FROM faasm/faabric-base:0.2.2
ARG FAABRIC_VERSION

# faabic-base image is not re-built often, so tag may be behind
Expand Down
5 changes: 5 additions & 0 deletions include/faabric/scheduler/ExecGraph.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#pragma once

#include <faabric/proto/faabric.pb.h>

#include <set>
#include <vector>

namespace faabric::scheduler {

struct ExecGraphNode
{
faabric::Message msg;
Expand All @@ -17,6 +20,8 @@ struct ExecGraph

int countExecGraphNodes(const ExecGraph& graph);

std::set<std::string> getExecGraphHosts(const ExecGraph& graph);

std::string execNodeToJson(const ExecGraphNode& node);

std::string execGraphToJson(const ExecGraph& graph);
Expand Down
2 changes: 1 addition & 1 deletion mpi-native/mpi-native.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FAABRIC_VERSION=0.2.1
FAABRIC_VERSION=0.2.2
FAABRIC_MPI_NATIVE_IMAGE=faasm/faabric-mpi-native:0.0.18
COMPOSE_PROJECT_NAME=faabric-mpi

Expand Down
18 changes: 18 additions & 0 deletions src/scheduler/ExecGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ int countExecGraphNodes(const ExecGraph& graph)
return count;
}

std::set<std::string> getExecGraphHostsForNode(const ExecGraphNode& node)
{
std::set<std::string> hostsForNode;
hostsForNode.insert(node.msg.executedhost());

for (auto c : node.children) {
std::set<std::string> nodeHost = getExecGraphHostsForNode(c);
hostsForNode.insert(nodeHost.begin(), nodeHost.end());
}

return hostsForNode;
}

std::set<std::string> getExecGraphHosts(const ExecGraph& graph)
{
return getExecGraphHostsForNode(graph.rootNode);
}

// ----------------------------------------
// TODO - do this with RapidJson and not sstream
// ----------------------------------------
Expand Down
22 changes: 22 additions & 0 deletions tests/test/scheduler/test_exec_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,28 @@ TEST_CASE("Test execution graph", "[scheduler][exec-graph]")
checkExecGraphEquality(expected, actual);
}

TEST_CASE("Test get unique hosts from exec graph", "[scheduler][exec-graph]")
{
faabric::Message msgA = faabric::util::messageFactory("demo", "echo");
faabric::Message msgB1 = faabric::util::messageFactory("demo", "echo");
faabric::Message msgB2 = faabric::util::messageFactory("demo", "echo");

msgA.set_executedhost("foo");
msgB1.set_executedhost("bar");
msgB2.set_executedhost("baz");

ExecGraphNode nodeB1 = { .msg = msgB1 };
ExecGraphNode nodeB2 = { .msg = msgB2 };
ExecGraphNode nodeB3 = { .msg = msgB2 };
ExecGraphNode nodeA = { .msg = msgA,
.children = { nodeB1, nodeB2, nodeB3 } };

ExecGraph graph{ .rootNode = nodeA };
std::set<std::string> expected = { "bar", "baz", "foo" };
auto hosts = faabric::scheduler::getExecGraphHosts(graph);
REQUIRE(hosts == expected);
}

TEST_CASE_METHOD(MpiBaseTestFixture,
"Test MPI execution graph",
"[mpi][scheduler][exec-graph]")
Expand Down