Applications-as-recipes and ${projectKey}

JohnB Registered Posts: 32 ✭✭✭✭✭

Is there a default variable that can be used in the application that refers to the project using it as a recipe?

Something like ${callingProjectKey} ?

I have SQL merge recipes in the application that reference ${projectKey}_tablename which fail because the temporary project instance has not created the table in advance.


MERGE INTO ${projectKey}_mytable as t
USING (SELECT ID,blah) ...

Best Answer

  • fchataigner2
    fchataigner2 Dataiker Posts: 355 Dataiker
    Answer ✓

    DSS doesn't provide directly the calling project's key as variable, you have to sniff it in the scenario, for example with the python code I suggested. That would indeed be a nice improvement.


  • fchataigner2
    fchataigner2 Dataiker Posts: 355 Dataiker
    edited July 17


    if the goal is to reuse tables that are "fixed", then you should probably replace ${projectKey} in their names by either a fixed value or by another variable that you define in the project.

    The easiest to get at the projectKey of the project from which the recipe is run, is to use the variable storing it for the scenario of the app-as-recipe, and put it as a project variable:

    - in the scenario, start by a Execute Python code step with

    from dataiku.scenario import Scenario
    calling_project_key = Scenario().get_all_variables().get('scenarioTriggerParam_projectKey', dataiku.default_project_key())
    import dataiku
    p = dataiku.Project()
    vars = p.get_variables()
    vars["local"]["callingProjectKey"] = calling_project_key

    - in the project defining the app-as-recipe, add a variable called `callingProjectKey` with the projectKey as value, and use it in place of ${projectKey} in places where you want to access the same table

  • JohnB
    JohnB Registered Posts: 32 ✭✭✭✭✭


    Thanks for the reply.

    We may have a few project copies for testing and would have different tables for each.

    I can achieve the same by defining "calllingProjectKey" as a control setting in the application designer and then specifying the value in the parameter field when defining the recipe made from the application (is this the same as your example?).

    My question was whether DSS provided its own internally-set variable for the name of the calling project.
    If not, it would be a reasonable enhancement request.

Setup Info
      Help me…