counsyl / stor

A cross-compatible CLI and Python API for accessing block and object storage
https://counsyl.github.io/stor/
Other
35 stars 12 forks source link

Guard dxpy imports so dnanexus and swift can actually be optional #143

Open jtratner opened 2 years ago

jtratner commented 2 years ago

dxpy pulls in a wide array of (often legacy) packages, skipping the import means we only need to pull it in as necessary which hopefully makes library more useful to others.

Tests should just continue to pass so shouldn't be a big deal

Showing this works for now:

>>> import stor
>>> stor.Path("/whatever")
PosixPath('/whatever')
>>> stor.Path("dx://whatever")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jtratner/git/stor/stor/base.py", line 47, in __new__
    cls = utils.find_dx_class(path)
  File "/Users/jtratner/git/stor/stor/utils.py", line 272, in find_dx_class
    from stor.dx import DXPath, DXCanonicalPath, DXVirtualPath
  File "/Users/jtratner/git/stor/stor/dx.py", line 9, in <module>
    import dxpy
ModuleNotFoundError: No module named 'dxpy'
>>>