-
-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] File system/Data storage abstraction #1640
Open
MTachon
wants to merge
15
commits into
geopython:master
Choose a base branch
from
MTachon:fs-abstraction
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…nge backend (netcdf4 -> h5netcdf) to read netcdf 4 files both on local and remote storage
…e format, and change config of s3 test data
… other data than zarr
@MTachon I see this PR is marked as WIP. Is this still the case or is it ready for review? Thanks. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR intends to abstract away the local/remote file system or byte storage where the data used by the providers are stored. The implementation leverages a file-system interface provided through
fsspec
.fsspec
provides already support for various file-systems and cloud storage services through built-in implementations. It also allows for using other known implementations, as well as implementing and registering new backends.The data storage abstraction happens mostly in the implementation of the
BaseProvider
, where a new instance attributefs
is introduced. This attribute, which is afsspec
file-system interface, is inherited by other providers. Other providers can use this file-system interface in their implementation to access the data.The instantiation of
fsspec
file-system objects may use configuration variables set in theproviders
section (some backends used byfsspec
may also use environment variables).This PR introduces a new optional
file_system
section, in theproviders
section of pygeoapi's runtime configuration. If thefile_system
section is omitted, thefs
attribute of theBaseProvider
will be an instance of thefsspec.implementations.local.LocalFileSystem
class. In that case, thefs
attribute can be used by other providers to access and read files on the "local" file system. In the implementations of the providers, calls to the builtinopen
functions can then be replaced by theopen
method of theLocalFileSystem
:The
file_system
section, if given in pygeoapi's configuration, has oneprotocol
mandatory field. The value passed to this field must be one of the protocols supported byfsspec
(seefsspec.available_protocols()
). For faster access, the data can be cached locally (e.g. when the data is on remote storage). This is of course not suitable for very large datasets, as the data needs to be downloaded on the first query, which is in that case both time consuming and takes much space. To cache locally the data, one can configure pygeoapi's runtime as follows:Related Issue / discussion
#824
Additional information
OGRProvider
, as theOpen
method of drivers fromosgeo.gdal
/osgeo.ogr
accepts only a path (str
) to the data to open, and not a file-like handle. However, this provider can already access data on remote storage with GDAL's virtual file systems. The environment variables (if any needed) need then to be set in pygeoapi's parent process to make it work.fsspec
was added torequirements.txt
as it is used inpygeoapi/provider/base.py
.fsspec
has had a OS package for Ubuntu for some time now, and does not seem to have known high or critical vulnerabilities.fsspec
has support for builtin implementations. Packages for external implementations supported byfsspec
can be added to therequirements-provider.txt
file.netCDF4
was replaced byh5py
andh5netcdf
to allow reading from remote storage withxarray
.Dependency policy (RFC2)
Updates to public demo
Contributions and licensing
(as per https://github.com/geopython/pygeoapi/blob/master/CONTRIBUTING.md#contributions-and-licensing)
Updates to public demo
Contributions and licensing
(as per https://github.com/geopython/pygeoapi/blob/master/CONTRIBUTING.md#contributions-and-licensing)