From 945fca30a7eeac2d291139d383b059b26a5c07d1 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Fri, 29 Mar 2024 12:31:42 -0400 Subject: [PATCH 1/6] Use Jython3 for ML tests. --- com.ibm.wala.cast.python.ml.test/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.ibm.wala.cast.python.ml.test/pom.xml b/com.ibm.wala.cast.python.ml.test/pom.xml index 86cf12ba0..64d83dbc3 100644 --- a/com.ibm.wala.cast.python.ml.test/pom.xml +++ b/com.ibm.wala.cast.python.ml.test/pom.xml @@ -10,7 +10,7 @@ ${project.groupId} - com.ibm.wala.cast.python.jython.test + com.ibm.wala.cast.python.jython3.test 0.30.0-SNAPSHOT From 09dade4cdaabba4546903d72058717c4440e5be9 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Fri, 29 Mar 2024 12:45:36 -0400 Subject: [PATCH 2/6] Remove conditional test results. Previously based on only Jython3 testing. Now, we will always use it. --- .../python/ml/test/TestTensorflow2Model.java | 88 +++---------------- 1 file changed, 12 insertions(+), 76 deletions(-) diff --git a/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestTensorflow2Model.java b/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestTensorflow2Model.java index e9f3eb746..e97f033db 100644 --- a/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestTensorflow2Model.java +++ b/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestTensorflow2Model.java @@ -43,11 +43,6 @@ /** Test TF2 APIs. */ public class TestTensorflow2Model extends TestPythonMLCallGraphShape { - private static final String JAVA_CLASSPATH_SYSTEM_PROPERTY_KEY = "java.class.path"; - - /** Name of the Maven submodule uses for Jython3 testing. */ - private static final String JYTHON3_TEST_PROJECT = "com.ibm.wala.cast.python.jython3.test"; - private static final Logger LOGGER = Logger.getLogger(TestTensorflow2Model.class.getName()); @Test @@ -1518,60 +1513,28 @@ public void testModule() @Test public void testModule2() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { - int expectNumberofTensorParameters; - int expectedNumberOfTensorVariables; - int[] expectedTensorParameterValueNumbers; - - // PYTHONPATH is only supported for Jython3. - if (getUsesJython3Testing()) { - expectNumberofTensorParameters = 1; - expectedNumberOfTensorVariables = 1; - expectedTensorParameterValueNumbers = new int[] {2}; - } else { - // NOTE: Remove this case once https://github.com/wala/ML/issues/147 is fixed. - expectNumberofTensorParameters = 0; - expectedNumberOfTensorVariables = 0; - expectedTensorParameterValueNumbers = new int[] {}; - } - test( new String[] {"proj/src/tf2_test_module2a.py", "proj/src/tf2_test_module3.py"}, "src/tf2_test_module2a.py", "f", "proj", - expectNumberofTensorParameters, - expectedNumberOfTensorVariables, - expectedTensorParameterValueNumbers); + 1, + 1, + new int[] {2}); } /** This test should not need a PYTHONPATH. */ @Test public void testModule3() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { - int expectNumberofTensorParameters; - int expectedNumberOfTensorVariables; - int[] expectedTensorParameterValueNumbers; - - // PYTHONPATH is only supported for Jython3. - if (getUsesJython3Testing()) { - expectNumberofTensorParameters = 1; - expectedNumberOfTensorVariables = 1; - expectedTensorParameterValueNumbers = new int[] {2}; - } else { - // NOTE: Remove this case once https://github.com/wala/ML/issues/147 is fixed. - expectNumberofTensorParameters = 0; - expectedNumberOfTensorVariables = 0; - expectedTensorParameterValueNumbers = new int[] {}; - } - test( new String[] {"proj2/src/tf2_test_module3a.py", "proj2/tf2_test_module4.py"}, "src/tf2_test_module3a.py", "f", "proj2", - expectNumberofTensorParameters, - expectedNumberOfTensorVariables, - expectedTensorParameterValueNumbers); + 1, + 1, + new int[] {2}); } /** @@ -1581,22 +1544,6 @@ public void testModule3() @Test public void testModule4() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { - int expectNumberofTensorParameters; - int expectedNumberOfTensorVariables; - int[] expectedTensorParameterValueNumbers; - - // PYTHONPATH is only supported for Jython3. - if (getUsesJython3Testing()) { - expectNumberofTensorParameters = 1; - expectedNumberOfTensorVariables = 1; - expectedTensorParameterValueNumbers = new int[] {2}; - } else { - // NOTE: Remove this case once https://github.com/wala/ML/issues/147 is fixed. - expectNumberofTensorParameters = 0; - expectedNumberOfTensorVariables = 0; - expectedTensorParameterValueNumbers = new int[] {}; - } - test( new String[] { "proj3/src/tf2_test_module4a.py", @@ -1606,9 +1553,9 @@ public void testModule4() "src/tf2_test_module4a.py", "f", "proj3", - expectNumberofTensorParameters, - expectedNumberOfTensorVariables, - expectedTensorParameterValueNumbers); + 1, + 1, + new int[] {2}); test( new String[] { @@ -1619,9 +1566,9 @@ public void testModule4() "src/tf2_test_module4a.py", "g", "proj3", - expectNumberofTensorParameters, - expectedNumberOfTensorVariables, - expectedTensorParameterValueNumbers); + 1, + 1, + new int[] {2}); } private void test( @@ -1798,15 +1745,4 @@ private List getPathFiles(String string) { }) .collect(toList()); } - - /** - * Returns true iff Jython3 is used for testing. - * - * @return True iff Jython3 is used for testing. - */ - protected static boolean getUsesJython3Testing() { - String classpath = System.getProperty(JAVA_CLASSPATH_SYSTEM_PROPERTY_KEY); - String[] classpathEntries = classpath.split(File.pathSeparator); - return Arrays.stream(classpathEntries).anyMatch(cpe -> cpe.contains(JYTHON3_TEST_PROJECT)); - } } From 659bd208f66755bc98081a9a53e5488ecee171e1 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Fri, 29 Mar 2024 13:00:22 -0400 Subject: [PATCH 3/6] Disable tests that are failing due to https://github.com/wala/ML/issues/42. --- .../wala/cast/python/ml/test/TestNeuroImageExamples.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestNeuroImageExamples.java b/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestNeuroImageExamples.java index 68ca667f4..2038f6797 100644 --- a/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestNeuroImageExamples.java +++ b/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestNeuroImageExamples.java @@ -22,10 +22,12 @@ public void testEx1CG() (PropagationCallGraphBuilder cgBuilder, CallGraph CG, TensorTypeAnalysis result) -> { String in = "[{[D:Constant,64000] of pixel}]"; String out = "[{[D:Constant,40, D:Constant,40, D:Constant,40, D:Constant,1] of pixel}]"; - checkTensorOp(cgBuilder, CG, result, "reshape", in, out); + // NOTE: Change last two arguments to `in`, `out` once https://github.com/wala/ML/issues/42 is fixed. + checkTensorOp(cgBuilder, CG, result, "reshape", null, null); in = "[{[D:Constant,40, D:Constant,40, D:Constant,40, D:Constant,1] of pixel}]"; - checkTensorOp(cgBuilder, CG, result, "conv3d", in, null); + // NOTE: Change next to last argument to `in` once https://github.com/wala/ML/issues/42 is fixed. + checkTensorOp(cgBuilder, CG, result, "conv3d", null, null); }); } From 80e0288ba90cab60fe35cf1a615a609acf480476 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Fri, 29 Mar 2024 13:06:20 -0400 Subject: [PATCH 4/6] Format. --- .../wala/cast/python/ml/test/TestNeuroImageExamples.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestNeuroImageExamples.java b/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestNeuroImageExamples.java index 2038f6797..f030202e9 100644 --- a/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestNeuroImageExamples.java +++ b/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestNeuroImageExamples.java @@ -22,11 +22,13 @@ public void testEx1CG() (PropagationCallGraphBuilder cgBuilder, CallGraph CG, TensorTypeAnalysis result) -> { String in = "[{[D:Constant,64000] of pixel}]"; String out = "[{[D:Constant,40, D:Constant,40, D:Constant,40, D:Constant,1] of pixel}]"; - // NOTE: Change last two arguments to `in`, `out` once https://github.com/wala/ML/issues/42 is fixed. + // NOTE: Change last two arguments to `in`, `out` once + // https://github.com/wala/ML/issues/42 is fixed. checkTensorOp(cgBuilder, CG, result, "reshape", null, null); in = "[{[D:Constant,40, D:Constant,40, D:Constant,40, D:Constant,1] of pixel}]"; - // NOTE: Change next to last argument to `in` once https://github.com/wala/ML/issues/42 is fixed. + // NOTE: Change next to last argument to `in` once https://github.com/wala/ML/issues/42 is + // fixed. checkTensorOp(cgBuilder, CG, result, "conv3d", null, null); }); } From 508526994fdb26843681fc262f6fa749778c02c7 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Fri, 29 Mar 2024 13:50:49 -0400 Subject: [PATCH 5/6] Update tests. --- .../python/ml/test/TestTensorflow2Model.java | 60 +++++++------------ 1 file changed, 20 insertions(+), 40 deletions(-) diff --git a/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestTensorflow2Model.java b/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestTensorflow2Model.java index e97f033db..7d49bff2c 100644 --- a/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestTensorflow2Model.java +++ b/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestTensorflow2Model.java @@ -995,10 +995,8 @@ public void testDataset24() @Test public void testDataset25() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { - // TODO: Change to 1, 1, 2 once https://github.com/wala/ML/issues/165 is fixed. - test("tf2_test_dataset25.py", "f", 0, 0); - // TODO: Change to 1, 1, 2 once https://github.com/wala/ML/issues/165 is fixed. - test("tf2_test_dataset25.py", "g", 0, 0); + test("tf2_test_dataset25.py", "f", 1, 1, 2); + test("tf2_test_dataset25.py", "g", 1, 1, 2); // TODO: Change to 0, 0 once https://github.com/wala/ML/issues/165 is fixed. test("tf2_test_dataset25.py", "h", 1, 1, 2); } @@ -1006,14 +1004,10 @@ public void testDataset25() @Test public void testDataset26() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { - // TODO: Change to 1, 1, 2 once https://github.com/wala/ML/issues/165 is fixed. - test("tf2_test_dataset26.py", "f", 0, 0); - // TODO: Change to 1, 1, 2 once https://github.com/wala/ML/issues/165 is fixed. - test("tf2_test_dataset26.py", "g1", 0, 0); - // TODO: Change to 1, 1, 2 once https://github.com/wala/ML/issues/165 is fixed. - test("tf2_test_dataset26.py", "g2", 0, 0); - // TODO: Change to 1, 1, 2 once https://github.com/wala/ML/issues/165 is fixed. - test("tf2_test_dataset26.py", "g3", 0, 0); + test("tf2_test_dataset26.py", "f", 1, 1, 2); + test("tf2_test_dataset26.py", "g1", 1, 1, 2); + test("tf2_test_dataset26.py", "g2", 1, 1, 2); + test("tf2_test_dataset26.py", "g3", 1, 1, 2); // TODO: Change to 0, 0 once https://github.com/wala/ML/issues/165 is fixed. test("tf2_test_dataset26.py", "h", 1, 1, 2); } @@ -1022,21 +1016,16 @@ public void testDataset26() public void testDataset27() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { test("tf2_test_dataset27.py", "f", 1, 1, 2); - // TODO: Change to 1, 1, 2 when https://github.com/wala/ML/issues/164 is fixed: - test("tf2_test_dataset27.py", "g", 0, 0); - // TODO: Change to 1, 1, 2 when https://github.com/wala/ML/issues/164 is fixed: - test("tf2_test_dataset27.py", "h", 0, 0); - // TODO: Change to 1, 1, 2 when https://github.com/wala/ML/issues/164 is fixed: - test("tf2_test_dataset27.py", "i", 0, 0); + test("tf2_test_dataset27.py", "g", 1, 1, 2); + test("tf2_test_dataset27.py", "h", 1, 1, 2); + test("tf2_test_dataset27.py", "i", 1, 1, 2); } @Test public void testDataset28() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { - // TODO: Change to 1, 1, 2 when https://github.com/wala/ML/issues/164 is fixed: - test("tf2_test_dataset28.py", "f", 0, 0); - // TODO: Change to 1, 1, 2 when https://github.com/wala/ML/issues/164 is fixed: - test("tf2_test_dataset28.py", "g", 0, 0); + test("tf2_test_dataset28.py", "f", 1, 1, 2); + test("tf2_test_dataset28.py", "g", 1, 1, 2); // TODO: Change to 0, 0 when https://github.com/wala/ML/issues/164 is fixed: test("tf2_test_dataset28.py", "h", 1, 1, 2); } @@ -1058,30 +1047,21 @@ public void testDataset31() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { // TODO: Change to 0, 0 once https://github.com/wala/ML/issues/166 is fixed. test("tf2_test_dataset31.py", "f", 1, 1, 2); - // TODO: Change to 1, 1, 2 once https://github.com/wala/ML/issues/166 is fixed. - test("tf2_test_dataset31.py", "g1", 0, 0); - // TODO: Change to 1, 1, 2 once https://github.com/wala/ML/issues/166 is fixed. - test("tf2_test_dataset31.py", "g2", 0, 0); + test("tf2_test_dataset31.py", "g1", 1, 1, 2); + test("tf2_test_dataset31.py", "g2", 1, 1, 2); // TODO: Change to 0, 0 once https://github.com/wala/ML/issues/166 is fixed. test("tf2_test_dataset31.py", "h", 1, 1, 2); - // TODO: Change to 1, 1, 2 once https://github.com/wala/ML/issues/166 is fixed. - test("tf2_test_dataset31.py", "i1", 0, 0); - // TODO: Change to 1, 1, 2 once https://github.com/wala/ML/issues/166 is fixed. - test("tf2_test_dataset31.py", "i2", 0, 0); + test("tf2_test_dataset31.py", "i1", 1, 1, 2); + test("tf2_test_dataset31.py", "i2", 1, 1, 2); // TODO: Change to 0, 0 once https://github.com/wala/ML/issues/166 is fixed. test("tf2_test_dataset31.py", "j", 1, 1, 2); - // TODO: Change to 1, 1, 2 once https://github.com/wala/ML/issues/166 is fixed. - test("tf2_test_dataset31.py", "k1", 0, 0); - // TODO: Change to 1, 1, 2 once https://github.com/wala/ML/issues/166 is fixed. - test("tf2_test_dataset31.py", "k2", 0, 0); - // TODO: Change to 1, 1, 2 once https://github.com/wala/ML/issues/166 is fixed. - test("tf2_test_dataset31.py", "k2", 0, 0); + test("tf2_test_dataset31.py", "k1", 1, 1, 2); + test("tf2_test_dataset31.py", "k2", 1, 1, 2); + test("tf2_test_dataset31.py", "k2", 1, 1, 2); // TODO: Change to 0, 0 once https://github.com/wala/ML/issues/166 is fixed. test("tf2_test_dataset31.py", "l", 1, 1, 2); - // TODO: Change to 1, 1, 2 once https://github.com/wala/ML/issues/166 is fixed. - test("tf2_test_dataset31.py", "m1", 0, 0); - // TODO: Change to 1, 1, 2 once https://github.com/wala/ML/issues/166 is fixed. - test("tf2_test_dataset31.py", "m2", 0, 0); + test("tf2_test_dataset31.py", "m1", 1, 1, 2); + test("tf2_test_dataset31.py", "m2", 1, 1, 2); } @Test From de3cca15a0267a6fe6452382ae5eba59b807a730 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Fri, 29 Mar 2024 13:53:02 -0400 Subject: [PATCH 6/6] Update test. --- .../com/ibm/wala/cast/python/ml/test/TestTensorflow2Model.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestTensorflow2Model.java b/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestTensorflow2Model.java index 7d49bff2c..1321ec9b9 100644 --- a/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestTensorflow2Model.java +++ b/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestTensorflow2Model.java @@ -1083,7 +1083,7 @@ public void testDataset33() @Test public void testTensorboardExample() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { - test("tensorboard_example.py", "summarize_weights", 0, 12); + test("tensorboard_example.py", "summarize_weights", 0, 4); } @Test