I'm a bit new to python, but I decided to script out a workflow that I complete often (create checkout replicas). This is my first try at it, based on the sample script in CreateReplica_management help.
I ran the script via PythonWin to test but I've cancelled it after > 1 hour run time. This would take <1 minute if I ran through the wizard in ArcMap. Any ideas/pointers?
# Description: Create a checkout to a file GDB # Import system modules import arcpy from arcpy import env #get list of versions that will be checked out version_list = "RLB" #specify the checkout number for version & GDB naming checkout_number = 1 #specify folder ocation and file name for checkout working_folder = "D:\RLB\Python\CheckoutScript" working_file = "TestCO_%s_v%s.gdb" % (version_list, checkout_number) # Set workspace env.workspace = "D:\RLB\Python\CheckoutScript\Water_D1_version%s.sde" % (version_list) # Set local variables in_data = ["Water_Network", "Water_Features"] # feature datasets replica_type = "CHECK_OUT" output_workspace = "%s\%s" % (working_folder, working_file) replica_name = "MyReplica_%s_v%s" % (version_list, checkout_number) access_type = "FULL" initial_sender = "PARENT_DATA_SENDER" expand = "USE_DEFAULTS" reuse_schema = "DO_NOT_REUSE" get_related = "GET_RELATED" replica_geometry = "" archiving = "DO_NOT_USE_ARCHIVING" #create the empty GDB for checkout arcpy.CreateFileGDB_management(working_folder, working_file) # Execute CreateReplica arcpy.CreateReplica_management(in_data, replica_type, output_workspace, replica_name, access_type, \ initial_sender, expand, reuse_schema, get_related, replica_geometry, archiving)
Thanks, I'll give it a try., but I don't think it's hung (the checkout gdb was semi-populated, so there was still "work" to be done when I cancelled). I'm currently trying to run it through the window in ArcMap but it's taking equally as long.
Why use raw file names? The final goal is to loop through several versions and create checkouts for each, so I'd have to use variables in my paths at that point.
working_folder = "D:\RLB\Python\CheckoutScript"
working_folder = r"D:\RLB\Python\CheckoutScript"
there is a blog post and a poll on filepaths and their problems...I will spare you the details but they are important in python.
Ahhh gotcha, thank you. It was a reading comprehension fail on my part. I see what you're recommending now, and I found the blog post so it all makes sense.
The blog post, for those who are curious
No definition queries, but the GDB is a decent size. I also realized I was checking out a few feature classes (including a large related table) that I do not typically include. The script did complete in the Desktop python window but it took 52 minutes.
I'm currently trying again on a small GDB but it's still taking longer than it should.