Hi all,
I am trying to write a standalone python script that does something like this
arcpy.ChangeVersion_management('unnetworklayer','BRANCH', version_name, '#', 'INCLUDE')
arcpy.ValidateNetworkTopology_un('unnetworklayer', 'DEFAULT')
Solved! Go to Solution.
You should be able to pass in the URL to the feature service and layer id of the utility network to get this information. However, for creating standalone Python scripts doing fine-grained operations against ArcGIS Enterprise my recommendation is to use the ArcGIS API for Python (read this article about pros/cons of different apis for more details).
One other important item to take into consideration, that the ArcGIS API for Python will give you but ArcPy won't, is that when you connect to a version and start making edits (or validating, reconciling, etc) you are potentially going to be competing with other users for locks. If another user is editing that version, your process will fail. If your process is running on a version than other users won't be able to edit it.
You should be able to pass in the URL to the feature service and layer id of the utility network to get this information. However, for creating standalone Python scripts doing fine-grained operations against ArcGIS Enterprise my recommendation is to use the ArcGIS API for Python (read this article about pros/cons of different apis for more details).
One other important item to take into consideration, that the ArcGIS API for Python will give you but ArcPy won't, is that when you connect to a version and start making edits (or validating, reconciling, etc) you are potentially going to be competing with other users for locks. If another user is editing that version, your process will fail. If your process is running on a version than other users won't be able to edit it.
Thanks for the reply - I particularly like that pros and cons matrix in the link.
At this site many arcpy scripts are in use and not ArcGIS API for Python, so it would be great to get this script working, though its good to have that fall-back option of changing API. The edits are being applied beforehand via FME, and no-one else should be editing the version.
When using the URL to the UN layer with arcpy I cant see a way to to change version - the Validate call works on sde.default.
I've been out this week so haven't had a chance to test this on my end, but are you saying if you run a standalone python script that does the following:
You are seeing that it is still only validating default? If you're performing this test in ArcGIS Pro you should make sure that the layer name you are using is unique. I can tell you that the ArcGIS API for Python does support all this.
Hi Robert - re these three steps - I cant get those to run without error
I think its the "Create Layer" step I am stuck on - its MakeFeatureLayer I am using for this, but ValidateNetworkTopology needs a Utility Network layer, not a feature layer, and so errors.
The correct approach for what you want to do is to use the ArcGIS API for Python. I was able to get around some of this by saving an existing utility network layer to a file, then opening it as a layer file, accessing the first layer in the file. But I ran into problems in getting the rest the tools to behave properly, especially since they don't get me the ability to set/clear locks as I discussed above.
Thanks for your help Robert!