nansat icon indicating copy to clipboard operation
nansat copied to clipboard

Using multiple custom nansat_mappers from different projects does not work

Open korvinos opened this issue 4 years ago • 2 comments

@akorosov I have an issue regarding using custom nansat_mappers created outside the Nansat. I have several project repositories. Each project is mounted to the /path/to/python3.7/site-packages/ so I can access it in python. Within each mounted repository in turn I have a nansat_mappers directory. The __init__.py file for all available nansat_mappers was modified according to the nansat documentation. However, the Nasnat still does not see these custom mappers. I checked the source code for the nansat and found that import of the custom mappers is implemented as follows: https://github.com/nansencenter/nansat/blob/74ecaf59e7568a14db9d5f3f738204b2f897b7a9/nansat/nansat.py#L1595

As far as I understand it requires that nansat_mappers directory is mounted directly to the /path/to/python3.7/site-packages/ instead of /path/to/python3.7/site-packages/package/.

However the documentation says (https://nansat.readthedocs.io/en/latest/source/about_mappers.html):

Create a directory called nansat_mappers within a directory on your $PYTHONPATH

If I mount on of the nansat_mappers directly to the site-packages it works just fine. However, it creates an issue with mounting multiple different nansat_mappers from different packages in the same environment.

korvinos avatar Jul 02 '20 12:07 korvinos

Maybe to extend Nansat.init with use_mapper parameter and call like that:

from some_package.some_mappers import SomeMapper

n = Nansat(filename, use_mapper=SomeMapper)

akorosov avatar Jul 07 '20 11:07 akorosov

Maybe to extend Nansat.init with add_mappers:

from some_package1 import some_mappers1
from some_package2 import some_mappers2

n = Nansat(filename, add_mappers=[some_mappers1, some_mappers2])

akorosov avatar Jul 07 '20 11:07 akorosov