ES-DOC / pyessv

Python Earth Science Standard Vocabularies
Other
8 stars 7 forks source link

Update Jupyter Notebook for latest API & Python 3 #15

Closed sadielbartholomew closed 4 years ago

sadielbartholomew commented 4 years ago

Hi @momipsl, I was going through the Notebook in the notebooks dir towards getting a better understanding of pyessv. Although it mostly ran fine there were some lines that did not do as expected/described. I did some investigation to work through those so might as well put in a PR to update it for the latest version (0.8.3.0 I see from PyPI) as the Notebook was last updated ~2 years ago:

  1. The second executable cell hit the following:

    ---------------------------------------------------------------------------
    AttributeError                            Traceback (most recent call last)
    <ipython-input-5-cd6afacab4fe> in <module>
          1 # Authority: WCRP.
    ----> 2 wcrp = pyessv.vocabs.wcrp
          3 assert isinstance(wcrp, pyessv.Authority)
          4 
          5 # Scope: CMIP6.
    
    AttributeError: module 'pyessv' has no attribute 'vocabs'

    but judging from the codebase wcrp = pyessv.WCRP instead would work, & indeed allows the cell to return cleanly, so I guess there was an API change since that broke this?

  2. None of the properties are returning a UUID as expected for the .uid attribute, instead producing None or for noaa_gfdl.uid throwing AttributeError: uid unknown attribute. I've suggested to remove corresponding lines since it seems the attribute is no longer valid.

  3. Executable cell 12 is checking whether objects are of type basestring which errored because I'm using Python 3 & it's for 2 only, though I saw that the utils.compat module has logic to adapt so that pyessv can run in 2 or 3, so instead of converting to a comparison to str I guess it is best to compare with compat.basestring, as suggested here?

This PR has minimal changes to get the Notebook to run as expected, including execution output differences (most of the line additions are ~10,000 from the iterative print over the node types, so it seems the vocabulary has expanded greatly in the past few years?). I'm happy to tweak it as you wish. Thanks.