forked from wala/ML
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Fix pytest entrypoints #86
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Looks a lot cleaner.
…b/ML into fix_pytest_entrypoints
khatchad
pushed a commit
that referenced
this pull request
Feb 23, 2024
Currently, we are using jython2 in `com.ibm.wala.cast.python.ml.test`, where we don't encounter decorator problems when running the tests. But when we use jython3, we do encounter problems with decorator `tf.function`. Therefore we are adding initial support for the decorator `tf.function` in `tensorflow.xml`. Initial support for `tf.function` because after this change, in jython3, can now process the decorator that has parenthesis e.g. `tf.function()` or `tf.function(...)`. Refer to wala#33 for the issue with inconsistent jython versions. After this change we see: Test code with parenthesis: ```python import tensorflow as tf @tf.function() def returned(a): return a a = tf.range(5) b = returned(a) ``` The analysis of the test with parenthesis: ``` answer: [Node: <Code body of function Lscript tf2_testing_decorator.py> Context: CallStringContext: [ com.ibm.wala.FakeRootClass.fakeRootMethod()V@2 ], v251][{[D:Symbolic,n, D:Compound,[D:Constant,28, D:Constant,28]] of pixel}] [Ret-V:Node: synthetic < PythonLoader, Ltensorflow/functions/range, do()LRoot; > Context: CallStringContext: [ script tf2_testing_decorator.py.do()LRoot;@96 ]][{[D:Symbolic,n, D:Compound,[D:Constant,28, D:Constant,28]] of pixel}] [Node: synthetic < PythonLoader, Ltensorflow/functions/range, do()LRoot; > Context: CallStringContext: [ script tf2_testing_decorator.py.do()LRoot;@96 ], v6][{[D:Symbolic,n, D:Compound,[D:Constant,28, D:Constant,28]] of pixel}] [Node: <Code body of function Lscript tf2_testing_decorator.py/returned> Context: CallStringContext: [ script tf2_testing_decorator.py.do()LRoot;@98 ], v2][{[D:Symbolic,n, D:Compound,[D:Constant,28, D:Constant,28]] of pixel}] [Node: <Code body of function Lscript tf2_testing_decorator.py> Context: CallStringContext: [ com.ibm.wala.FakeRootClass.fakeRootMethod()V@2 ], v257][{[D:Symbolic,n, D:Compound,[D:Constant,28, D:Constant,28]] of pixel}] [Ret-V:Node: <Code body of function Lscript tf2_testing_decorator.py/returned> Context: CallStringContext: [ script tf2_testing_decorator.py.do()LRoot;@98 ]][{[D:Symbolic,n, D:Compound,[D:Constant,28, D:Constant,28]] of pixel}] ``` Test code with parenthesis: ```python import tensorflow as tf @tf.function def returned(a): return a a = tf.range(5) b = returned(a) ``` The analysis of the test without parenthesis: ``` answer: [Node: <Code body of function Lscript tf2_testing_decorator.py> Context: CallStringContext: [ com.ibm.wala.FakeRootClass.fakeRootMethod()V@2 ], v249][{[D:Symbolic,n, D:Compound,[D:Constant,28, D:Constant,28]] of pixel}] [Ret-V:Node: synthetic < PythonLoader, Ltensorflow/functions/range, do()LRoot; > Context: CallStringContext: [ script tf2_testing_decorator.py.do()LRoot;@95 ]][{[D:Symbolic,n, D:Compound,[D:Constant,28, D:Constant,28]] of pixel}] [Node: synthetic < PythonLoader, Ltensorflow/functions/range, do()LRoot; > Context: CallStringContext: [ script tf2_testing_decorator.py.do()LRoot;@95 ], v6][{[D:Symbolic,n, D:Compound,[D:Constant,28, D:Constant,28]] of pixel}] [Node: synthetic < PythonLoader, Ltensorflow/class/Function, do()LRoot; > Context: CallStringContext: [ script tf2_testing_decorator.py.do()LRoot;@97 ], v2][{[D:Symbolic,n, D:Compound,[D:Constant,28, D:Constant,28]] of pixel}] [Node: <Code body of function Lscript tf2_testing_decorator.py> Context: CallStringContext: [ com.ibm.wala.FakeRootClass.fakeRootMethod()V@2 ], v255][{[D:Symbolic,n, D:Compound,[D:Constant,28, D:Constant,28]] of pixel}] [Ret-V:Node: synthetic < PythonLoader, Ltensorflow/class/Function, do()LRoot; > Context: CallStringContext: [ script tf2_testing_decorator.py.do()LRoot;@97 ]][{[D:Symbolic,n, D:Compound,[D:Constant,28, D:Constant,28]] of pixel}] ``` We see that with the decorator, `expr` is classified as a `CALL`, and without it is classified as an `Attribute`.
khatchad
added a commit
that referenced
this pull request
Feb 23, 2024
* Initial fix. * Use Guava to merge the iterables. Looks a lot cleaner. * Cleaning. * Log entrypoints. * Enhance. * Add pytest calls to methods test. * Update .gitignore. * Move to new class. * Add pytest test class with an explicit ctor. * Simply assertions.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Not previously working.
Need to the following: