Storage Configuration requires Kernel Restart
Closed
Storage Configuration requires Kernel Restart
In trying to configure a custom storage location using kadlu.storage_cfg(setdir=PATH/HERE)
I encountered some unexpected behaviour.
I added a line to my notebook that set the storage location using kadlu.storage_cfg(setdir=PATH/HERE)
and then tried to run the rest of the notebook using the new specified location. However, for the location change to take effect, I had to restart the notebook kernel. Otherwise, it continued to use the previous (default) storage location despite subsequent calls to kadlu.storage_cfg()
returning the updated storage location.
When I dug into the code, it seems like this behaviour is happening b/c the db
& conn
objects (in era5.py
, etc) are instantiated when kadlu is originally imported and don't have a chance to adjust to the newly configured storage location.
Thanks for reporting this, I think I reproduced the problem with the following test case. As you mention, the geospatial.db file isnt in the expected folder after running kadlu.load(). The db connection should probably instead be instantiated inside the function, or stored and passed as an argument/parameter so that it can be updated when changing the storage config
import os from datetime import datetime import kadlu bounds = {'north': 50, 'south': 48, 'east': -124, 'west': -125, 'start': datetime(2018, 1, 1, 0, 0), 'end': datetime(2018, 1, 3, 0, 0)} testdir1 = os.path.join(os.path.expanduser('~'), 'test1') if not os.path.isdir(testdir1): os.mkdir(testdir1) testdir2 = os.path.join(os.path.expanduser('~'), 'test2') if not os.path.isdir(testdir2): os.mkdir(testdir2) kadlu.storage_cfg(testdir1) kadlu.load(source='era5', var='waveheight', **bounds) kadlu.storage_cfg(testdir2) kadlu.load(source='era5', var='waveheight', **bounds)
mentioned in merge request !56 (merged)
@jilliana I've added a fix for this and pushed the updates to pip, can you confirm that this is working for you? Additionally, kadlu should now work without needing anaconda (only tested on linux so far)
@matt_s This is all working for me now! Thank you
😄 I was also able to install kadlu directly through pip without using Anaconda (on a mac). The only additional step I needed to do was to install GEOS (cartopy dependency) before running
pip install kadlu
.