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

Allowed types for registering Python functions are a different set from those allowed by RACO #903

Open
orzikhd opened this issue Jul 17, 2017 · 1 comment
Assignees

Comments

@orzikhd
Copy link
Contributor

orzikhd commented Jul 17, 2017

I ran into this issue while trying to make a UDA work in MyriaL in a jupyter notebook. RACO expects either LONG_TYPE or DOUBLE_TYPE for numerical function results, but when registering a function it is possible to register it as FLOAT_TYPE and then RACO fails to understand the type, leading to TypeError: 'NoneType' object has no attribute '__getitem__'

It seems like there should be a warning when registering the function about the type not being valid or a better error output when the type checking fails while calling the UDF/UDA.

Here is an example that is based on the argMax TwitterK example from the myria docs:

from raco.types import LONG_TYPE
def pickBasedOnValue(tuplList):
    for tupl in tuplList:
        value1 = tupl[0]
        arg1 = tupl[1]
        value2 = tupl[2]
        arg2 = tupl[3]
        if (value1 >= value2):
            return arg1
        else:
            return arg2

MyriaPythonFunction(pickBasedOnValue, LONG_TYPE).register()
from raco.types import FLOAT_TYPE
def maxValue(tuplList):
    for tupl in tuplList:
        value1 = tupl[0]
        value2 = tupl[1]
        if (value1 >= value2):
            return value1
        else:
            return value2

MyriaPythonFunction(maxValue, FLOAT_TYPE).register() 
%%query
uda argMaxAndMax(arg, val) {
    [-1 as argAcc, -1.0 as valAcc];
    
    [pickBasedOnValue(val, arg, valAcc, argAcc),
     maxValue(val, valAcc)];
    
    [argAcc, valAcc];
};
t = scan(cube300);
s = select argMaxAndMax(iOrder, vx) from t;
store(s, maxVX);

This throws the NoneType error, but using DOUBLE_TYPE instead for maxValue works.

@senderista
Copy link
Contributor

This looks like a RACO issue to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants