Publishing a Model from Pro to Server - g_ESRI_variable_1 issue

402
2
10-10-2023 10:44 AM
JPGlee
by
New Contributor II

I have a working GeoProcessing model in ArcPro that works perfectly well. Within this model I have a number of python tools.

When I publish the model to ArcGIS Server it seems fine but when I try and run the model in Server I get an error. It seems Server makes a copy of all scripts to X:\arcgisserver\directories\arcgissystem\arcgisinput 

However, one of the python scripts gets adjusted with the following added to the top of the code X:\arcgisserver\directories\arcgissystem\arcgisinput\MyTool_101023.GPServer\extracted\p30\MyTool_widget_gp\SelectFactors3.py

When I run the model I get an error and it points to SelectFactors3.py as being the problem.

Why does this g_ESRI_variable_1 get added and what does it mean?

# Esri start of added imports
import sys, os, arcpy
# Esri end of added imports

# Esri start of added variables
g_ESRI_variable_1 = 'X:\\arcgisserver\\directories\\configuration\\aliasconfiguration.json'
# Esri end of added variables

 

0 Kudos
2 Replies
DavidSolari
Occasional Contributor III

The publishing process is rewriting your script to adjust embedded paths but the heuristic is terrible and it'll often break your scripts. The workaround is to edit the server's copy, adjust your tool to avoid referencing external files that aren't standard ArcGIS resources, or copy those external files to the server directories.

JPGlee
by
New Contributor II

David, I just replaced the rewritten script on the server (via the publishing process) with the original one from my local Pro and it worked. Thank you! I'll explore more