Export to GitHub

pyrrd - issue #26

fetch() function broken.


Posted on Jan 20, 2011 by Grumpy Giraffe

What steps will reproduce the problem? 1. Create an instance of the RRD class, specify an existing file. 2. Instantiate the fetch() function.

What is the expected output? What do you see instead? I expected a fetch result, I got a error instead :-)

What version of the product are you using? On what operating system? Latest version from trunk on Windows.

Please provide any additional information below.

Here's my sample code to reproduce the problem:

    rrd = RRD("../history/108732.rrd")
    print rrd.fetch(resolution=300, start='-1h', end=self.epoch_now())   

Where self.epoch_now() is the epoch datetime, right now.

Here's the error:

TypeError: fetch() takes exactly 2 arguments (3 given)

It seems to be related to the AVERAGE directive, I'm not sure how it was intended. But this is the data argument list just before passing it to the fetch function:

('../history/108732.rrd', 'AVERAGE', ['--resolution', '300', '--start', '-1h', '--end', '1295546673'])

Comment #1

Posted on May 12, 2011 by Happy Rhino

I have hit this as well.

Comment #2

Posted on Sep 18, 2011 by Swift Horse

I just hit this in 0.1 release.

It looks like fetch was broken in rev 103. http://bazaar.launchpad.net/~oubiwann/pyrrd/trunk/revision/103

The number of args return by prepareObject increased to 3, but backend.external.fetch() expects only 2 parameters.

I think this is the correct change to prepareObject:

if function == 'fetch': validParams = ['resolution', 'start', 'end'] params = common.buildParameters(obj, validParams) return (obj.filename, [obj.cf] + params)

Comment #3

Posted on Oct 18, 2011 by Happy Giraffe

Thanks, Casey! I'm putting this at the top of the list. Thanks for the patch.

Comment #4

Posted on Oct 18, 2011 by Happy Giraffe

Issue 33 has been merged into this issue.

Comment #5

Posted on Oct 18, 2011 by Happy Giraffe

Issue 36 has been merged into this issue.

Comment #6

Posted on Oct 19, 2011 by Happy Giraffe

I've pushed up Casey's fix, but haven't tested yet. If folks test this before I do, go ahead a leave a comment on this ticket with any issues encountered or if it works great for you.

Comment #7

Posted on Oct 19, 2011 by Grumpy Ox

I'm using a monkeypatched version of Casey's patch (snippet below), working fine for me.

from pyrrd.backend import external

_orig_prepareObject = external.prepareObject def monkeypatch_rrd_prepareObject(function, obj): ret = _orig_prepareObject(function, obj) if function != 'fetch': return ret filename, cf, params = ret return (filename, [cf] + params)

external.prepareObject = monkeypatch_rrd_prepareObject

Comment #8

Posted on Oct 19, 2011 by Helpful Camel

I'm using casey patch and it works fine. tested with an rrd database containing a single data source and a single cf.

Comment #9

Posted on Oct 19, 2011 by Happy Giraffe

This is great news -- I've implemented his fix exactly as presented. As soon as I have time (hopefully this week), I'll do some formal testing and then close this ticket.

If you are using his patch, you can instead switch to running from either a git checkout of master or a bzr branch of trunk (in fact, doing so would be very helpful for QA purposes).

Thanks for the update, guys!

Comment #10

Posted on Jul 25, 2012 by Helpful Rabbit

Are there any updates on this issue?

Comment #11

Posted on Feb 22, 2013 by Massive Ox

There hasn't been an official release with this bug fix in it yet. The version that's in the git repo seems fine though. Here's a quick walk-through of installing that one on a Linux system:

git clone https://code.google.com/p/pyrrd/ cd pyrrd sudo python setup.py install

And then this minimal fetch test code worked for me:

from pyrrd.rrd import RRD, RRA, DS filename="test.rrd" os.path.exists(filename) rrd = RRD(filename, mode="r") results = rrd.fetch() print results

There are TODO items for both updating the fetch documentation in the wiki and for the fetch method to "add a doctest that creates an RRD with multiple DSs and RRAs". I think all that may be aiming higher than is necessary to have a useful enough first test. Just adding the simplest possible fetch doctest would keep regressions like this one at bay, and make figuring out how to use the code a lot easier. It wasn't obvious how to construct even this simple example.

Comment #12

Posted on Jan 6, 2014 by Happy Hippo

11 +1. Installing via pip is broken at the moment.

Status: InProgress

Labels:
Type-Defect Priority-High