moiexpositoalonsolab / deepbiosphere

MIT License
8 stars 0 forks source link

PosixPath Atrribute Error in Utils.py #1

Open totti0223 opened 1 week ago

totti0223 commented 1 week ago

encountered in google colab. i havent checked whether the error reproduces in other environment, so just will keep it just a notice in issue.

code

!cd drive/MyDrive/deepbiosphere/ && python src/deepbiosphere/Download_GBIF_Data.py \
--gbif_user XXXXX --gbif_email XXXXXXXX --organism plant --start_date 2015 --end_date 2022

error message

Traceback (most recent call last):
  File "/usr/lib/python3.10/pkgutil.py", line 417, in get_importer
    importer = sys.path_importer_cache[path_item]
KeyError: PosixPath('/content/drive/MyDrive/deepbiosphere/src/deepbiosphere')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/content/drive/MyDrive/deepbiosphere/src/deepbiosphere/Download_GBIF_Data.py", line 2, in <module>
    from deepbiosphere.Utils import paths
  File "/content/drive/MyDrive/deepbiosphere/src/deepbiosphere/__init__.py", line 9, in <module>
    for (_, module_name, _) in iter_modules([package_dir]):
  File "/usr/lib/python3.10/pkgutil.py", line 129, in iter_modules
    for i in importers:
  File "/usr/lib/python3.10/pkgutil.py", line 421, in get_importer
    importer = path_hook(path_item)
  File "<frozen importlib._bootstrap_external>", line 1632, in path_hook_for_FileFinder
  File "<frozen importlib._bootstrap_external>", line 1504, in __init__
  File "<frozen importlib._bootstrap_external>", line 182, in _path_isabs
AttributeError: 'PosixPath' object has no attribute 'startswith'

workaround

in src/deepbiosphere/init.py

for (_, module_name, _) in iter_modules([str(package_dir)]):
#for (_, module_name, _) in iter_modules([package_dir]):

in setup.cfg, prior to pip install

pacakge_dir= =src

to

package_dir = =src

leg2015 commented 2 days ago

Good catch! Unfortunately default module importation in python was a bit ugly in older versions of Python and I never got around to cleaning up the package importation to the newer pyproject.toml package setup. I'll leave this issue open for now as a reminder to fixing it at some point!