WIPACrepo / file_catalog

Store file metadata information in a file catalog
MIT License
1 stars 4 forks source link

Use Relative Imports Internally #130

Closed ric-evans closed 2 years ago

ric-evans commented 2 years ago

Since schema is being exported in the base __init__.py, the sub-package's modules themselves cannot import from file_catalog. To prevent this and from happening elsewhere in other modules, use relative imports everywhere (from . import xyz).

looks like https://github.com/WIPACrepo/file_catalog/pull/129 has a bug in it

Originally posted by @ric-evans in https://github.com/WIPACrepo/file-catalog-indexer/issues/45#issuecomment-1097266810

dsschult commented 2 years ago

What's the actual error? Could this relate to using __all__?

ric-evans commented 2 years ago

What's the actual error? Could this relate to using __all__?

E   ImportError: cannot import name 'schema' from partially initialized module 'file_catalog' (most likely due to a circular import) (/home/circleci/project/.tox/py/lib/python3.8/site-packages/file_catalog/__init__.py)
ric-evans commented 2 years ago

https://github.com/WIPACrepo/file_catalog/pull/131 did not fix this. Unsure if this is still a problem

dsschult commented 2 years ago

131 looks like it fixed it to me? https://app.circleci.com/pipelines/github/WIPACrepo/file-catalog-indexer/478/workflows/357e96d2-1953-4406-9be0-721fb7f8e8f9/jobs/903 is now complaining about the iceprod import, which is being merged now.

ric-evans commented 2 years ago

The Indexer isn't breaking, that's true. There are still non-relative imports here. However, that doesn't seem to be an issue after all.