Failed to run function : : Dataset (name) is specified with a relative name

rawan_mohammed
rawan_mohammed Registered Posts: 8
edited July 2024 in Using Dataiku

Hello,

I'm working on a python function endpoint, and I need to call one of the datasets from the flow in the function.

however, when I try to run the test queries I get the following error:

 Failed to run function : <class 'Exception'> : Dataset names is specified with a relative name, but no default project was found. Please use complete name

the code:

def api_py_function(features):
    code = get_city_code(features["name"])
    return code

def get_city_code(name: str):
    dataset = dataiku.Dataset("names")
    df = dataset.get_dataframe()

Operating system used: Windows 11

Best Answers

Answers

  • rawan_mohammed
    rawan_mohammed Registered Posts: 8

    Thank you! however can you tell me how to define the client? i tried all methods i found online but none of them seems to work.

    and i'm running the method in the API Designer of the same project with the dataset.

  • FlorentD
    FlorentD Dataiker, Dataiku DSS Core Designer, Registered, Moderator Posts: 52 Dataiker
    edited July 2024

    Hi,

    did you try this one:

     client = dataiku.api_client()

    This is the usual way to get the client.

    Best

  • rawan_mohammed
    rawan_mohammed Registered Posts: 8

    I have but thanks again! the problem was actually the project key

  • rawan_mohammed
    rawan_mohammed Registered Posts: 8

    Thank you! this worked but apparently what i had wrong all that time were the api and project keys.

    I was using the api key of the api i was working on, and my personal api key.

    and the problem with the project key was that it should be capitalized

Setup Info
    Tags
      Help me…