Using python to Validate Network Topology in a version

913
6
Jump to solution
09-15-2023 04:44 AM
jclarke
New Contributor III

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')
 
The documentation says both these tools accept a "Utility Network Layer" as input. But how can I make one? I have tried MakeFeatureLayer etc.
0 Kudos
1 Solution

Accepted Solutions
RobertKrisher
Esri Regular Contributor

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.

View solution in original post

6 Replies
RobertKrisher
Esri Regular Contributor

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.

jclarke
New Contributor III

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. 

0 Kudos
RobertKrisher
Esri Regular Contributor

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:

  • Create Layer (using feature service URL and giving it some unique layer name)
  • Change version (on layer)
  • Validate topology (on layer)

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.

0 Kudos
jclarke
New Contributor III

Hi Robert - re these three steps - I cant get those to run without error

  • Create Layer (using feature service URL and giving it some unique layer name)
  • Change version (on layer)
  • Validate topology (on layer)

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.

0 Kudos
RobertKrisher
Esri Regular Contributor

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.

0 Kudos
jclarke
New Contributor III

Thanks for your help Robert!

0 Kudos