bird-house / flyingpigeon

WPS processes for climate model data, indices and extreme events
http://flyingpigeon.readthedocs.io/en/latest/
Apache License 2.0
19 stars 15 forks source link

make test-notebooks #321

Closed nilshempelmann closed 4 years ago

nilshempelmann commented 4 years ago

Overview

including make test-notebooks

nilshempelmann commented 4 years ago

@huard output_sanitize will be centralised in birdhouse-docs\docs\source\ ?

I removed the unittes testing the processes, they are now covered with the notebooks, is a double check necessary?

huard commented 4 years ago

Yes. unit tests can check various options. We could not be doing this for a notebook intended for documentation, which will describe only the most interesting functionality.

tlvu commented 4 years ago

output_sanitize will be centralised in birdhouse-docs\docs\source\ ?

@nilshempelmann I can not find https://github.com/birdhouse-docs. Until we settle down on the more appropriate location of that file, can you not commit the file locally and curl it from its original location https://github.com/Ouranosinc/PAVICS-e2e-workflow-tests/raw/master/notebooks/output-sanitize.cfg? That's the repo with all the Jenkins infrastructure to run notebooks from multiples git repos.

nilshempelmann commented 4 years ago

output_sanitize will be centralised in birdhouse-docs\docs\source\ ?

@nilshempelmann I can not find https://github.com/birdhouse-docs. Until we settle down on the more appropriate location of that file, can you not commit the file locally and curl it from its original location https://github.com/Ouranosinc/PAVICS-e2e-workflow-tests/raw/master/notebooks/output-sanitize.cfg? That's the repo with all the Jenkins infrastructure to run notebooks from multiples git repos.

@tlvu Here is the top level birdhouse documentation: https://github.com/bird-house/birdhouse-docs/ and gues the right place for centalisation of output-sanitize.cfg.

nilshempelmann commented 4 years ago

Yes. unit tests can check various options. We could not be doing this for a notebook intended for documentation, which will describe only the most interesting functionality.

OK I see. Will took it back, also increase it with more functionality

nilshempelmann commented 4 years ago

@tlvu Thanks for the review. Still working on the notebooks tests. This needs to add to the output_sanitize.cfg:

 assert reference_output == test_output failed:

  'Metalink con..._subset.nc.\n' == 'Metalink con..._subset.nc.\n'
    Metalink content-type detected.
    Downloading to /tmp/tmpRANDOM/slp.2000_bbox_subset.nc.
  + Downloading to /tmp/tmpRANDOM/slp.2001_bbox_subset.nc.
nilshempelmann commented 4 years ago

test-notebooks seems to fail due to the widgets in the notebooks:

~/anaconda3/envs/flyingpigeon/lib/python3.7/site-packages/birdy/client/notebook.py in monitor(execution, sleep)
     47       Number of seconds to wait before each status check.
     48     """
---> 49     progress = widgets.IntProgress(
     50         value=0,
     51         min=0,

AttributeError: 'NoneType' object has no attribute 'IntProgress'
tlvu commented 4 years ago

@tlvu Thanks for the review. Still working on the notebooks tests. This needs to add to the output_sanitize.cfg:

 assert reference_output == test_output failed:

  'Metalink con..._subset.nc.\n' == 'Metalink con..._subset.nc.\n'
    Metalink content-type detected.
    Downloading to /tmp/tmpRANDOM/slp.2000_bbox_subset.nc.
  + Downloading to /tmp/tmpRANDOM/slp.2001_bbox_subset.nc.

@nilshempelmann looks like you need to make refresh-notebooks

tlvu commented 4 years ago

test-notebooks seems to fail due to the widgets in the notebooks:

~/anaconda3/envs/flyingpigeon/lib/python3.7/site-packages/birdy/client/notebook.py in monitor(execution, sleep)
     47       Number of seconds to wait before each status check.
     48     """
---> 49     progress = widgets.IntProgress(
     50         value=0,
     51         min=0,

AttributeError: 'NoneType' object has no attribute 'IntProgress'

@nilshempelmann I am not sure about this one. Notebooks requiring user interactive input need to have a default values for when those input are not there since the test is run non-interractively. Could this also be birdy/owslib/FP errors?

tlvu commented 4 years ago

I attempt to run make test-notebooks myself, and looks like it also run all the unit tests together with the notebooks, a bit un-expected.

I also have this error:

__________________________________________________ docs/source/notebooks/plot_indices.ipynb::Cell 6 __________________________________________________
Notebook cell execution failed                                                                                                                        
Cell 6: Cell execution caused an exception                                                                                                            

Input:                                                                                                                                                
# find ensemble files for one indice based on pr files:                                                                                               

tasInd_NER = [ tas_NER+f for f in listdir(tas_NER) if '.nc' in f ]                                                                                    

resource = [f for f in tasInd_NER if tas_indice in f ] # and '_yr_' in f                        

Traceback:                                                                                

---------------------------------------------------------------------------                                                                           
FileNotFoundError                         Traceback (most recent call last)                               
<ipython-input-7-17fa5defb2a2> in <module>                                                                                
      1 # find ensemble files for one indice based on pr files:                   
      2                                                                                                                                               
----> 3 tasInd_NER = [ tas_NER+f for f in listdir(tas_NER) if '.nc' in f ] 
      4                                                                        
      5                                                                                                                                               

FileNotFoundError: [Errno 2] No such file or directory: '/home/nils/data/example_data/NER/'

Don't forget to remove this hardcoded path on your machine once you're done.

tlvu commented 4 years ago
________________________________________________ docs/source/notebooks/subset_processes.ipynb::Cell 0 ________________________________________________
Notebook cell execution failed                                                                                                                        
Cell 0: Cell execution caused an exception                                                                                                            

Input:                                                                                                                                                
# Import the WPS client and connect to the server                                                                                                     
from birdy import WPSClient                                                                                                                           
import birdy                                                                                                                                          
from os import environ                                                                                                                                

# To display Images from an url                                                                                                                       
from IPython.core.display import HTML                                                                                                                 
from IPython.display import Image                                                                                                                     

# Download files stored in a metalink                                                                                                                 
from metalink import download                                                                                                                         
import tempfile                                                                                                                                       

# wait until WPS process is finished                                                                                                                  
import time                                                                                                                                           

Traceback:                                                                                                                                            

---------------------------------------------------------------------------                                                                           
ModuleNotFoundError                       Traceback (most recent call last)                                                                           
<ipython-input-1-0b525ccfa987> in <module>                                                                                                            
      9                                                                                         
     10 # Download files stored in a metalink                                                                                                         
---> 11 from metalink import download                                                                                                                 
     12 import tempfile                                                                   
     13                                                                                                                                               

ModuleNotFoundError: No module named 'metalink'            
tlvu commented 4 years ago
__________________________________________________ docs/source/notebooks/plot_indices.ipynb::Cell 1 __________________________________________________
Notebook cell execution failed                                                                                                                        
Cell 1: Cell outputs differ                                                                                                                           

Input:                                                                                                                                                
# This cell is for server admnistration test purpose                                                                                                  
# Ignore this cell and modify the following cell according to your needs                                                                              

fp_server = environ.get('FYINGPIGEON_WPS_URL')
print(fp_server)  # link to the flyingpigoen server

Traceback:
 mismatch 'stdout'

 assert reference_output == test_output failed:

  'http://localhost:8093/wps\n' == 'None\n'
  - None
  + http://localhost:8093/wps

Should be environ.get('WPS_URL', 'https://pavics.ouranos.ca/twitcher/ows/proxy/flyingpigeon')

nilshempelmann commented 4 years ago

test-notebooks seems to fail due to the widgets in the notebooks:

~/anaconda3/envs/flyingpigeon/lib/python3.7/site-packages/birdy/client/notebook.py in monitor(execution, sleep)
     47       Number of seconds to wait before each status check.
     48     """
---> 49     progress = widgets.IntProgress(
     50         value=0,
     51         min=0,

AttributeError: 'NoneType' object has no attribute 'IntProgress'

@nilshempelmann I am not sure about this one. Notebooks requiring user interactive input need to have a default values for when those input are not there since the test is run non-interractively. Could this also be birdy/owslib/FP errors?

@huard @cehbrecht : progress=True for birdy in notebooks seems to fail in the test-notebooks. Any idea to solve the failure?

nilshempelmann commented 4 years ago
________________________________________________ docs/source/notebooks/subset_processes.ipynb::Cell 0 ________________________________________________
Notebook cell execution failed                                                                                                                        
Cell 0: Cell execution caused an exception                                                                                                            

Input:                                                                                                                                                
# Import the WPS client and connect to the server                                                                                                     
from birdy import WPSClient                                                                                                                           
import birdy                                                                                                                                          
from os import environ                                                                                                                                

# To display Images from an url                                                                                                                       
from IPython.core.display import HTML                                                                                                                 
from IPython.display import Image                                                                                                                     

# Download files stored in a metalink                                                                                                                 
from metalink import download                                                                                                                         
import tempfile                                                                                                                                       

# wait until WPS process is finished                                                                                                                  
import time                                                                                                                                           

Traceback:                                                                                                                                            

---------------------------------------------------------------------------                                                                           
ModuleNotFoundError                       Traceback (most recent call last)                                                                           
<ipython-input-1-0b525ccfa987> in <module>                                                                                                            
      9                                                                                         
     10 # Download files stored in a metalink                                                                                                         
---> 11 from metalink import download                                                                                                                 
     12 import tempfile                                                                   
     13                                                                                                                                               

ModuleNotFoundError: No module named 'metalink'            

I installed metalink manually, since the pip installation failed

nilshempelmann commented 4 years ago
__________________________________________________ docs/source/notebooks/plot_indices.ipynb::Cell 1 __________________________________________________
Notebook cell execution failed                                                                                                                        
Cell 1: Cell outputs differ                                                                                                                           

Input:                                                                                                                                                
# This cell is for server admnistration test purpose                                                                                                  
# Ignore this cell and modify the following cell according to your needs                                                                              

fp_server = environ.get('FYINGPIGEON_WPS_URL')
print(fp_server)  # link to the flyingpigoen server

Traceback:
 mismatch 'stdout'

 assert reference_output == test_output failed:

  'http://localhost:8093/wps\n' == 'None\n'
  - None
  + http://localhost:8093/wps

Should be environ.get('WPS_URL', 'https://pavics.ouranos.ca/twitcher/ows/proxy/flyingpigeon')

@tlvu Why? Should the birds be universal usable or tailord for pavics purposes?

nilshempelmann commented 4 years ago

I attempt to run make test-notebooks myself, and looks like it also run all the unit tests together with the notebooks, a bit un-expected.

I also have this error:

__________________________________________________ docs/source/notebooks/plot_indices.ipynb::Cell 6 __________________________________________________
Notebook cell execution failed                                                                                                                        
Cell 6: Cell execution caused an exception                                                                                                            

Input:                                                                                                                                                
# find ensemble files for one indice based on pr files:                                                                                               

tasInd_NER = [ tas_NER+f for f in listdir(tas_NER) if '.nc' in f ]                                                                                    

resource = [f for f in tasInd_NER if tas_indice in f ] # and '_yr_' in f                        

Traceback:                                                                                

---------------------------------------------------------------------------                                                                           
FileNotFoundError                         Traceback (most recent call last)                               
<ipython-input-7-17fa5defb2a2> in <module>                                                                                
      1 # find ensemble files for one indice based on pr files:                   
      2                                                                                                                                               
----> 3 tasInd_NER = [ tas_NER+f for f in listdir(tas_NER) if '.nc' in f ] 
      4                                                                        
      5                                                                                                                                               

FileNotFoundError: [Errno 2] No such file or directory: '/home/nils/data/example_data/NER/'

Don't forget to remove this hardcoded path on your machine once you're done.

@tlvu @cehbrecht So, we need a central place to store testdata.

huard commented 4 years ago

In birdy:

try:
    import ipywidgets
except ImportError:
    ipywidgets = None
    warnings.warn('Jupyter Notebook is not supported. Please install *ipywidgets*.', IPythonWarning)

ipywidget is probably not installed.

nilshempelmann commented 4 years ago

ipywidgets

@huard That was the trick !! test-notebooks passing.

nilshempelmann commented 4 years ago

Should be environ.get('WPS_URL', 'https://pavics.ouranos.ca/twitcher/ows/proxy/flyingpigeon')

@tlvu is there a way to avoid the hardcodes?

tlvu commented 4 years ago

Should be environ.get('WPS_URL', 'https://pavics.ouranos.ca/twitcher/ows/proxy/flyingpigeon')

@tlvu is there a way to avoid the hardcodes?

The hardcode is just to provide the default value when the environment var is not set. This is for the case when the notebook is used as tutorial by a real user.

When the notebook is used as a testing tool, that env var is set to the appropriate value or the string pavics.ouranos.ca is replaced with the real server.

So the hardcode so not cause any incompatibility and do not lock the user into only one specific server. Does that answer your concern @nilshempelmann ?