Skip to content

Commit

Permalink
Merge pull request #830 from zinggAI/relate
Browse files Browse the repository at this point in the history
junit issues resolved
  • Loading branch information
sonalgoyal authored May 13, 2024
2 parents ad86c08 + 109d81d commit 1a4e971
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ public abstract class ExecutorTester<S, D, R, C, T> {

public static final Log LOG = LogFactory.getLog(ExecutorTester.class);

public ZinggBaseCommon<S,D, R, C, T> executor;
public ZinggBase<S,D, R, C, T> executor;

public ExecutorTester(ZinggBaseCommon<S, D, R, C, T> executor) {
public ExecutorTester(ZinggBase<S, D, R, C, T> executor) {
this.executor = executor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public LabellerTester(Labeller<S, D, R, C, T> executor) {
public void validateResults() throws ZinggClientException {
// check that marked data has at least 1 match row and 1 unmatch row
ZFrame<D, R, C> dfMarked = executor.getContext().getPipeUtil().
read(false, false, executor.getContext().getPipeUtil().getTrainingDataMarkedPipe(executor.getArgs()));
read(false, false, executor.getContext().getModelHelper().getTrainingDataMarkedPipe(executor.getArgs()));

C matchCond = dfMarked.equalTo(ColName.MATCH_FLAG_COL, 1);
C notMatchCond = dfMarked.equalTo(ColName.MATCH_FLAG_COL, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public TrainingDataFinderTester(TrainingDataFinder<S, D, R, C, T> executor) {
public void validateResults() throws ZinggClientException {
// check that unmarked data has at least 10 rows
ZFrame<D, R, C> df = executor.getContext().getPipeUtil().read(false, false,
executor.getContext().getPipeUtil().getTrainingDataUnmarkedPipe(
executor.getContext().getModelHelper().getTrainingDataUnmarkedPipe(
(executor.getArgs())));

long trainingDataCount = df.count();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void testSetColumnOptionThroughBuildAndSetArguments() {
Client client = new SparkClient();
client.buildAndSetArguments(arguments, options);

assertEquals("columnName", client.getArguments().getColumn());
assertEquals("columnName", ((IArguments)client.getArguments()).getColumn());
}


Expand Down
3 changes: 2 additions & 1 deletion spark/core/src/test/java/zingg/TestDocumenter.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.junit.jupiter.api.BeforeEach;

import zingg.common.client.Arguments;
import zingg.common.client.IArguments;
import zingg.spark.core.executor.ZinggSparkTester;

public class TestDocumenter extends ZinggSparkTester{
Expand All @@ -12,7 +13,7 @@ public class TestDocumenter extends ZinggSparkTester{
public void setUp(){

try {
args = argsUtil.createArgumentsFromJSON(getClass().getResource("/testDocumenter/config.json").getFile());
args = (IArguments) argsUtil.createArgumentsFromJSON(getClass().getResource("/testDocumenter/config.json").getFile());
//fail("Exception was expected for missing config file");
} catch (Throwable e) {
e.printStackTrace();
Expand Down
3 changes: 2 additions & 1 deletion spark/core/src/test/java/zingg/TestFebrlDataset.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.junit.jupiter.api.Test;

import zingg.common.client.Arguments;
import zingg.common.client.IArguments;
import zingg.common.client.ZinggClientException;
import zingg.common.client.pipe.FilePipe;
import zingg.common.client.pipe.Pipe;
Expand All @@ -31,7 +32,7 @@ public class TestFebrlDataset extends ZinggSparkTester{
public void setUp() throws Exception, ZinggClientException{
String configFilePath = getClass().getResource("../testFebrl/config.json").getFile();
System.out.println("configFilePath "+configFilePath);
args = argsUtil.createArgumentsFromJSON(configFilePath);
args = (IArguments) argsUtil.createArgumentsFromJSON(configFilePath);
String modelPath = getClass().getResource("../testFebrl/models").getPath();
System.out.println("modelPath "+modelPath);
args.setZinggDir(modelPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class TestDataDocumenter extends ZinggSparkTester {
public void setUp(){
try {
String configPath = getClass().getResource("../../../../documenter/config.json").getFile();
docArguments = argsUtil.createArgumentsFromJSON(configPath);
docArguments = (IArguments) argsUtil.createArgumentsFromJSON(configPath);
} catch (Throwable e) {
e.printStackTrace();
LOG.info("Unexpected exception received " + e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void setUp(){

try {
String configPath = getClass().getResource("../../../../documenter/config.json").getFile();
docArguments = argsUtil.createArgumentsFromJSON(configPath);
docArguments = (IArguments) argsUtil.createArgumentsFromJSON(configPath);
String zinggDirPath = getClass().getResource("../../../../"+docArguments.getZinggDir()).getFile();
docArguments.setZinggDir(zinggDirPath);
} catch (Throwable e) {
Expand All @@ -47,21 +47,21 @@ public void setUp(){
public void testIfModelDocumenterGeneratedDocFile() throws Throwable {

try {
Files.deleteIfExists(Paths.get(docArguments.getZinggModelDocFile()));
Files.deleteIfExists(Paths.get(zsCTX.getModelHelper().getZinggModelDocFile(docArguments)));
} catch (IOException e) {
e.printStackTrace();
}
ModelDocumenter modelDoc = new SparkModelDocumenter(zsCTX, docArguments);
modelDoc.createModelDocument();

assertTrue(Files.exists(Paths.get(docArguments.getZinggModelDocFile())), "Model documentation file is not generated");
assertTrue(Files.exists(Paths.get(zsCTX.getModelHelper().getZinggModelDocFile(docArguments))), "Model documentation file is not generated");
}

@Test
public void testPopulateTemplateDataWhenMarkedRecordsAreAvailable() throws Throwable {

ModelDocumenter modelDoc = new SparkModelDocumenter(zsCTX, docArguments);
modelDoc.markedRecords = zsCTX.getPipeUtil().read(false, false, zsCTX.getPipeUtil().getTrainingDataMarkedPipe(docArguments));
modelDoc.markedRecords = zsCTX.getPipeUtil().read(false, false, zsCTX.getModelHelper().getTrainingDataMarkedPipe(docArguments));

Map<String, Object> root = modelDoc.populateTemplateData();
assertTrue(root.containsKey(TemplateFields.MODEL_ID), "The field does not exist - " + TemplateFields.MODEL_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class TestPipeUtil extends ZinggSparkTester{
public void testStopWordsPipe() {
IArguments args = new Arguments();
String fileName = args.getStopWordsDir() + "file";
Pipe p = zsCTX.getPipeUtil().getStopWordsPipe(args, fileName);
Pipe p = zsCTX.getModelHelper().getStopWordsPipe(fileName);

assertEquals(Pipe.FORMAT_CSV, p.getFormat(), "Format is not CSV");
assertEquals("true", p.get(FilePipe.HEADER).toLowerCase(), "Property 'header' is set to 'false'");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.apache.spark.sql.SparkSession;
import org.apache.spark.sql.types.DataType;

import zingg.common.client.IArguments;
import zingg.common.client.IZArgs;
import zingg.common.client.ZFrame;
import zingg.common.client.ZinggClientException;
import zingg.common.client.options.ZinggOptions;
Expand All @@ -30,7 +30,7 @@ public JunitSparkLabeller(ZinggSparkContext sparkContext) {
}

@Override
public void setArgs(IArguments args) {
public void setArgs(IZArgs args) {
super.setArgs(args);
junitLabeller.setArgs(args);
}
Expand Down

0 comments on commit 1a4e971

Please sign in to comment.