wala / ML

Eclipse Public License 2.0
24 stars 17 forks source link

Fix extra function caused by additional summary entries for tensor generators #80

Closed tatianacv closed 1 year ago

tatianacv commented 1 year ago

This PR fixes the XML summaries so that the FQN imports (ex. from tensorflow.python.ops.variables import Variable) and traditional imports (ex. import tensorflow as tf, import tensorflow) when using the same API count as the same class. Therefore, there was a change in the expectedNumberOfTensorVariables because in https://github.com/wala/ML/blob/8f0fba7c2ced99c85292e5b72d16c93e968627e6/com.ibm.wala.cast.python.test/data/tf2e2.py#L1-L8 we don't count the two APIs as different, but one which is why in this PR we see a change from 4 to 3 in test such as the one above.

I also added a test that only included the FQN import to ensure we were processing that API. I added one test for the only level 2 API and one test for one of the level 1 APIs.

For example, tf2b.cpy and tf2c.py are essentially the same except having different ways of importing the same thing:

https://github.com/wala/ML/blob/8f0fba7c2ced99c85292e5b72d16c93e968627e6/com.ibm.wala.cast.python.test/data/tf2c.py#L1-L8

https://github.com/wala/ML/blob/8f0fba7c2ced99c85292e5b72d16c93e968627e6/com.ibm.wala.cast.python.test/data/tf2b.py#L1-L7

Yet, there are differences in the number of tensor variables identified (3 and 4, respectively).:

https://github.com/wala/ML/blob/8f0fba7c2ced99c85292e5b72d16c93e968627e6/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestTensorflowModel.java#L67-L68

Now, we have (in this PR) 3 and 3 tensor variables, respectively (they are now the same despite the different ways of importing the same thing): https://github.com/wala/ML/pull/80/files#diff-5b16d15bb6e50c03555d3801c21e05c34697088581cfc1c721a3b999355b5ffdL67-R68

Now, the XML summaries are structured more hierarchically.