Standalone Scripts
Standalone scripts are useful for ETL processes, database cleanup and re-indexing, user and group management, calculations that might slow a server down during the day, daily notifications of changes, and quality control of data.
Stand-alone scripts are run from the command line using propy and are best for automated processes. The default location of propy is:
C:\Program Files\ArcGIS\Pro\bin\Python\Scripts\propy.
There are important differences to note between ArcGIS Pro toolbox scripts and standalone scripts. For standalone scripts:
Parameters should be in a config file or passed as text in the command line like normal Python scripts.
arcpy.AddMessage() does not work, you must use the default print() call in Python.
Some methods in ArcPy may not work as expected since the standalone scripts do not have full access to map documents and cannot display data like you can with an ArcGIS Pro toolbox. There are usually ways around this, especially if you have a blank project with a map the script can point to.
Locating Errors
Errors in Python can be difficult to track down, so we recommend adding a try/catch around the entire script and using the traceback library to catch any errors. You can do this for both toolboxes and stand-alone scripts. For example:
import traceback
try:
… rest of the script …
except Exception as e:
print(str(e))
print(traceback.format_exc())
If you’re writing to a log file, you can also save the string output from the traceback there.
Geoprocessing Services
Data conversion, data analysis, and data management tools are enabled via geoprocessing services. A geoprocessing service is developed as an ArcGIS Pro toolbox and then published after a successful run in ArcGIS Pro.
A geoprocessing service is necessary when users outside of ArcGIS Pro need access to a process, or if the tool is required as a published service for an application. For example, a custom analysis process could be published so a web application can access it and run calculations for display based on user input.
There are ArcPy methods that may not work once published as a geoprocessing service, so it's important to test carefully once you begin publishing. The methods that may cause issues are usually related to map functions. There are usually workarounds, it may just take extra research to find the method that works for a published service.
Note that any methods that use credits to run will also use credits once published. If you want to limit who can access your geoprocessing service, you can secure it by users or groups just like with any other published content.
Too busy to sort out the finer details of ArcPy? Argis Solutions’ experienced GIS development team is poised to support your custom tool needs with our practical, sustainable approach to tool-building. Schedule a discovery call to learn more.