Skip to content

Commit a865d75

Browse files
committed
[MINOR] Federated Planner Test
Add different configs for federated L2SVM and add test cases. Closes apache#1563.
1 parent 9270a03 commit a865d75

File tree

4 files changed

+73
-6
lines changed

4 files changed

+73
-6
lines changed

src/main/java/org/apache/sysds/hops/cost/HopRel.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,10 @@ public String toString(){
196196
strB.append(", FedOut: ");
197197
strB.append(fedOut);
198198
strB.append(", Cost: ");
199-
strB.append(cost);
200-
strB.append(", Number of inputs: ");
201-
strB.append(inputDependency.size());
199+
strB.append(cost.getTotal());
200+
strB.append(", Inputs: ");
201+
strB.append(inputDependency.stream().map(i -> "{" + i.getHopRef().getHopID() +
202+
", " + i.getFederatedOutput() + "}").collect(Collectors.toList()));
202203
strB.append("}");
203204
return strB.toString();
204205
}

src/test/java/org/apache/sysds/test/functions/privacy/fedplanning/FederatedL2SVMPlanningTest.java

+23-3
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ public class FederatedL2SVMPlanningTest extends AutomatedTestBase {
4343
private final static String TEST_DIR = "functions/privacy/fedplanning/";
4444
private final static String TEST_NAME = "FederatedL2SVMPlanningTest";
4545
private final static String TEST_CLASS_DIR = TEST_DIR + FederatedL2SVMPlanningTest.class.getSimpleName() + "/";
46-
private final static String TEST_CONF = "SystemDS-config-fout.xml";
47-
private final static File TEST_CONF_FILE = new File(SCRIPT_DIR + TEST_DIR, TEST_CONF);
46+
private static File TEST_CONF_FILE;
4847

4948
private final static int blocksize = 1024;
5049
public final int rows = 100;
@@ -57,12 +56,33 @@ public void setUp() {
5756
}
5857

5958
@Test
60-
public void runL2SVMTest(){
59+
public void runL2SVMFOUTTest(){
6160
String[] expectedHeavyHitters = new String[]{ "fed_fedinit", "fed_ba+*", "fed_tak+*", "fed_+*",
6261
"fed_max", "fed_1-*", "fed_tsmm", "fed_>"};
62+
setTestConf("SystemDS-config-fout.xml");
6363
loadAndRunTest(expectedHeavyHitters);
6464
}
6565

66+
@Test
67+
public void runL2SVMHeuristicTest(){
68+
String[] expectedHeavyHitters = new String[]{ "fed_fedinit", "fed_ba+*"};
69+
setTestConf("SystemDS-config-heuristic.xml");
70+
loadAndRunTest(expectedHeavyHitters);
71+
}
72+
73+
@Test
74+
public void runL2SVMCostBasedTest(){
75+
//String[] expectedHeavyHitters = new String[]{ "fed_fedinit", "fed_ba+*", "fed_tak+*", "fed_+*",
76+
// "fed_max", "fed_1-*", "fed_tsmm", "fed_>"};
77+
String[] expectedHeavyHitters = new String[]{ "fed_fedinit"};
78+
setTestConf("SystemDS-config-cost-based.xml");
79+
loadAndRunTest(expectedHeavyHitters);
80+
}
81+
82+
private void setTestConf(String test_conf){
83+
TEST_CONF_FILE = new File(SCRIPT_DIR + TEST_DIR, test_conf);
84+
}
85+
6686
private void writeInputMatrices(){
6787
writeStandardRowFedMatrix("X1", 65, null);
6888
writeStandardRowFedMatrix("X2", 75, null);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!--
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
-->
19+
20+
<root>
21+
<!-- set the federated plan generator (none, [runtime], compile_fed_all, compile_fed_heuristic, compile_cost_based) -->
22+
<sysds.federated.planner>compile_cost_based</sysds.federated.planner>
23+
</root>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!--
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
-->
19+
20+
<root>
21+
<!-- set the federated plan generator (none, [runtime], compile_fed_all, compile_fed_heuristic, compile_cost_based) -->
22+
<sysds.federated.planner>compile_fed_heuristic</sysds.federated.planner>
23+
</root>

0 commit comments

Comments
 (0)