Skip to content

Commit

Permalink
Merge pull request #217 from bird-house/fix-216
Browse files Browse the repository at this point in the history
fix breakage with owslib 0.29 removal of verbose argument
  • Loading branch information
huard authored Apr 28, 2023
2 parents 7398c8a + 00e703e commit 4cbd217
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 34 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Install packages
run: |
sudo apt-get -y install pandoc
if: matrix.python-version == 3.8
if: matrix.python-version == 3.9
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
Expand All @@ -28,10 +28,10 @@ jobs:
run: make test
- name: Lint with flake8 ⚙️
run: make lint
if: matrix.python-version == 3.8
if: matrix.python-version == 3.9
- name: Check formatting with black ⚙️
run: black --check --target-version py36 birdy tests
if: matrix.python-version == 3.8
run: black --check --target-version py39 birdy tests
if: matrix.python-version == 3.9
- name: Build docs 🏗️
run: make docs
if: matrix.python-version == 3.8
if: matrix.python-version == 3.9
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
22 changes: 17 additions & 5 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 @@ -77,8 +79,8 @@ def __init__(
passed to :class:`owslib.wps.WebProcessingService`
cert: str
passed to :class:`owslib.wps.WebProcessingService`
verbose: str
passed to :class:`owslib.wps.WebProcessingService`
verbose: bool
Deprecated. passed to :class:`owslib.wps.WebProcessingService` for owslib < 0.29
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
)

0 comments on commit 4cbd217

Please sign in to comment.