Getting the project name of the project that imported a code library

Solved!
info-rchitect
Level 6
Getting the project name of the project that imported a code library

Hello,

 

I have a shared code library that others use by editing their `external-libraries.json` file.  Is there a way for that code library to fetch the project that has imported it?

 

thx


Operating system used: Windows 10

0 Kudos
1 Solution
Jean-Yves
Developer Advocate

Hello,

Thank you for your question!   You could leverage our python api and retrieve the project key where the library is being run:

import dataiku 
current_project_key = dataiku.default_project_key()


If you want the name of the project (not its identifier - the key) , you can run the following:

import dataiku

client = dataiku.api_client()
project = client.get_default_project()
current_project_name = project.get_metadata().get('label')


I hope this helps!

Jean-Yves

View solution in original post

1 Reply
Jean-Yves
Developer Advocate

Hello,

Thank you for your question!   You could leverage our python api and retrieve the project key where the library is being run:

import dataiku 
current_project_key = dataiku.default_project_key()


If you want the name of the project (not its identifier - the key) , you can run the following:

import dataiku

client = dataiku.api_client()
project = client.get_default_project()
current_project_name = project.get_metadata().get('label')


I hope this helps!

Jean-Yves