Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

KeyError: 'WhichOneof' while converting time series data to dataframe #90

Closed
ireneusz-ptak opened this issue Mar 4, 2021 · 1 comment · Fixed by #91
Closed

KeyError: 'WhichOneof' while converting time series data to dataframe #90

ireneusz-ptak opened this issue Mar 4, 2021 · 1 comment · Fixed by #91
Assignees
Labels
api: monitoring Issues related to the googleapis/python-monitoring API. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@ireneusz-ptak
Copy link

Using the latest (2.0.1) version of the API and I just can't make this simple example work:

query=google.cloud.monitoring_v3.query.Query(monitoring_v3.services.metric_service.client.MetricServiceClient(),
            project_name,
            metric_type='storage.googleapis.com/authz/acl_operations_count', 
            end_time=None, 
            days=7
            )

query.as_dataframe()

I'm getting the following error:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~/miniconda3/lib/python3.8/site-packages/proto/message.py in __getattr__(self, key)
    559         try:
--> 560             pb_type = self._meta.fields[key].pb_type
    561             pb_value = getattr(self._pb, key)

KeyError: 'WhichOneof'

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
<ipython-input-19-a95d81571ff4> in <module>
      8 print(type(query))
      9 
---> 10 query.as_dataframe()

~/miniconda3/lib/python3.8/site-packages/google/cloud/monitoring_v3/query.py in as_dataframe(self, label, labels)
    533         :returns: A dataframe where each column represents one time series.
    534         """
--> 535         return _dataframe._build_dataframe(self, label, labels)
    536 
    537     def __deepcopy__(self, memo):

~/miniconda3/lib/python3.8/site-packages/google/cloud/monitoring_v3/_dataframe.py in _build_dataframe(time_series_iterable, label, labels)
     94     for time_series in time_series_iterable:
     95         pandas_series = pandas.Series(
---> 96             data=[_extract_value(point.value) for point in time_series.points],
     97             index=[
     98                 point.interval.end_time.ToNanoseconds() for point in time_series.points

~/miniconda3/lib/python3.8/site-packages/google/cloud/monitoring_v3/_dataframe.py in <listcomp>(.0)
     94     for time_series in time_series_iterable:
     95         pandas_series = pandas.Series(
---> 96             data=[_extract_value(point.value) for point in time_series.points],
     97             index=[
     98                 point.interval.end_time.ToNanoseconds() for point in time_series.points

~/miniconda3/lib/python3.8/site-packages/google/cloud/monitoring_v3/_dataframe.py in _extract_value(typed_value)
     47 def _extract_value(typed_value):
     48     """Extract the value from a TypedValue."""
---> 49     value_type = typed_value.WhichOneof("value")
     50     return typed_value.__getattribute__(value_type)
     51 

~/miniconda3/lib/python3.8/site-packages/proto/message.py in __getattr__(self, key)
    563             return marshal.to_python(pb_type, pb_value, absent=key not in self)
    564         except KeyError as ex:
--> 565             raise AttributeError(str(ex))
    566 
    567     def __ne__(self, other):

AttributeError: 'WhichOneof'

Is it me or it should work?

@product-auto-label product-auto-label bot added the api: monitoring Issues related to the googleapis/python-monitoring API. label Mar 4, 2021
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Mar 5, 2021
@busunkim96
Copy link
Contributor

Hi @ireneusz-ptak,

It looks like at some point we accidentally stopped running the dataframe tests (if pandas isn't installed they silently skip. Given the amount of changes to the library between 1.x and 2.x I suspect that code is very broken on the latest release.

Thank you for the report, and apologies for the inconvenience!

@busunkim96 busunkim96 self-assigned this Mar 5, 2021
@busunkim96 busunkim96 added api: clouddebugger Issues related to the Stackdriver Debugger API. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. and removed triage me I really want to be triaged. api: clouddebugger Issues related to the Stackdriver Debugger API. labels Mar 5, 2021
@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Mar 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: monitoring Issues related to the googleapis/python-monitoring API. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants