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

Naming Conflict: datumaro.py Causes ModuleNotFoundError #8026

Closed
2 tasks done
mondiriariana opened this issue Jun 13, 2024 · 5 comments
Closed
2 tasks done

Naming Conflict: datumaro.py Causes ModuleNotFoundError #8026

mondiriariana opened this issue Jun 13, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@mondiriariana
Copy link

Actions before raising this issue

  • I searched the existing issues and did not find anything similar.
  • I read/searched the docs

Steps to Reproduce

I encountered an issue while working with the CVAT repository. The file named datumaro.py in the directory cvat/cvat/apps/dataset_manager/formats causes a naming conflict with the datumaro package installed in the virtual environment.

This conflict results in a ModuleNotFoundError when attempting to import from the datumaro package, as Python imports the local datumaro.py file instead of the installed package.

Steps to Reproduce:

  1. Clone the CVAT repository.
  2. Set up a virtual environment and install the datumaro package.
  3. Try to import Dataset from datumaro.components.project in a script located in cvat/cvat/apps/dataset_manager/formats.
  4. Run the script

Expected Behavior

Expected Outcome:
The script importTest.py should execute without errors, successfully importing Dataset from datumaro.components.project.

Actual Outcome:
from datumaro.components.dataset import Dataset ModuleNotFoundError: No module named 'datumaro.components'; 'datumaro' is not a package

Possible Solution

Proposed Solution:
Rename the local datumaro.py file to avoid conflicts, e.g., to datumaro_local.py.

However, I'm aware that renaming files might have implications elsewhere in the codebase. Could you please confirm if this change would be acceptable, or suggest an alternative solution?

Context

Additional Information:
I have verified that the issue is not related to a general import problem because the script runs without errors when executed from outside the CVAT repository directory.

Environment

No response

@mondiriariana mondiriariana added the bug Something isn't working label Jun 13, 2024
@zhiltsov-max
Copy link
Contributor

Hi. Thank you for reporting the problem. Could you add more information about the script? Is it a custom script used outside of CVAT or a CVAT component? I can see other formats can import Datumaro package successfully. If it's a side script, maybe it's better to move it into some other location and copy the related dependencies with the names changed.

@mondiriariana
Copy link
Author

@zhiltsov-max

Hello,

The problem persists not only in my custom script importTest.py but also in the existing script yolo.py provided within the CVAT repository. I also encounter the same issue with other classes in the formats folder.

Further Details:

I have confirmed that the datumaro package datumaro 1.7.0 is correctly installed in my virtual environment. The issue seems to arise due to Python prioritizing the local datumaro.py file over the installed package, leading to import errors.

Suggested Approach:
I have temporarily renamed the local datumaro.py file to datumaro_local.py as a workaround, which has resolved the import issues in my local environment. However, this solution may not be optimal for the entire CVAT repository. However, I tried several time copying the repository over again and went over all similar issues I found online.

Request for Guidance:
Given that other formats within the CVAT repository can import datumaro successfully, could you please advise on the best approach to resolve this conflict comprehensively?

Your guidance on resolving this matter would be greatly appreciated.

Thank you again for your assistance.

Operating System: macOS
Python Version: Python 3.11.5
Name: datumaro Version: 1.7.0 Summary: Dataset Management Framework (Datumaro) Home-page: https://github.com/openvinotoolkit/datumaro Author: Intel Author-email: emily.chun@intel.com License: Location: /Users/arianamondiri/Desktop/cvat_yolo_ULTRA/cvat/.cvat/lib/python3.11/site-packages Requires: attrs, cryptography, defusedxml, h5py, imagesize, json-stream, lxml, matplotlib, networkx, nibabel, numpy, opencv-python, openvino, orjson, ovmsclient, pandas, Pillow, protobuf, pyarrow, pycocotools, pyemd, PyYAML, requests, ruamel.yaml, scikit-learn, scipy, shapely, tabulate, tensorboardX, tokenizers, tqdm, tritonclient, typing-extensions

Best regards

@zhiltsov-max
Copy link
Contributor

If the script you're working on is not a part of CVAT, then you should keep in mind how module resolution works in Python. To resolve the problem, just move the script to some other place and copy the required dependencies with renaming, if necessary.

https://docs.python.org/3/reference/import.html#namespace-packages

@mondiriariana
Copy link
Author

@zhiltsov-max

The ModuleNotFoundError persists across various scripts in the CVAT repository, including original scripts like yolo.py.

Given that this naming conflict impacts essential scripts, I am currently unable to proceed with adding support for a new annotation format. Your guidance on addressing this issue comprehensively would be invaluable in ensuring the stability and performance of the CVAT framework.

Thank you for your prompt attention to this matter.

@zhiltsov-max
Copy link
Contributor

Could you clarify the problem with YOLO?

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