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
Configurable Geocoder (fix #210) #315
Conversation
Add a base class for geocode plugins and an implementation for web-based geocoders (not yet finished).
This is usefull for running GHC in a private environment where geocoding the server does not make any sense.
Need some time to dive in. At least the build failure is not from this PR, but a test that Probes the Resource https://demo.pygeoapi.io/master. That Resource has been failing I now see since jan 28, 2020 10:55 GMT. See https://demo.geohealthcheck.org/resource/165 Dived into this, was quite a route among various products/components. All described here: geopython/pygeoapi#356 ...also to note @tomkralidis |
opengeospatial/ogcapi-processes#63 was cause and fixed so build shoild pass now. |
Great find and I am happy it all works now. All tests pass. |
docs/install.rst
Outdated
@@ -81,6 +81,7 @@ Install | |||
# - GHC_REQUIRE_WEBAPP_AUTH # optional: to require authentication to access webapp | |||
# - GHC_SMTP # if GHC_NOTIFICATIONS is enabled | |||
# - GHC_MAP # or use default settings | |||
# - GEOIP # or use the feault settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: "default"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9699493
docs/config.rst
Outdated
@@ -42,6 +42,7 @@ The configuration options are: | |||
- **centre_long**: Centre longitude for homepage map | |||
- **maxzoom**: maximum zoom level | |||
- **subdomains**: available subdomains to help with parallel requests | |||
- **GEOIP**: configuration for the geolocater service plugin. Default is the ip-api.com api. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
geolocater
should be geolocator
, multiple files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel stupid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed with: e8868a1
docs/plugins.rst
Outdated
@@ -10,7 +10,8 @@ one may want to perform. Hence developers can extend or even replace | |||
the GHC standard Plugins with custom implementations. | |||
|
|||
Two Plugin types exist that can be extended: the `Probe` and `Check` class. | |||
In v0.7.0 also plugins for Resource Authentication, `ResourceAuth`, were added. | |||
In v0.7.0 also plugins for Resource Authentication, `ResourceAuth`, were added | |||
and in v0.8.0 the geocoder plugin was introduced. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will hopefully be 0.8.1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made a reference to 0.9 with commit 4fa7da7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to see the Plugin system used!
Main comment/changes needed: any config change also requires changes to the config for Docker deployment. Not handy but Docker uses env-vars a lot. See the files:
config_site.py and default env vars in Dockerfile. Changes will be bit similar to SMTP config convention.
Thanks for the review work! I'll try to fix things up, but I'm quite busy lately, so it might take some time. |
@borrob no sweat! just keep your PR current with |
Fixed Conflicts: GeoHealthCheck/util.py
I fixed the easy ones. I'll start to check up on the config changes. |
@justb4 Can you be a bit more specific? I changed the |
@borrob the reason for the specific Docker var setup is to enable overruling the default GHC configuration in The convention would be the same as for SMTP. Given the current GEOIP config this would require 3 env vars, e.g. Set defaults in the Dockerfile:
And then in the
Feels like duplicate work, but this has evolved historically and came from Kubernetes deployment. This convention is very common for many tools. Hence also the convention to start env varnames with |
Dockerfile
Outdated
@@ -44,6 +44,9 @@ ENV LC_ALL="en_US.UTF-8" \ | |||
GHC_SMTP_SSL=False \ | |||
GHC_SMTP_USERNAME=None \ | |||
GHC_SMTP_PASSWORD=None \ | |||
GHC_GEOIP_URL='http://ip-api.com/json/{hostname}' \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we align/indent accordingly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aaarrgh. tab vs space discussion.
Fixed with 39183ac.
@@ -0,0 +1,31 @@ | |||
from plugin import Plugin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a license header?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed with 7bdf022.
@@ -0,0 +1,49 @@ | |||
from GeoHealthCheck.geocoder import Geocoder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
License header here as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed with 7bdf022.
@@ -0,0 +1,200 @@ | |||
import requests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
License header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed with 7bdf022.
Thanks for all the review work and the explanation on the docker variables. |
GeoHealthCheck/geocoder.py
Outdated
:param hostname string: the hostname of the server for which we want | ||
the coords. | ||
|
||
TOOD: return result as tuple with locatin in lat-lon like: (52.4, 21.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typos:
TOOD --> TODO
locatin --> location
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should pay more attention to my typing.
Fixed with 0c377b0
Ok, PRs #349 #347 are now in. Maybe you want to merge those in to get the green light on tests first. BTW Whenever we merge in master branch the Docker image Need some time for full review... |
Great! |
Thanks @borrob ! |
An implementation for issue #210: Configurable Geocoder
The plugin system is used to create a configurable geocoder. The geocoder plugin class and specific parameters are specified in the
config_main.py
orconfig_site.py
. The base setup refers to the ip-api.com that is already used at the moment.This PR provides three plugins: using a geocode service on the web via a GET request and via a POST request. The third geocoder returns a (configurable) fixed location which might be useful for intranet/on prem installations of GHC.
I did not check compatibility with the other two open PRs, but conflicts (if any) should be minor.