Select to view content in your preferred language

Create Geocode SD Draft error

1805
17
Jump to solution
07-21-2022 11:32 AM
AliciaShyu
Occasional Contributor

I have a script to overwrite an existing locator service, in a standalone ArcGIS Server (10.9.1) The code was originally shared by ArcGIS Geocoding Team here

I'm getting the following error when creating the sd draft file

t6vk6pW5G6.jpg

I already checked and all my paths are correct. Any ideas?

import arcpy
import pprint
from arcgis.gis import server

## Sign in to server
# this connects to a standalone server that has web adaptor installed
EGServer = server.Server(url=f"https://arcgis:6443/arcgis/admin", username, password)
print(' Connected to server')


# Overwrite any existing outputs
arcpy.env.overwriteOutput = True

locator_path = "\\\\xxxx\\xxxx\\arcgissource\\locators\\EnerGov\\ElasticSearch"
sdDraft ="\\\\xxxx\\xxxx\\arcgissource\\locators\\EnerGov\\ElasticSearch\\ElasticSearchLocator.sddraft"
sd_file = "\\\\xxxx\\xxxx\\arcgissource\\locators\\EnerGov\\ElasticSearch\\ElasticSearchLocator.sd"
service_name = "ElasticSearchLocator"
summary = "Locator for EnerGov's elastic search"
tags = "EnerGov, locator, elastic search"


## server_connection_file has agssite login
server_connection_file = "\\\\xxxx\\xxxx\\arcgissource\\locators\\EnerGov\\admin on arcgis_6443.ags"

# Create the sd draft file
analyze_messages = arcpy.CreateGeocodeSDDraft(locator_path, sdDraft, service_name,
            server_connection_file, copy_data_to_server=True, summary=summary, 
            tags=tags, max_result_size=20,max_batch_size=500, 
            suggested_batch_size=150, overwrite_existing_service=True)
print("Creating SD Draft file")
print(arcpy.GetMessages())
## Stage and upload the service if the sddraft analysis did not contain errors
if analyze_messages['errors'] == {}:
    try:
        # Execute StageService to convert sddraft file to a service definition
        # (sd) file
        arcpy.StageService_server(sdDraft, sd_file)

        # Execute UploadServiceDefinition to publish the service definition
        # file as a service
        arcpy.UploadServiceDefinition_server(sd_file, EGServer)
        print("The geocode service was successfully published")
    except arcpy.ExecuteError:
        print("An error occurred")
        print(arcpy.GetMessages(2))
else:
## If the sddraft analysis contained errors, display them
    print("Error were returned when creating service definition draft")
    pprint.pprint(analyze_messages['errors'], indent=2)

 

 

0 Kudos
1 Solution

Accepted Solutions
AliciaShyu
Occasional Contributor

At 10.9.1 (ArcGIS Server) you don't need to republish the locator service. The script only needs to stop the service, rebuild the locator and start the service.

View solution in original post

0 Kudos
17 Replies
MichaelVolz
Esteemed Contributor

Was the address locator created with the CreateAddress Locator (ArcMap) tool or Create Locator (Pro) tool?

Can you try having everything local (instead of network share) as a test to see if the script runs?

0 Kudos
AliciaShyu
Occasional Contributor

The locator was created using the Create Locator (Pro) tool.

Changing everything to my local machine gives me the same value error showing the local path.

0 Kudos
MichaelVolz
Esteemed Contributor

Is the script in this link the same as yours?

https://community.esri.com/t5/arcgis-enterprise-portal-questions/overwriting-locator-python-but-it-c...

If so, how do the input parameters look compared to yours?

0 Kudos
AliciaShyu
Occasional Contributor

Yes, the only difference is that I don't have portal setup, so I'm connecting to the server to upload the service.

0 Kudos
ShadearaGist
New Contributor

I am getting this same error, did you find the solution? 

0 Kudos
AliciaShyu
Occasional Contributor

No, no solution yet. 

0 Kudos
RonnieRichards
Regular Contributor

A couple of ideas...

  • In past versions of arcpy the .LOC was not required maybe try to add the .loc to the full locator path and see if this resolves the value error
  • For the ArcGIS Server connection, try removing the .AGS from the connection file used for the publication. This change occurred somewhere around Pro 2.7.
  • Was the ArcGIS Server connection file created in ArcMap or ArcGIS Pro? There is a difference mainly with how the credential is saved and believe we had to convert our connections over to the pro versions. 
0 Kudos
AliciaShyu
Occasional Contributor

At 10.9.1 (ArcGIS Server) you don't need to republish the locator service. The script only needs to stop the service, rebuild the locator and start the service.

0 Kudos
RonnieRichards
Regular Contributor

Thanks for this info @AliciaShyu I am curious though, what is the source of your locators?

In our situation, they are file based locators and published to servers so not sure how a script stopping/starting the service would even have access to the published locator unless the server resource directory is shared.

0 Kudos