Comments (7)
Fixed in c7c669b
Ok thanks @tomkralidis ! Ready for review.
from geopython-workshop.
Strange: all the cells in the Notebook work. Only OAFeat via OWSLib to the local Docker pygeoapi
instance gives a 'connection refusederror when fetching the OpenAPI document via
api()method. Other calls to the local
pygeoapiinstance work ok, like fetching features. Also the
api()call works ok for the
pygeoapi` demo server. Any idea @tomkralidis ?
Error output:
---------------------------------------------------------------------------
ConnectionRefusedError Traceback (most recent call last)
/usr/local/lib/python3.8/dist-packages/urllib3/connection.py in _new_conn(self)
168 try:
--> 169 conn = connection.create_connection(
170 (self._dns_host, self.port), self.timeout, **extra_kw
/usr/local/lib/python3.8/dist-packages/urllib3/util/connection.py in create_connection(address, timeout, source_address, socket_options)
95 if err is not None:
---> 96 raise err
97
/usr/local/lib/python3.8/dist-packages/urllib3/util/connection.py in create_connection(address, timeout, source_address, socket_options)
85 sock.bind(source_address)
---> 86 sock.connect(sa)
87 return sock
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
NewConnectionError Traceback (most recent call last)
/usr/local/lib/python3.8/dist-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
698 # Make the request on the httplib connection object.
--> 699 httplib_response = self._make_request(
700 conn,
/usr/local/lib/python3.8/dist-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
393 else:
--> 394 conn.request(method, url, **httplib_request_kw)
395
/usr/local/lib/python3.8/dist-packages/urllib3/connection.py in request(self, method, url, body, headers)
233 headers["User-Agent"] = _get_default_user_agent()
--> 234 super(HTTPConnection, self).request(method, url, body=body, headers=headers)
235
/usr/lib/python3.8/http/client.py in request(self, method, url, body, headers, encode_chunked)
1251 """Send a complete request to the server."""
-> 1252 self._send_request(method, url, body, headers, encode_chunked)
1253
/usr/lib/python3.8/http/client.py in _send_request(self, method, url, body, headers, encode_chunked)
1297 body = _encode(body, 'body')
-> 1298 self.endheaders(body, encode_chunked=encode_chunked)
1299
/usr/lib/python3.8/http/client.py in endheaders(self, message_body, encode_chunked)
1246 raise CannotSendHeader()
-> 1247 self._send_output(message_body, encode_chunked=encode_chunked)
1248
/usr/lib/python3.8/http/client.py in _send_output(self, message_body, encode_chunked)
1006 del self._buffer[:]
-> 1007 self.send(msg)
1008
/usr/lib/python3.8/http/client.py in send(self, data)
946 if self.auto_open:
--> 947 self.connect()
948 else:
/usr/local/lib/python3.8/dist-packages/urllib3/connection.py in connect(self)
199 def connect(self):
--> 200 conn = self._new_conn()
201 self._prepare_conn(conn)
/usr/local/lib/python3.8/dist-packages/urllib3/connection.py in _new_conn(self)
180 except SocketError as e:
--> 181 raise NewConnectionError(
182 self, "Failed to establish a new connection: %s" % e
NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f58dc975430>: Failed to establish a new connection: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
MaxRetryError Traceback (most recent call last)
/usr/local/lib/python3.8/dist-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
438 if not chunked:
--> 439 resp = conn.urlopen(
440 method=request.method,
/usr/local/lib/python3.8/dist-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
754
--> 755 retries = retries.increment(
756 method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
/usr/local/lib/python3.8/dist-packages/urllib3/util/retry.py in increment(self, method, url, response, error, _pool, _stacktrace)
573 if new_retry.is_exhausted():
--> 574 raise MaxRetryError(_pool, url, error or ResponseError(cause))
575
MaxRetryError: HTTPConnectionPool(host='localhost', port=5000): Max retries exceeded with url: /openapi (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f58dc975430>: Failed to establish a new connection: [Errno 111] Connection refused'))
During handling of the above exception, another exception occurred:
ConnectionError Traceback (most recent call last)
/tmp/ipykernel_56/4142736323.py in <module>
1 # Open API Specification v3 - API document
----> 2 api = oa_feat.api() # OpenAPI definition
/usr/local/lib/python3.8/dist-packages/owslib/ogcapi/__init__.py in api(self)
95 if url is not None:
96 LOGGER.debug('Request: {}'.format(url))
---> 97 response = http_get(url, headers=REQUEST_HEADERS, auth=self.auth)
98 if openapi_format == openapi_json_mimetype:
99 content = response.json()
/usr/local/lib/python3.8/dist-packages/owslib/util.py in http_get(*args, **kwargs)
465 rkwargs.setdefault('cert', rkwargs.get('cert'))
466 rkwargs.setdefault('verify', rkwargs.get('verify', True))
--> 467 return requests.get(*args, **rkwargs)
468
469
/usr/local/lib/python3.8/dist-packages/requests/api.py in get(url, params, **kwargs)
73 """
74
---> 75 return request('get', url, params=params, **kwargs)
76
77
/usr/local/lib/python3.8/dist-packages/requests/api.py in request(method, url, **kwargs)
59 # cases, and look like a memory leak in others.
60 with sessions.Session() as session:
---> 61 return session.request(method=method, url=url, **kwargs)
62
63
/usr/local/lib/python3.8/dist-packages/requests/sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
540 }
541 send_kwargs.update(settings)
--> 542 resp = self.send(prep, **send_kwargs)
543
544 return resp
/usr/local/lib/python3.8/dist-packages/requests/sessions.py in send(self, request, **kwargs)
653
654 # Send the request
--> 655 r = adapter.send(request, **kwargs)
656
657 # Total elapsed time of the request (approximately)
/usr/local/lib/python3.8/dist-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
514 raise SSLError(e, request=request)
515
--> 516 raise ConnectionError(e, request=request)
517
518 except ClosedPoolError as e:
ConnectionError: HTTPConnectionPool(host='localhost', port=5000): Max retries exceeded with url: /openapi (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f58dc975430>: Failed to establish a new connection: [Errno 111] Connection refused'))
from geopython-workshop.
Forget the above, I noticed a startup error:
Trying to generate openapi.yml
list indices must be integers or slices, not str
openapi.yml generated continue to pygeoapi
make SCRIPT_NAME empty from /
So the OAS doc is not generated.
Thought it was related to geopython/pygeoapi#775, updated to latest
but still the error. Maybe something in the config.
from geopython-workshop.
But even leaving out all collections except obs
, no error on startup, but still same error on api()
call.
Stranger http://localhost:5000/openapi?f=json renders OAS doc ok...
from geopython-workshop.
I think this issue is rooted in the OWSLib .api()
workflow. For OWSLib OGC API support, the .api
function determines the URL to invoke from the link relations in the response, as opposed to constructing the URL as passed in the constructor in the other methods.
For example, running the workshop pygeoapi instance landing page, we can see the OpenAPI link relation below:
{
"rel": "service-desc",
"type": "application/vnd.oai.openapi+json;version=3.0",
"title": "The OpenAPI definition as JSON",
"href": "http://localhost:5000/openapi"
}
So http://localhost:5000/openapi works fine in a browser, but in the Jupyter environment does not resolve. When applying the following:
diff --git a/workshop/services/pygeoapi-config.yml b/workshop/services/pygeoapi-config.yml
index ae82455..01acd2d 100644
--- a/workshop/services/pygeoapi-config.yml
+++ b/workshop/services/pygeoapi-config.yml
@@ -34,7 +34,7 @@ server:
bind:
host: 0.0.0.0
port: 80
- url: http://localhost:5000
+ url: http://geopython-workshop-pygeoapi
mimetype: application/json; charset=UTF-8
encoding: utf-8
language: en-US
... and restarting with docker restart geopython-workshop-pygeoapi
, the notebook works as expected, but the API has broken links when accessing through a web browser.
My recommendation here is to remove any OWSLib examples that call the api()
function for now.
from geopython-workshop.
I see, a Catch 22 situation ;-). Left out the api()
call for the local service. All examples now work for the local service.
Still I see this error at startup, but not clear what caused it:
START /entrypoint.sh
Trying to generate openapi.yml
list indices must be integers or slices, not str
openapi.yml generated continue to pygeoapi
make SCRIPT_NAME empty from /
from geopython-workshop.
Fixed in c7c669b
from geopython-workshop.
Related Issues (20)
- value is trying to be set on a copy of a slice from a DataFrame HOT 2
- Geometry is in a geographic CRS. Results from 'centroid' are likely incorrect. HOT 1
- Remove pygeoapi and pycsw from docker-compose HOT 5
- send reminder of workshop requirements HOT 2
- Upgrade packages and Docker Image for 2023 FOSS4G HOT 1
- Ch. 6 Analysis - Error in Pandas Bokeh plot HOT 3
- Ch. 7 - Visualization - Error in Jupyter Notebook when executing Cells HOT 2
- The Binder version of the workshop not available
- `rasterio` dependency is missing in requirements.txt file HOT 3
- add workshop link from OSGeoLive desktop HOT 1
- add reference to PROJ CRS Explorer
- add FAIR data principles to Section 8
- Add metadata import to metadata section
- Curl -O http… seems not working on windows HOT 1
- Emerging trends needs attention
- Add a section for big geospatial data and distributed computation
- Add a native conda execution HOT 1
- Extend Docker install docs for Linux non-root users
- Should the SRS section include the grids method?
- should we add web publish section
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from geopython-workshop.