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

Add monitoring missing dependency: pandas #5100

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions monitoring/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
'google-api-core<2.0.0dev,>=0.1.1',
]
extras = {
'optional': ['pandas>=0.22.0'],

This comment was marked as spam.

This comment was marked as spam.

}


Expand Down
21 changes: 9 additions & 12 deletions monitoring/tests/unit/test__dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@

try:
import pandas
except ImportError:
except ImportError: # pragma: NO COVER

This comment was marked as spam.

HAVE_PANDAS = False
else:
HAVE_PANDAS = True # pragma: NO COVER
else: # pragma: NO COVER

This comment was marked as spam.

HAVE_PANDAS = True

import unittest


PROJECT = 'my-project'

INSTANCE_NAMES = ['instance-1', 'instance-2']
Expand Down Expand Up @@ -103,11 +102,11 @@ def test_empty_labels_illegal(self):
def test_simple_label(self):
iterable = generate_query_results()
dataframe = self._call_fut(iterable, label='instance_name')
dataframe_columns_list = [i[0] for i in list(dataframe.columns)]

self.assertEqual(dataframe.shape, DIMENSIONS)
self.assertEqual(dataframe.values.tolist(), ARRAY)

self.assertEqual(list(dataframe.columns), INSTANCE_NAMES)
self.assertEqual(dataframe_columns_list, INSTANCE_NAMES)
self.assertIsNone(dataframe.columns.name)

self.assertEqual(list(dataframe.index), parse_timestamps())
Expand Down Expand Up @@ -137,13 +136,12 @@ def test_multiple_labels_with_just_one(self):

iterable = generate_query_results()
dataframe = self._call_fut(iterable, labels=NAMES)
dataframe_columns_list = [i[0] for i in list(dataframe.columns)]

self.assertEqual(dataframe.shape, DIMENSIONS)
self.assertEqual(dataframe.values.tolist(), ARRAY)

self.assertEqual(list(dataframe.columns), INSTANCE_IDS)
self.assertEqual(dataframe_columns_list, INSTANCE_IDS)
self.assertEqual(dataframe.columns.names, NAMES)
self.assertEqual(dataframe.columns.name, NAME)

self.assertEqual(list(dataframe.index), parse_timestamps())
self.assertIsNone(dataframe.index.name)
Expand Down Expand Up @@ -192,7 +190,6 @@ def test_empty_table_multiple_labels_with_just_one(self):
dataframe = self._call_fut([], labels=NAMES)
self.assertEqual(dataframe.shape, (0, 0))
self.assertEqual(dataframe.columns.names, NAMES)
self.assertEqual(dataframe.columns.name, NAME)
self.assertIsNone(dataframe.index.name)
self.assertIsInstance(dataframe.index, pandas.DatetimeIndex)

Expand All @@ -202,12 +199,12 @@ def test_empty_table_smart_labels(self):
dataframe = self._call_fut([])
self.assertEqual(dataframe.shape, (0, 0))
self.assertEqual(dataframe.columns.names, NAMES)
self.assertEqual(dataframe.columns.name, NAME)
self.assertIsNone(dataframe.index.name)
self.assertIsInstance(dataframe.index, pandas.DatetimeIndex)


class Test__sorted_resource_labels(unittest.TestCase):
@unittest.skipUnless(HAVE_PANDAS, 'No pandas')
class Test__sorted_resource_labels(unittest.TestCase): # pragma: NO COVER

This comment was marked as spam.


def _call_fut(self, labels):
from google.cloud.monitoring._dataframe import _sorted_resource_labels
Expand Down