bopen / elevation

Python script to download global terrain digital elevation models, SRTM 30m DEM and SRTM 90m DEM.

Home Page:http://elevation.bopen.eu

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RuntimeError: Unable to acquire lock on `filepath`

tommylees112 opened this issue · comments

We are using your package to download SRTM data for kenya

Hopefully I can spare some of the details (the functions shown but not explained hopefully have somewhat intuitive sounding names) but this is where / how we are using your package:

    def export(self, region_name: str = 'kenya',
               product: str = 'SRTM3',
               max_download_tiles: int = 15) -> None:
        """
        Export SRTm topography data

        Arguments
        ----------
        region_name: str = 'kenya'
            The region to download. Must be one of the regions in the
            region_lookup dictionary
        product: {'SRTM1', 'SRTM3'} = 'SRTM3'
            The product to download the data from
        max_download_tiles: int = 15
            By default, the elevation package doesn't allow more than 9
            tiles to be downloaded. Kenya is 12 tiles - this increases the
            limit to allow Kenya to be downloaded
        """

        region = region_lookup[region_name]

        output_tif = self.output_folder / f'{region_name}.tif'

        if not output_tif.exists():
            print(f'Downloading tiles. Saving as tif to {output_tif}')
            try:
                elevation.clip(bounds=self._region_to_tuple(region),  # type: ignore
                               output=output_tif.resolve().as_posix(),
                               product=product,
                               max_download_tiles=max_download_tiles)
            except Exception as e:
                print(e)

            elevation.clean()  # type: ignore

        output_nc = self.output_folder / f'{region_name}.nc'

        if not output_nc.exists():
            print(f'Converting {output_tif} to NetCDF format ({output_nc})')
            self._tif_to_nc(output_tif, output_nc)

We get the following error message on a remote cluster. Is this something you have seen before?

(crp) chri4118@linux8:/soge-home/projects/crop_yield/ml_drought/scripts$ python export.py
The SRTM exporter requires GDAL and the elevation python package. The mac conda environment contains them.In addition, a (finnicky) ubuntu environment contains them in environment.ubuntu.cpu.gdal.yml
Downloading tiles. Saving as tif to ../data/raw/srtm/kenya.tif
Unable to acquire lock on `b'/soge-home/users/chri4118/.cache/elevation/SRTM3/.folder_lock'` due to [Errno 38] Function not implemented
Traceback (most recent call last):
  File "/soge-home/users/chri4118/.conda/envs/crp/lib/python3.7/site-packages/fasteners/process_lock.py", line 99, in _try_acquire
    self.trylock()
  File "/soge-home/users/chri4118/.conda/envs/crp/lib/python3.7/site-packages/fasteners/process_lock.py", line 217, in trylock
    self._trylock(self.lockfile)
  File "/soge-home/users/chri4118/.conda/envs/crp/lib/python3.7/site-packages/fasteners/process_lock.py", line 250, in _trylock
    fcntl.lockf(lockfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
OSError: [Errno 38] Function not implemented

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "export.py", line 83, in <module>
    export_srtm()
  File "export.py", line 74, in export_srtm
    exporter.export()
  File "../src/exporters/srtm.py", line 77, in export
    elevation.clean()  # type: ignore
  File "/soge-home/users/chri4118/.conda/envs/crp/lib/python3.7/site-packages/elevation/datasource.py", line 201, in clean
    datasource_root, _ = ensure_setup(cache_dir, product)
  File "/soge-home/users/chri4118/.conda/envs/crp/lib/python3.7/site-packages/elevation/datasource.py", line 122, in ensure_setup
    util.ensure_setup(datasource_root, product=product, force=force, **spec)
  File "/soge-home/users/chri4118/.conda/envs/crp/lib/python3.7/site-packages/elevation/util.py", line 69, in ensure_setup
    with fasteners.InterProcessLock(os.path.join(root, FOLDER_LOCKFILE_NAME)):
  File "/soge-home/users/chri4118/.conda/envs/crp/lib/python3.7/site-packages/fasteners/process_lock.py", line 179, in __enter__
    gotten = self.acquire()
  File "/soge-home/users/chri4118/.conda/envs/crp/lib/python3.7/site-packages/fasteners/process_lock.py", line 161, in acquire
    gotten = r(self._try_acquire, blocking, watch)
  File "/soge-home/users/chri4118/.conda/envs/crp/lib/python3.7/site-packages/fasteners/_utils.py", line 121, in __call__
    return fn(*args, **kwargs)
  File "/soge-home/users/chri4118/.conda/envs/crp/lib/python3.7/site-packages/fasteners/process_lock.py", line 112, in _try_acquire
    'exception': e,
RuntimeError: Unable to acquire lock on `b'/soge-home/users/chri4118/.cache/elevation/SRTM1/.folder_lock'` due to [Errno 38] Function not implemented