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

Finch notebooks failure after Geoserver upgrade #206

Closed
tlvu opened this issue Oct 21, 2021 · 4 comments · Fixed by Ouranosinc/pavics-sdi#233 or #207
Closed

Finch notebooks failure after Geoserver upgrade #206

tlvu opened this issue Oct 21, 2021 · 4 comments · Fixed by Ouranosinc/pavics-sdi#233 or #207
Assignees

Comments

@tlvu
Copy link
Collaborator

tlvu commented Oct 21, 2021

Description

Since our notebooks are unable to test Geoserver from a dev machine (issue Ouranosinc/pavics-sdi#183), this error is caught only after a go-live on prod of PR bird-house/birdhouse-deploy#136.

Steps to Reproduce

Jenkins build error: http://jenkins.ouranos.ca/job/PAVICS-e2e-workflow-tests/job/master/1276/console

KeyError: "['bbox'] not found in axis"

regridding.ipynb:

12:15:43  ______ pavics-sdi-master/docs/source/notebooks/regridding.ipynb::Cell 22 _______
12:15:43  Notebook cell execution failed
12:15:43  Cell 22: Cell execution caused an exception
12:15:43  
12:15:43  Input:
12:15:43  # NBVAL_IGNORE_OUTPUT
12:15:43  
12:15:43  wfs_url = 'http://boreas.ouranos.ca/geoserver/wfs'
12:15:43  # Connect to GeoServer WFS service.
12:15:43  wfs = WebFeatureService(wfs_url, version='2.0.0')
12:15:43  
12:15:43  # Get the json as a binary stream
12:15:43  # Here we select Quebec's MRCs polygons
12:15:43  # We select only a few properties
12:15:43  data = wfs.getfeature(
12:15:43      typename='public:quebec_mrc_boundaries',
12:15:43      #bbox=(-93.1, 41.1, -75.0, 49.6),
12:15:43      outputFormat='json',
12:15:43      propertyname=['the_geom', 'MRS_NM_MRC']
12:15:43  )
12:15:43  # Load into a GeoDataFrame by reading the json on-the-fly
12:15:43  shapes_all = gpd.GeoDataFrame.from_features(json.load(data))
12:15:43  # Just for simplicity, let's take 10 large MRCs
12:15:43  shapes_all['AREA'] = shapes_all.area
12:15:43  shapes = shapes_all.sort_values('AREA').iloc[-20:-10].drop(columns=['bbox']).set_index('MRS_NM_MRC')
12:15:43  shapes
12:15:43  
12:15:43  Traceback:
12:15:43  
12:15:43  ---------------------------------------------------------------------------
12:15:43  KeyError                                  Traceback (most recent call last)
12:15:43  /tmp/ipykernel_438/1389203164.py in <module>
12:15:43       18 # Just for simplicity, let's take 10 large MRCs
12:15:43       19 shapes_all['AREA'] = shapes_all.area
12:15:43  ---> 20 shapes = shapes_all.sort_values('AREA').iloc[-20:-10].drop(columns=['bbox']).set_index('MRS_NM_MRC')
12:15:43       21 shapes
12:15:43  
12:15:43  /opt/conda/envs/birdy/lib/python3.7/site-packages/pandas/core/frame.py in drop(self, labels, axis, index, columns, level, inplace, errors)
12:15:43     4313             level=level,
12:15:43     4314             inplace=inplace,
12:15:43  -> 4315             errors=errors,
12:15:43     4316         )
12:15:43     4317 
12:15:43  
12:15:43  /opt/conda/envs/birdy/lib/python3.7/site-packages/pandas/core/generic.py in drop(self, labels, axis, index, columns, level, inplace, errors)
12:15:43     4151         for axis, labels in axes.items():
12:15:43     4152             if labels is not None:
12:15:43  -> 4153                 obj = obj._drop_axis(labels, axis, level=level, errors=errors)
12:15:43     4154 
12:15:43     4155         if inplace:
12:15:43  
12:15:43  /opt/conda/envs/birdy/lib/python3.7/site-packages/pandas/core/generic.py in _drop_axis(self, labels, axis, level, errors)
12:15:43     4186                 new_axis = axis.drop(labels, level=level, errors=errors)
12:15:43     4187             else:
12:15:43  -> 4188                 new_axis = axis.drop(labels, errors=errors)
12:15:43     4189             result = self.reindex(**{axis_name: new_axis})
12:15:43     4190 
12:15:43  
12:15:43  /opt/conda/envs/birdy/lib/python3.7/site-packages/pandas/core/indexes/base.py in drop(self, labels, errors)
12:15:43     5590         if mask.any():
12:15:43     5591             if errors != "ignore":
12:15:43  -> 5592                 raise KeyError(f"{labels[mask]} not found in axis")
12:15:43     5593             indexer = indexer[~mask]
12:15:43     5594         return self.delete(indexer)
12:15:43  
12:15:43  KeyError: "['bbox'] not found in axis"

subset.ipynb:

12:15:43  Notebook cell execution failed
12:15:43  Cell 7: Cell execution caused an exception
12:15:43  
12:15:43  Input:
12:15:43  # NBVAL_IGNORE_OUTPUT
12:15:43  # Select 3 regions around the city of Montr��al (drop unused "bbox" dimension)
12:15:43  poly_mtl = all_shapes[all_shapes.RES_NM_REG.isin(['Mont��r��gie', 'Montr��al', 'Laval'])].drop(columns=['bbox'])
12:15:43  poly_mtl
12:15:43  
12:15:43  Traceback:
12:15:43  
12:15:43  ---------------------------------------------------------------------------
12:15:43  KeyError                                  Traceback (most recent call last)
12:15:43  /tmp/ipykernel_719/432195274.py in <module>
12:15:43        1 # NBVAL_IGNORE_OUTPUT
12:15:43        2 # Select 3 regions around the city of Montr��al (drop unused "bbox" dimension)
12:15:43  ----> 3 poly_mtl = all_shapes[all_shapes.RES_NM_REG.isin(['Mont��r��gie', 'Montr��al', 'Laval'])].drop(columns=['bbox'])
12:15:43        4 poly_mtl
12:15:43  
12:15:43  /opt/conda/envs/birdy/lib/python3.7/site-packages/pandas/core/frame.py in drop(self, labels, axis, index, columns, level, inplace, errors)
12:15:43     4313             level=level,
12:15:43     4314             inplace=inplace,
12:15:43  -> 4315             errors=errors,
12:15:43     4316         )
12:15:43     4317 
12:15:43  
12:15:43  /opt/conda/envs/birdy/lib/python3.7/site-packages/pandas/core/generic.py in drop(self, labels, axis, index, columns, level, inplace, errors)
12:15:43     4151         for axis, labels in axes.items():
12:15:43     4152             if labels is not None:
12:15:43  -> 4153                 obj = obj._drop_axis(labels, axis, level=level, errors=errors)
12:15:43     4154 
12:15:43     4155         if inplace:
12:15:43  
12:15:43  /opt/conda/envs/birdy/lib/python3.7/site-packages/pandas/core/generic.py in _drop_axis(self, labels, axis, level, errors)
12:15:43     4186                 new_axis = axis.drop(labels, level=level, errors=errors)
12:15:43     4187             else:
12:15:43  -> 4188                 new_axis = axis.drop(labels, errors=errors)
12:15:43     4189             result = self.reindex(**{axis_name: new_axis})
12:15:43     4190 
12:15:43  
12:15:43  /opt/conda/envs/birdy/lib/python3.7/site-packages/pandas/core/indexes/base.py in drop(self, labels, errors)
12:15:43     5590         if mask.any():
12:15:43     5591             if errors != "ignore":
12:15:43  -> 5592                 raise KeyError(f"{labels[mask]} not found in axis")
12:15:43     5593             indexer = indexer[~mask]
12:15:43     5594         return self.delete(indexer)
12:15:43  
12:15:43  KeyError: "['bbox'] not found in axis"

Additional Information

Similar Raven issue Ouranosinc/raven#410

@aulemahal
Copy link
Collaborator

At a quick glance, I find it weird that the returned polygon collection has different attributes with only a server upgrade, this seems quite an easy fix anyway.

@Zeitsperre
Copy link
Collaborator

This is exactly the type of error I was expecting post-upgrade. It appears that one version of the quebec_mrc_boundaries had a BBOX field, and we dropped that particular version in the upgrade. By chance, If anything, this might result in cleaner code. I wonder if this field was automatically generated by the previous GeoServer, given that the files are the same...

@aulemahal
Copy link
Collaborator

I am guessing the field was automatically generated! In the WFS calls, we have propertyname=['the_geom', 'MRS_NM_MRC'] , so it was kinda strange that an additional "bbox" field was also provided.

@tlvu tlvu changed the title Notebooks failure after Geoserver upgrade Finch notebooks failure after Geoserver upgrade Oct 21, 2021
@tlvu
Copy link
Collaborator Author

tlvu commented Oct 26, 2021

@aulemahal I'll test both PR on Jenkins once power is back tomorrow and will merge. Thanks for the fix !

tlvu added a commit to Ouranosinc/pavics-sdi that referenced this issue Oct 26, 2021
Remove bugging drop after geoserver upgrade

Fixes bird-house/finch#206.

Completes bird-house/finch#207.
tlvu added a commit that referenced this issue Oct 26, 2021
Remove bugging drop after geoserver upgrade

## Overview

This PR fixes #206.  The other part of the fix is PR Ouranosinc/pavics-sdi#233.

Changes:

* Removed the `drop(columns=['bbox']` from the examples using geoserver's WFS. It seems that the bbox column is not (unexpectedly) added anymore with the upgrade.

## Additional Information
This needs to be done on the other notebook in pavics-sdi too.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants