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

Circular Inport on Oracle Import #22

Closed
icezyclon opened this issue Jan 24, 2022 · 2 comments
Closed

Circular Inport on Oracle Import #22

icezyclon opened this issue Jan 24, 2022 · 2 comments

Comments

@icezyclon
Copy link
Contributor

icezyclon commented Jan 24, 2022

Problem:
Importing any oracle from aalpy.oracles will result in a circular import on version 1.1.7 which is the newest version from pypi. This issue also exists on the most current commit: a59df07
Minimum working example:

from aalpy.oracles import WMethodEqOracle

Resulting in:

Traceback (most recent call last):
  File "test.py", line 1, in <module>
    from aalpy.oracles import UserInputEqOracle
  File "USER/.virtualenvs/avlstar4/lib/python3.8/site-packages/aalpy/oracles/__init__.py", line 9, in <module>
    from .UserInputEqOracle import UserInputEqOracle
  File "USER/.virtualenvs/avlstar4/lib/python3.8/site-packages/aalpy/oracles/UserInputEqOracle.py", line 2, in <module>
    from aalpy.utils import visualize_automaton
  File "USER/.virtualenvs/avlstar4/lib/python3.8/site-packages/aalpy/utils/__init__.py", line 4, in <module>
    from .ModelChecking import model_check_experiment, mdp_2_prism_format, model_check_properties, get_properties_file, get_correct_prop_values, compare_automata
  File "USER/.virtualenvs/avlstar4/lib/python3.8/site-packages/aalpy/utils/ModelChecking.py", line 9, in <module>
    from aalpy.oracles import RandomWMethodEqOracle
ImportError: cannot import name 'RandomWMethodEqOracle' from partially initialized module 'aalpy.oracles' (most likely due to a circular import) (USER/.virtualenvs/avlstar4/lib/python3.8/site-packages/aalpy/oracles/__init__.py)

Explanation:
Basically, the init.py of oracles loads the UserInputEqOracle, which in turn requires visualize_automata, in the process initializing init.py of utils which loads ModelChecking which requires the RandomWMethodEqOracle from the partially initialized init.py of oracles.

Notes:

  1. Running tests automatically would probably prevent such easy errors from getting pushed to pypi. I would recommend a tool like pre-commit, if you would like, I could set up a basic configuration for AALpy.
  2. Please tag the versions which are pushed to pypi also here. This would have allowed me to easily find the commit that resulted in this issue.
  3. I switched to version *1.1 for now which does not have this problem.
@icezyclon
Copy link
Contributor Author

Note: After a bisection search I found the first broken commit:

commit 49aa8c0
Date: Tue Dec 14 19:52:16 2021 +0100
Message: fix bug in WMethod char. set computation, add comparison of det. automata

Hopefully, that helps

@emuskardin
Copy link
Member

Thanks once again.
I will reach out to you about pre-commit in the near feature :)

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