In a python toolbox use arcpy to set an aprx scratch disk space without affecting the default geodatabase.

419
1
09-26-2023 02:43 AM
Status: Open
Labels (1)
AndyBates
New Contributor III

Hi Esri

We have had an issue setting the scratch disk in ArcPro. Just to be clear, we are setting the parameter using arcpy in a python toolbox not manually in environment settings.  Our situation it this:

  • We have a python toolbox to create drawing indexes and save a new drawing filling in the drawing index with the required information.
  • All project data is held in multiple geodatabases database, including a Temporary database for workings / junk which is deleted in time.
  • When a new aprx is created the default geodatabase and scratch disc are set to the aprx databases. We don’t use these, so we set the default geodatabase to our temporary geodatabase so any ouputs will be found in a project geodatabase. We use the code self.aprx.defaultGeodatabase = tempFolder[0]   Where tempFolder[0] is the path to our project temporary geodatabase and self.aprx is the aprx object. This line of code though will also set the scratch disc to the same temporary database which we do not want.

 

The problem is the location of the scratch disk space. This means that outputs to the scratch disk are going across the network, which significantly increases processing time. Having the scratch disc set (independently of the default geodatabase) allows us to put it on the users C drive and speed up processes. Note, even then some of our processing tasks can take 5-6 hours.

 

Having communicated with Esri support, they have confirmed that this is not currently possible for an aprx in arcpy. Here is the relevant response from your team:

 

“The screenshot below shows all the places in which geoprocessing environment settings can be defined within ArcGIS Pro.

 

AndyBates_0-1695721336926.jpeg

 

 

Whilst it is possible to define the application settings (top level) using ArcPy via the user interface, it isn’t possible to programmatically do this with ArcPy. Unfortunately, this workflow is not currently supported, however it is a valid enhancement, therefore we would recommend that you log it as an idea on the Esri Community page.”

My suggested enhancement, like doing things manually, in arcpy allow us to set the scratch disc and default geodatabase independently of each other. This would allow me in our python processing tools to find the username and set the scratch disc to their C drive user area, leaving the default outputs pointing at the project temporary geodatabase. Currently, when doing larger tasks we are in danger of increasing processing time significantly when it is avoidable, or having default outputs going to a users C drives which is not acceptable. We would much rather be able to code this process, rather than relying of users to set their env settings manually, to create a slicker processes.

 

Any queries, get in touch.

 

Regards

 

Andy

1 Comment
AndyBates

Hi Luke

You're right we can and do do this, which makes me realise I mislead a little in my text. We also need this to work for the out of the box geoprocessing tools. What I want to be able to do is every time a new aprx is created, check the default geodb goes to the server and the scratch disc goes to the C drive. Every time the aprx is saved (using our own save tools which also updates the drawing index metadata) the scratch disc location is checked as the current user and moved if needs be. 

There are ways and means, but the above would be a lot slicker. 

Regards

Andy