It would be great if it were possible the schedule a the clean up geoprocessing history in a project. For example, in the Geoprocessing Options I could set GP history older than 2 weeks to be deleted. If this is not possible then make the GP history accessible via arcpy which can then be cleaned programmatically. I understand that technically this can be done by manipulating the files that make up the APRX but I would prefer not to mess around with them that way to avoid breaking things.
@KoryKramer- apologies for not responding sooner, I've been meaning to find the time to test this out. I've attempted to remove the GP history from an APRX file and using this approach doesn't seem to work (code below showing to 2 approaches I tried).
I did a bit of a deeper dive and it looks like the GP history is stored in the projects JSON (GISProject.json).
So really, I'd still like to see a solution available via arcpy OR via the project options.
#set the aprx obj
aprxFile = "<file path>"
aprx = arcpy.mp.ArcGISProject(aprxFile)
#check read only
if not aprx.isReadOnly:
### ATTEMPT 1 ###
#get the metadata obj
md = aprx.metadata
#delete
md.deleteContent("GPHISTORY")
#save
md.save()
aprx.metadata = md
aprx.save()
### ATTEMPT 2 ###
#get the metadata obj
md = arcpy.metadata.Metadata(aprxFile)
#delete
md.deleteContent("GPHISTORY")
#save
md.save()
Has anybody had success in the meantime? when I start with :
aprx = arcpy.mp.ArcGISProject("CURRENT")
aprx_metadata = aprx.metadata
print(aprx_metadata.title)
print(aprx_metadata.description)
I get 2 times "None". Seems like python cannot access the metadata.
@CordulaGöke- I ended up implementing a solution that unzips the project and removes it from the GISProject.json and then zips it all back up with an aprx extension. We had too many issues with people in the business having excessive history but we don't want to stop people from retaining any history because it can be helpful to rerun tools with the same or similar inputs in a single session. We run a scheduled task that cleans up the projects weekly so it gives users a chance to retain their history during the working week and come back Monday to a clean project.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.