You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be handy to have a method that returns the current location of a dataset, showing its potentially nested project path. Here is a solution that I hacked together for this:
def project_path(dataset):
"""
Return the (potentially) nested project path of the current dataset.
"""
def _find_projects(project_id, folders):
cat = session.get(project_id).payload.catalogs.project
if cat.endswith('/projects/'):
return folders
else:
pname = session.get(cat).payload.body.name
folders = [pname] + folders
return _find_projects(cat, folders)
session = dataset.resource.session
pr_id = dataset.resource.body.owner
pr_name = dataset.resource.body.owner_name
return '|'.join(_find_projects(pr_id, []) + [pr_name])
Example:
uid = '47e3e24ce2ba429fb92577be94a6b58f'
p = project_path(dataset)
p
would be: Germany|Custom Research|Vaillant Group
The above solution is missing a catch for the case of the Personal Project, but I reckon this should be easy to include.
The text was updated successfully, but these errors were encountered:
It would be handy to have a method that returns the current location of a dataset, showing its potentially nested project path. Here is a solution that I hacked together for this:
Example:
uid = '47e3e24ce2ba429fb92577be94a6b58f'
would be:
Germany|Custom Research|Vaillant Group
The above solution is missing a catch for the case of the Personal Project, but I reckon this should be easy to include.
The text was updated successfully, but these errors were encountered: