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

Cannot run analysis (import statements seems to be at the wrong position when there are strings) #11

Closed
HALOCORE opened this issue Nov 5, 2022 · 1 comment

Comments

@HALOCORE
Copy link

HALOCORE commented Nov 5, 2022

I am trying to run OperationAnalysis on a simple test file, using the following 2 commands:

python3 -m dynapyt.instrument.instrument --files ./test1.py --analysis OperationAnalysis
python3 -m dynapyt.run_analysis --entry ./test1.py --analysis OperationAnalysis

Test file content:

"""print 3"""

print(1 + 2)

"""print 7"""

print(3 + 4)

Instrumentation (by first command):

# DYNAPYT: DO NOT INSTRUMENT

"""print 3"""

print(_binary_op_(_dynapyt_ast_, 0, lambda: 1, 0, lambda: 2))

"""print 7"""

from dynapyt.runtime import _catch_
from dynapyt.runtime import _binary_op_

_dynapyt_ast_ = __file__ + ".orig"
try:
    
    print(_binary_op_(_dynapyt_ast_, 1, lambda: 3, 0, lambda: 4))
except Exception as _dynapyt_exception_:
    _catch_(_dynapyt_exception_)

Run (second command):

$ python3 -m dynapyt.run_analysis --entry ./test1.py --analysis OperationAnalysis
Traceback (most recent call last):
  File "/home/bo/anaconda3/envs/py310/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/bo/anaconda3/envs/py310/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/bo/anaconda3/envs/py310/lib/python3.10/site-packages/dynapyt/run_analysis.py", line 30, in <module>
    exec(open(abspath(args.entry)).read())
  File "<string>", line 5, in <module>
NameError: name '_binary_op_' is not defined

Without strings """print 3""" and """print 7""" it will work.

Python ver: 3.10
pip list (result of pip install dynapyt libcst aiopg):

Package           Version
----------------- -------
aiopg             1.4.0
async-timeout     4.0.2
dynapyt           0.1.0
libcst            0.4.7
mypy-extensions   0.4.3
pip               22.3
psycopg2-binary   2.9.5
PyYAML            6.0
setuptools        65.5.1
typing_extensions 4.4.0
typing-inspect    0.8.0
wheel             0.38.1
AryazE added a commit that referenced this issue Nov 22, 2022
@AryazE
Copy link
Collaborator

AryazE commented Nov 22, 2022

The new version has already fixed this problem. It has been updated on PyPi now and you can get the latest version from PyPi (pip install -U dynapyt) or GitHub.

@AryazE AryazE closed this as completed Nov 22, 2022
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

No branches or pull requests

2 participants