Cannot use otbtf TFrecords without gdal
When on a system without gdal, the following fails:
from otbtf.tfrecords import TFRecords
# import otbtf.tfrecords.TFRecords # this also fails
Rasing:
raceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/linkhome/rech/gentet01/ube33sw/otbtf/otbtf/__init__.py", line 24, in <module>
from otbtf.dataset import Buffer, PatchesReaderBase, PatchesImagesReader, IteratorBase, RandomIterator, Dataset, \
File "/linkhome/rech/gentet01/ube33sw/otbtf/otbtf/dataset.py", line 30, in <module>
from otbtf.utils import read_as_np_arr, gdal_open
File "/linkhome/rech/gentet01/ube33sw/otbtf/otbtf/utils.py", line 23, in <module>
from osgeo import gdal
ModuleNotFoundError: No module named 'osgeo'
This is because in __init__.py
, there is some pieces of code that rely on gdal:
from utils import read_as_np_arr, gdal_open
from otbtf.dataset import ...
To fix this issue, we would need an empty init.py. However, there is a drawback: all functions/classes would be split depending on their file (dataset
, utils
or tfrecords
). Thus, backward comp would break, because stuff like import otbtf.Dataset
would move to otbtf.dataset.Dataset