Hey Dataiku community,
Hope all is well!
We have a use case where we save the App instances of our applications as a recipe in order to test running the application and have the most recent run saved for reference. However, we would like to now delete the old application as a recipe app instances and only keep the must recently run instance in the App Instance folder. Is it possible to bulk delete these projects or do we have to go in and delete 1 at a time? Is there any way to leverage DSS API's to auto delete these extraneous projects after lets say a month of inactivity?
Any suggestions are helpful, not sure if others have a similar use case, thanks!
There isn't currently a way to bulk delete projects in the UI. At the moment there is also no a way to retrieve a project's last modified date from the API.
If you can read the directory structure for projects, you could delete from a project folder based on the last time the project was modified on the filesystem, with something like this:
import os import dataiku from datetime import datetime, timedelta # to obtain your project path datadir = os.environ['DIP_HOME'] # get project folder client = dataiku.api_client() root_folder = client.get_root_project_folder() # go through all of the projects in your project folder for project_key in folder.list_project_keys(): project_location = datadir + '/config/projects/' + project_key # get the last modified date based on the project folder last modified date last_modified = datetime.fromtimestamp(os.path.getmtime(project_location)) # compare to 30 days ago older_than_30_days = datetime.now() - timedelta(days=30) if last_modified < older_than_30_days: # get and delete the project project = client.get_project(project_key) # goodbye res = project.delete()
Alternatively, if your naming convention for the projects is consistent, you may be able to simply delete based on the project name (i.e. if projects are named along the lines of project v1, project v2, project v3 for example).
I hope that helps,