Esempio n. 1
0
    def test_deserialize_dataframe(self):
        """Test deserializing an uncompressed dataframe."""
        content = b'\n'.join([b'a,b,c', b'1,2,3', b'4,5,6'])

        result = reports.deserialize_dataframe(content)
        pd.util.testing.assert_frame_equal(
            result,
            pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=['a', 'b', 'c']))
Esempio n. 2
0
        def get(report_type, match=None, partition=None):
            """Fetch report from ZooKeeper and return it as a DataFrame."""
            try:
                data, _meta = context.GLOBAL.zk.conn.get(
                    z.path.state_report(report_type))

                df = reports.deserialize_dataframe(data)
                if match:
                    df = _match_by_name(df, report_type, match)
                if partition:
                    df = _match_by_partition(df, partition)

                return df
            except kazoo.exceptions.NoNodeError:
                raise KeyError(report_type)