[Python] Failed to run function : <class 'Exception'> : Default project key is not specified...

Discussão em 'Python' iniciado por Stack, Dezembro 18, 2024.

  1. Stack

    Stack Membro Participativo

    Trying to create an API endpoint in Dataiku using Python for an R shiny application but when I run the test query I'm getting the error:


    Failed to run function : <class 'Exception'> : Default project key is not specified (no DKU_CURRENT_PROJECT_KEY in env)
    ​

    I've checked the project key and all is correct so unsure what's causing this issue.

    def create_batchID():
    # Specify the project key explicitly
    project_key = "SCORING_PROJECT"

    # Connect to the Dataiku instance
    client = dataiku.api_client()
    project = client.get_project(project_key)

    # Get the Snowflake connection from Dataiku
    executor = SQLExecutor2(connection="SCORE_DEV")

    get_batchID = '''SELECT batch_seq.nextval FROM dual;'''
    script_name = 'scoring'
    comment = 'SCORING_RUN'

    # Get the batch ID
    batchID_df = executor.query_to_df(get_batchID)
    batchID = int(batchID_df.iloc[0, 0])

    # Insert the batch
    insert_batch = '''CALL SP_INSERT_BATCH :)batchID_, :script_name_, :comment_);'''
    executor.execute(insert_batch, params={"batchID_": batchID, "script_name_": script_name, "comment_": comment})

    return json.dumps({"batch_id": batchID})

    Continue reading...

Compartilhe esta Página