Skip to content
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

fix breakage with owslib 0.29 removal of verbose argument #217

Merged
merged 9 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Changes:
* Relax dependency check on GeoTiff rioxarray and rasterio converters due to some mysterious gdal error.
* Remove tests with live 52North WPS server since it seems offline.
* Remove Python 3.6 from test matrix and add 3.10.
* Handle the removal of the `verbose` argument in `OWSLib.WebProcessingService` 0.29.0.

0.8.1 (2021-12-01)
==================
Expand Down
20 changes: 16 additions & 4 deletions birdy/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
ComplexData,
WebProcessingService,
)
from warnings import warn
import packaging.version

from birdy.client import notebook, utils
from birdy.client.outputs import WPSResult
Expand Down Expand Up @@ -46,13 +48,13 @@ def __init__(
auth=None,
verify=True,
cert=None,
verbose=False,
progress=False,
version=WPS_DEFAULT_VERSION,
caps_xml=None,
desc_xml=None,
language=None,
lineage=False,
**kwds,
):
"""Initialize WPSClient.

Expand All @@ -78,7 +80,7 @@ def __init__(
cert: str
passed to :class:`owslib.wps.WebProcessingService`
verbose: str
passed to :class:`owslib.wps.WebProcessingService`
Deprecated. passed to :class:`owslib.wps.WebProcessingService` for owslib < 0.29
huard marked this conversation as resolved.
Show resolved Hide resolved
progress: bool
If True, enable interactive user mode.
version: str
Expand Down Expand Up @@ -117,17 +119,28 @@ def __init__(
auth_headers = ["Authorization", "Proxy-Authorization", "Cookie"]
headers.update({h: r.headers[h] for h in auth_headers if h in r.headers})

if "verbose" in kwds:
if packaging.version.parse(owslib.__version__) >= packaging.version.parse(
"0.29.0"
):
kwds.pop("verbose")
warn(
"The 'verbose' keyword is deprecated and will be removed in a future version. Starting with owslib "
"0.29.0, debugging information is logged instead of printed.",
DeprecationWarning,
)

self._wps = WebProcessingService(
url,
version=version,
username=username,
password=password,
verbose=verbose,
headers=headers,
verify=verify,
cert=cert,
skip_caps=True,
language=language,
**kwds,
)

try:
Expand Down Expand Up @@ -309,7 +322,6 @@ def _build_inputs(self, pid, **kwargs):
for value in values:
# if input_param.dataType == "ComplexData": seems simpler
if isinstance(input_param.defaultValue, ComplexData):

# Guess the mimetype of the input value
mimetype, encoding = guess_type(value, supported_mimetypes)

Expand Down
2 changes: 1 addition & 1 deletion birdy/client/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def output_formats_widgets(self, outputs):
for (key, o) in outputs
]
):
for (key, output) in outputs:
for key, output in outputs:
if hasattr(output, "supportedValues"):
of[key] = widgets.RadioButtons(
options=[o.mimeType for o in output.supportedValues],
Expand Down
23 changes: 13 additions & 10 deletions birdy/ipyleafletwfs/examples/ipyleafletwfs_guide.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"from birdy import IpyleafletWFS\n",
"from ipyleaflet import Map\n",
"\n",
"url = 'http://boreas.ouranos.ca/geoserver/wfs'\n",
"version = '2.0.0'\n",
"url = \"http://boreas.ouranos.ca/geoserver/wfs\"\n",
"version = \"2.0.0\"\n",
"\n",
"wfs_connection = IpyleafletWFS(url, version)\n",
"\n",
Expand Down Expand Up @@ -57,7 +57,7 @@
"metadata": {},
"outputs": [],
"source": [
"wfs_connection.build_layer(layer_typename='public:HydroLAKES_poly', source_map=demo_map)"
"wfs_connection.build_layer(layer_typename=\"public:HydroLAKES_poly\", source_map=demo_map)"
]
},
{
Expand Down Expand Up @@ -95,8 +95,10 @@
"metadata": {},
"outputs": [],
"source": [
"wfs_connection.create_feature_property_widget(widget_name='Wshd_area', feature_property='Wshd_area', widget_position='bottomleft')\n",
"demo_map\n"
"wfs_connection.create_feature_property_widget(\n",
" widget_name=\"Wshd_area\", feature_property=\"Wshd_area\", widget_position=\"bottomleft\"\n",
")\n",
"demo_map"
]
},
{
Expand All @@ -114,7 +116,9 @@
"metadata": {},
"outputs": [],
"source": [
"wfs_connection.create_feature_property_widget(widget_name='main_widget', feature_property='Lake_area')"
"wfs_connection.create_feature_property_widget(\n",
" widget_name=\"main_widget\", feature_property=\"Lake_area\"\n",
")"
]
},
{
Expand All @@ -131,7 +135,7 @@
"outputs": [],
"source": [
"gjson = wfs_connection.geojson\n",
"gjson['features'][0].keys()"
"gjson[\"features\"][0].keys()"
]
},
{
Expand All @@ -140,8 +144,7 @@
"metadata": {},
"outputs": [],
"source": [
"\n",
"gjson['totalFeatures']\n"
"gjson[\"totalFeatures\"]"
]
},
{
Expand All @@ -157,7 +160,7 @@
"metadata": {},
"outputs": [],
"source": [
"wfs_connection.create_feature_property_widget(widget_name='main_widget')\n",
"wfs_connection.create_feature_property_widget(widget_name=\"main_widget\")\n",
"demo_map"
]
},
Expand Down
9 changes: 4 additions & 5 deletions birdy/ipyleafletwfs/examples/quickstart-template.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
"outputs": [],
"source": [
"from birdy import IpyleafletWFS\n",
"from ipyleaflet import Map\n",
"from ipyleaflet import Map\n",
"\n",
"# Initialize the connection\n",
"url ='http://boreas.ouranos.ca/geoserver/wfs'\n",
"version ='2.0.0'\n",
"url = \"http://boreas.ouranos.ca/geoserver/wfs\"\n",
"version = \"2.0.0\"\n",
"\n",
"boreas_wfs = IpyleafletWFS(url, version)\n",
"\n",
Expand All @@ -48,8 +48,7 @@
"outputs": [],
"source": [
"# Build the WFS layer\n",
"boreas_wfs.build_layer(layer_typename='public:HydroLAKES_poly', source_map=m)\n",
"\n"
"boreas_wfs.build_layer(layer_typename=\"public:HydroLAKES_poly\", source_map=m)"
]
},
{
Expand Down
24 changes: 16 additions & 8 deletions birdy/ipyleafletwfs/examples/wfs_constructor.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"from ipyleaflet import Map\n",
"\n",
"# Create connection\n",
"url = 'http://boreas.ouranos.ca/geoserver/wfs'\n",
"version = '2.0.0'\n",
"url = \"http://boreas.ouranos.ca/geoserver/wfs\"\n",
"version = \"2.0.0\"\n",
"\n",
"wfs = IpyleafletWFS(url, version)\n"
"wfs = IpyleafletWFS(url, version)"
]
},
{
Expand All @@ -33,7 +33,7 @@
"source": [
"# Create the map instance\n",
"m = Map(center=(47.90, -69.90), zoom=11)\n",
"m\n"
"m"
]
},
{
Expand All @@ -55,11 +55,19 @@
"# Create wfs layer\n",
"# Move and zoom to the desired extent before running this cell\n",
"# Do NOT zoom too far out, as large GeoJSON layers can be long to load and even cause crashed\n",
"basin_style = { 'color': '#d000ff', 'opacity': 1, 'dashArray': '10', 'fillOpacity': 0.0, 'weight': 3 }\n",
"lake_style = { 'color': '#00aeff', 'dashArray': '0', 'fillOpacity': 0.5, 'weight': 0.5 }\n",
"basin_style = {\n",
" \"color\": \"#d000ff\",\n",
" \"opacity\": 1,\n",
" \"dashArray\": \"10\",\n",
" \"fillOpacity\": 0.0,\n",
" \"weight\": 3,\n",
"}\n",
"lake_style = {\"color\": \"#00aeff\", \"dashArray\": \"0\", \"fillOpacity\": 0.5, \"weight\": 0.5}\n",
"\n",
"lakes = wfs.create_wfsgeojson_layer('public:HydroLAKES_poly', m, layer_style=lake_style)\n",
"basins = wfs.create_wfsgeojson_layer('public:wshed_bound_n2', m, layer_style=basin_style)"
"lakes = wfs.create_wfsgeojson_layer(\"public:HydroLAKES_poly\", m, layer_style=lake_style)\n",
"basins = wfs.create_wfsgeojson_layer(\n",
" \"public:wshed_bound_n2\", m, layer_style=basin_style\n",
")"
]
},
{
Expand Down
7 changes: 7 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,3 +409,10 @@ def test_local_uri(self): # noqa: D102
def test_url(self): # noqa: D102
assert not is_embedded_in_request(self.remote, self.url)
assert not is_embedded_in_request(self.local, self.url)


def test_verbose_deprecation(): # noqa: D103
with pytest.warns(DeprecationWarning):
WPSClient(
url=URL_EMU, caps_xml=EMU_CAPS_XML, desc_xml=EMU_DESC_XML, verbose=True
)