Creating a project with python in project folder

MRvLuijpen
MRvLuijpen Partner, L2 Admin, L2 Designer, Dataiku DSS Core Designer, Dataiku DSS & SQL, Dataiku DSS ML Practitioner, Dataiku DSS Core Concepts, Neuron 2020, Neuron, Dataiku DSS Adv Designer, Registered, Dataiku DSS Developer, Neuron 2021, Neuron 2022, Frontrunner 2022 Finalist, Frontrunner 2022 Winner, Frontrunner 2022 Participant, Neuron 2023 Posts: 107 Neuron

Hi community,

just a small question.

If I would like to create a new project from python, I can use the create_project() function from the dssclient.py. The definition is

def create_project(self, project_key, name, owner, description=None, settings=None, project_folder_id=None)

However, I am not sure how I can set the project_folder_id.

I am able to create a new project inside the root folder (on my test machine), but of course in my situation the users are not allowed to create projects inside the root folder (only inside their own project folders.

Thanks in advance for your response,

Marc Robert

Tagged:

Answers

  • Andrey
    Andrey Dataiker Alumni Posts: 119 ✭✭✭✭✭✭✭
    edited July 17

    Hi,

    The project folder id that needs to be used in create_project function could be taken from the URL of the project folder page like

    ...project-list/i5mqS6T#testfolder

    otherwise, you can find it using API:

    root = c.get_project_folder("")
    
    [i.id for i in root.list_child_folders()]

    So in that case the call to create_project would be like:

    c.create_project("test","test", "user1", project_folder_id="i5mqS6T")

    Also, I don't know if you've seen the Project Creation Macro feature:

    https://doc.dataiku.com/dss/latest/plugins/reference/project-creation-macros.html

    It seems like it could be helpful in your case. If you have exactly 1 folder per user you could select it filtering the list of all folders using:

    project_folder.get_settings().get_owner()

    Also from DSS 8.0.3 it'll be possible to add dynamic dropdowns to the project creation UI, so you could offer a user to select from a list of available project folders.

  • MRvLuijpen
    MRvLuijpen Partner, L2 Admin, L2 Designer, Dataiku DSS Core Designer, Dataiku DSS & SQL, Dataiku DSS ML Practitioner, Dataiku DSS Core Concepts, Neuron 2020, Neuron, Dataiku DSS Adv Designer, Registered, Dataiku DSS Developer, Neuron 2021, Neuron 2022, Frontrunner 2022 Finalist, Frontrunner 2022 Winner, Frontrunner 2022 Participant, Neuron 2023 Posts: 107 Neuron

    Thank you Andrey,

    I will look into this.

Setup Info
    Tags
      Help me…