Skip to content
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

Inconsistent Jython versions #33

Closed
khatchad opened this issue May 3, 2023 · 0 comments · Fixed by #34
Closed

Inconsistent Jython versions #33

khatchad opened this issue May 3, 2023 · 0 comments · Fixed by #34

Comments

@khatchad
Copy link
Collaborator

khatchad commented May 3, 2023

Commit b4b6e8e says to use Python 2 for now, but it references jython3:

<artifactId>jython3</artifactId>

That results in an inconsistency with the follow:

<artifactId>com.ibm.wala.cast.python.jython</artifactId>

If we are using Jython 3, I believe we should be using com.ibm.wala.cast.python.jython3 instead of com.ibm.wala.cast.python.jython.

What happens here as a result is that we load up Jython 3 code that calls methods that don't exist in Jython 2, thus throwing a NoSuchMethod exception. An example is the PythonTree class, which has the method getLineno() in Jython (Python 2) but getLine() in Jython 3 (Python 3).

khatchad added a commit to khatchad/wala-python that referenced this issue May 3, 2023
Make consistent by using Jython 3 as a dependency.
khatchad added a commit to ponder-lab/ML that referenced this issue May 3, 2023
msridhar pushed a commit that referenced this issue May 3, 2023
Make consistent by using Jython 3 as a dependency.
khatchad added a commit to ponder-lab/ML that referenced this issue May 23, 2023
* Address wala#28. (#29)

See https://maven.apache.org/plugins/maven-shade-plugin/examples/attached-artifact.html for reference.

* Remove unused footnote. (#31)

Forgot to remove this one with the last update.

* Lowercase parent pom artifact ID. (#32)

Fixes wala#30.

* Fix wala#33. (#34)

Make consistent by using Jython 3 as a dependency.

* Metadata, build script, and warnings (#35)

* Remove obsolete bundles.

These are being used as JARs now.

* Export missing packages.

Since wala/ML is now using JAR packaging, this probably doesn't matter.
However, it fixes the warnings. And, if it ever gets OSGi component
packaged again, we can use it.

* Fix build.properities file.

Source and data directiories don't exist for these subprojects.

* Fix more warnings.

* Use verify to run the tests.

* Export more packages.

* Fix generics hiding warning.

* Fix Jython and Jython3 test directory metadata.

* Add GH actions file (#40)

* Add GH actions file.

* Remove optional dependency analysis.

Was failing.

* Fix path.

* Switch Jython repos.

* Revert "Switch Jython repos."

This reverts commit 20052de.

* Print out the stack trace.

* Switch to Jython3 for testing ML.

* Revert "Print out the stack trace."

This reverts commit 8fb7951.

* Update run.sh

Fix broken resolution.

* Ignore failing test.

Reinstate once wala#42 is fixed.

* Revert "Work around https://github.com/ponder-lab/ML/issues/4."

This reverts commit 0e5c334.
khatchad pushed a commit that referenced this issue Aug 14, 2023
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 #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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant