cormorack / yodapy

Your Ocean Data Access in Python
https://cormorack.github.io/yodapy/
MIT License
9 stars 10 forks source link

yodapy OOI() object attributes seem very fragile #99

Closed robfatland closed 5 years ago

robfatland commented 5 years ago

When I try to demonstrate the reduction in scope from a search I seem to get a lot of DataFrame-related errors. One observation is that the internal state of the OOI() object seems to be changing so that ooi.sites breaks.

The simplest I found is as follows where the error is on .sites I think:

ooi=OOI()
ooi.instruments
ooi.sites

and I can expand this a bit as below and this also crashes on the last line.

ooi=OOI()
ooi.sites
ooi.instruments
ooi.sites

Here is an example error/warning printout.

/srv/conda/envs/notebook/lib/python3.6/site-packages/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
/srv/conda/envs/notebook/lib/python3.6/site-packages/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-6-f3b03b2e82d4> in <module>
      2 ooi.sites
      3 ooi.instruments
----> 4 ooi.sites

/srv/conda/envs/notebook/lib/python3.6/site-packages/yodapy/datasources/ooi/OOI.py in sites(self)
    165     def sites(self):
    166         """ Returns the OOI sites """
--> 167         if not self._sites:
    168             try:
    169                 self._sites = pd.read_csv(self._OOI_PORTAL_SITES).dropna(subset=[  # noqa

/srv/conda/envs/notebook/lib/python3.6/site-packages/pandas/core/generic.py in __nonzero__(self)
   1476         raise ValueError("The truth value of a {0} is ambiguous. "
   1477                          "Use a.empty, a.bool(), a.item(), a.any() or a.all()."
-> 1478                          .format(self.__class__.__name__))
   1479 
   1480     __bool__ = __nonzero__

ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
/srv/conda/envs/notebook/lib/python3.6/site-packages/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
/srv/conda/envs/notebook/lib/python3.6/site-packages/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
lsetiawan commented 5 years ago

Thanks! I will take a look at this.