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

rename logging module #278

Closed
0x-stan opened this issue Oct 30, 2023 · 3 comments
Closed

rename logging module #278

0x-stan opened this issue Oct 30, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@0x-stan
Copy link

0x-stan commented Oct 30, 2023

Simple Summary

Because the curvesim.logging module has the same name as the python logging module, an error is reported when importing curvesim. I recommend renaming it.

Motivation / Use-case

When developing based on curvesim, I found that import curvesim will report an error and cannot be run. The reason is that curvesim.logging has the same name as the python logging module. After experiments, it was found that modifying the logging module name can solve this problem.

Python 3.10.10 (main, Jun  8 2023, 14:33:30) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import curvesim
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/stan/Library/Caches/pypoetry/virtualenvs/crvusdsim-pUi1XxWR-py3.10/lib/python3.10/site-packages/curvesim/__init__.py", line 4, in <module>
    from ._order_book import order_book
  File "/Users/stan/Library/Caches/pypoetry/virtualenvs/crvusdsim-pUi1XxWR-py3.10/lib/python3.10/site-packages/curvesim/_order_book/__init__.py", line 6, in <module>
    import matplotlib.pyplot as plt
  File "/Users/stan/Library/Caches/pypoetry/virtualenvs/crvusdsim-pUi1XxWR-py3.10/lib/python3.10/site-packages/matplotlib/__init__.py", line 145, in <module>
    import logging
  File "/Users/stan/workcode/curve/curvesim/curvesim/logging.py", line 7, in <module>
    import logging.config
ModuleNotFoundError: No module named 'logging.config'; 'logging' is not a package

Detailed Summary

Rename curvesim.logging module.

@chanhosuh
Copy link
Member

@0x-stan we can't replicate this error. Can you create a minimal working example? e.g. include what's in your venv and what commands you ran first

@chanhosuh chanhosuh added the bug Something isn't working label Oct 30, 2023
@chanhosuh
Copy link
Member

btw, the way python namespacing works, having a module named logging in a package should not create an issue with import logging in any other module or dependent package. The name would only create a conflict if you already did something previously in your interpreter instance to import curvesim.logging as logging (setting sys.modules['logging']) or your sys.path starts looking from inside the package.

@0x-stan
Copy link
Author

0x-stan commented Oct 31, 2023

Thanks Reply! I can not reproduce this error today. I think you are right. Maybe it was caused by an internal conflict in my sys.path. Will close this issue.

@0x-stan 0x-stan closed this as completed Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants