geopython / pygeoapi

pygeoapi is a Python server implementation of the OGC API suite of standards. The project emerged as part of the next generation OGC API efforts in 2018 and provides the capability for organizations to deploy a RESTful OGC API endpoint using OpenAPI, GeoJSON, and HTML. pygeoapi is open source and released under an MIT license.
https://pygeoapi.io
MIT License
499 stars 262 forks source link

Missing SQLite plugin with Docker Image #364

Closed jvanulde closed 4 years ago

jvanulde commented 4 years ago

Trying to launch pygeoapi container using the following:

docker run -p 5000:80 -it geopython/pygeoapi

Get the following error:

START /entrypoint.sh
Trying to generate openapi.yml
Plugin SQLite not found
NoneType: None
Traceback (most recent call last):
  File "/usr/local/bin/pygeoapi", line 11, in <module>
load_entry_point('pygeoapi', 'console_scripts', 'pygeoapi')()
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
  File "/pygeoapi/pygeoapi/openapi.py", line 519, in generate_openapi_document
click.echo(yaml.safe_dump(get_oas(s), default_flow_style=False))
  File "/pygeoapi/pygeoapi/openapi.py", line 504, in get_oas
return get_oas_30(cfg)
  File "/pygeoapi/pygeoapi/openapi.py", line 336, in get_oas_30
p = load_plugin('provider', cfg['datasets'][k]['provider'])
  File "/pygeoapi/pygeoapi/plugin.py", line 82, in load_plugin
raise InvalidPluginError(msg)
pygeoapi.plugin.InvalidPluginError: Plugin SQLite not found
ERROR: openapi.yml could not be generated ERROR

Environment

justb4 commented 4 years ago

The current Docker Image does not work with the SQLIte Provider (Plugin). See also here. Not sure why but could be a lib-dependency problem in the Docker image. @jorgejesus @francbartoli may know.

Quick solution is to use a local pygeoapi config like my.config.yml that does not contain a SQLite dataset and use Docker Volume mapping to override the default within the Docker image e.g.:

docker run -p 5000:80 -v $(pwd)/my.config.yml:/pygeoapi/local.config.yml -it geopython/pygeoapi:latest

You should be able to use the project default config file: pygeoapi-config.yml as my.config.yml.

jvanulde commented 4 years ago

The issue is I need to connect to a GeoPackage. I couldn't get it to work using the base install either so I decided to try the Docker image.

justb4 commented 4 years ago

You could also use the OGRProvider for GeoPackage, see for example this config snippet.

jorgejesus commented 4 years ago

Fast reply to @jvanulde @justb4 The SQLite plugin has been replaced with SQLiteGPKGProvider checking what is the problem

jorgejesus commented 4 years ago

Pushed a fix to my branch: https://github.com/jorgejesus/pygeoapi/tree/issue-364 But there is another problem with openapi generation:

  File "/pygeoapi/pygeoapi/openapi.py", line 351, in get_oas_30
    if v2['type'] == 'date':
TypeError: string indices must be integers

Seems this is related to #367 and there is a PR for this bug

justb4 commented 4 years ago

Ok, I was not aware of the SQLite to SQLiteGPKGProvider name-change. I also see in plugin.py master a 'GeoPackage': 'pygeoapi.provider.geopackage.GeoPackageProvider', but no corresponding module under pygeoapi/provider. Or is this a Provider that returns GPKG formats, like downloads? I missed some of the discussions, sorry.

Apart from the SQLite to SQLiteGPKGProvider name-change (and #367), I think the Docker Image should also contain the proper SQLite/SpatialLite library (mod_spatialite.so) ?

jorgejesus commented 4 years ago

@justb4 Well spotted 'GeoPackage': 'pygeoapi.provider.geopackage.GeoPackageProvider' is surpassed and should be removed

I think that the on the docker image everything is ok with SQLite/SpatialLite (mod_spatialite.so)

justb4 commented 4 years ago

ha yes, I see libsqlite3-mod-spatialite is installed in Docker build.

justb4 commented 4 years ago

so a Provider name change required in at least: https://github.com/geopython/pygeoapi/blob/master/docker/default.config.yml#L193 and in other config yml's under docker/ dir.

jorgejesus commented 4 years ago

Updated my fork and commited, the docker image is running

https://github.com/jorgejesus/pygeoapi/tree/issue-364

Testing on the browser the Sqlite dataprovider from countries is giving an error on json serialization, pytest runs ok the sqlite dataprovider, inside the docker container.

tests/test_sqlite_geopackage_provider.py ..........            [100%]

@justb4 I can submit a PR for what was done already and have a "working" docker image but with problems on the sqlite data, or wait until I see what is going on specifically with the json serialization

jorgejesus commented 4 years ago

Autobuild on docker was triggered and image updated, tested locally pulling new image, everything working