Default project key is not specified (no DKU_CURRENT_PROJECT_KEY in env)

Eduardo
Eduardo Registered Posts: 1

I'm creating a python function endpoint with this script:

And I don't know how to deal with this error:

Dev server deployment FAILED
Failed to initiate function server : <class 'Exception'> : Default project key is not specified (no DKU_CURRENT_PROJECT_KEY in env)

Answers

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 1,914 Neuron
    edited July 16

    Hi, when posting code always use the code block (the </> icon in the toolbar) so your code snippet can easily be copied/pasted.

    The API node doesn't have a project context. In fact the API node doesn't even have access to the project data so you will first need to establish a full Python API connection. I am guessing you are only testing in the Designer Node which comes with the API Note embedded into it which is why you haven't seen the URL error you should see with the above code. This URL should point to either a Designer or Automation node. And the API Key should be valid on those instances (see sample code below).

    While you can fetch a model from a Managed Folder in a Designer or Automation node from an API service deployed in the API node you should consider if this is pattern you want to go for. API services can be deployed on High Availability mode in Kubernetes. But if your API service has to fetch a model from a Designer or Automation node you will have a single point of failure since neither the Designer Node nor Automation Node work in HA mode. This obviously means your API service will depend on the Designer Node / Automation Node being up to be able to predict data.

    Then the other issue you got is that you are using the Internal DSS client. In general outside DSS you should be using the external API client (import dataikuapi) rather than the internal, unless there is something you want to do which is only available in the internal client.

    import dataikuapi
    
    client = dataikuapi.DSSClient("https://dss.example/", "YOURAPIKEY")
    project = client.get_project("project_key")
    folder = project.get_managed_folder("my_folder_id")
    

    https://developer.dataiku.com/12/getting-started/dataiku-python-apis/index.html

    https://developer.dataiku.com/latest/api-reference/python/managed-folders.html#dataikuapi.dss.managedfolder.DSSManagedFolder.get_settings

Setup Info
    Tags
      Help me…