Hi everybody, is it possible to run an arcpy scripts with:
and if yes, is it possible to schedule it or run it on demand?
Thanks,
Naty
Solved! Go to Solution.
Looking to Esri's documentation on Authoring geoprocessing services with Python scripts—ArcGIS Pro | Documentation:
Most Python script tools that execute successfully on your computer will publish and execute successfully as a geoprocessing service—you do not have to modify your script in any way.
In terms of scheduling, there are multiple ways it can be done, which works best depends on your situation. Geoprocessing services themselves do not have a setting to have the service execute automatically, the service has to be called. ArcGIS Pro includes scheduling tools, which rely on Windows Task Scheduler, and Notebook Server now supports scheduling notebook tasks.
Hi @NatashaManzuiga,
Yes, it's possible to run such a script.
Get the .aprx file:
aprx = arcpy.mp.ArcGISProject(path to aprx)
https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/arcgisproject-class.htm
Define source:
Source = path to feature class on sde on Oracle
Search cursor
cursor = arcpy.da.SearchCursor(source, [fields to seach])
https://pro.arcgis.com/en/pro-app/latest/arcpy/data-access/searchcursor-class.htm
Get the layout from the .aprx
layout = aprx.listLayouts("wildcard layout name*")[0]
https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/layout-class.htm
Export to PDF:
layout.exportToPDF(path of output file)
https://pro.arcgis.com/en/pro-app/latest/help/sharing/overview/pdf-export.htm
As for scheduling, @JoshuaBixby has it right - it'll depend on your platform, but yes, it's possible.
If this answer solved your question or if you found it helpful please mark it accordingly to help others who have the same question.
Looking to Esri's documentation on Authoring geoprocessing services with Python scripts—ArcGIS Pro | Documentation:
Most Python script tools that execute successfully on your computer will publish and execute successfully as a geoprocessing service—you do not have to modify your script in any way.
In terms of scheduling, there are multiple ways it can be done, which works best depends on your situation. Geoprocessing services themselves do not have a setting to have the service execute automatically, the service has to be called. ArcGIS Pro includes scheduling tools, which rely on Windows Task Scheduler, and Notebook Server now supports scheduling notebook tasks.
I run the script with 3 parameters...and it's ok in local.
projectPath=arcpy.GetParameterAsText(0)
dbTablePath=arcpy.GetParameterAsText(1)
pdfPath=arcpy.GetParameterAsText(2)
I'trying to publish the script but how can I change the parameters (to let it run on the server) ?
and also I tried to publish a simple script...with:
print ("Hello")
and I got this error:
Script1 113 GPService https://xxxxxxxx:6443/arcgis/admin siteadmin 2021-03-24 16:33:26 Status: Failed StatusMessage: ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (http://esriurl.com/support) to Report a Bug, and refer to the error help for potential solutions or workarounds. ErrorMessage: ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (http://esriurl.com/support) to Report a Bug, and refer to the error help for potential solutions or workarounds.
Thanks, Naty
Hi @NatashaManzuiga,
Yes, it's possible to run such a script.
Get the .aprx file:
aprx = arcpy.mp.ArcGISProject(path to aprx)
https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/arcgisproject-class.htm
Define source:
Source = path to feature class on sde on Oracle
Search cursor
cursor = arcpy.da.SearchCursor(source, [fields to seach])
https://pro.arcgis.com/en/pro-app/latest/arcpy/data-access/searchcursor-class.htm
Get the layout from the .aprx
layout = aprx.listLayouts("wildcard layout name*")[0]
https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/layout-class.htm
Export to PDF:
layout.exportToPDF(path of output file)
https://pro.arcgis.com/en/pro-app/latest/help/sharing/overview/pdf-export.htm
As for scheduling, @JoshuaBixby has it right - it'll depend on your platform, but yes, it's possible.
If this answer solved your question or if you found it helpful please mark it accordingly to help others who have the same question.
I run the script with 3 parameters...and it's ok in local.
projectPath=arcpy.GetParameterAsText(0)
dbTablePath=arcpy.GetParameterAsText(1)
pdfPath=arcpy.GetParameterAsText(2)
I'trying to publish the script but how can I change the parameters (to let it run on the server) ?
and also I tried to publish a simple script...with:
print ("Hello")
and I got this error:
Script1 113 GPService https://xxxxxxxx:6443/arcgis/admin siteadmin 2021-03-24 16:33:26 Status: Failed StatusMessage: ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (http://esriurl.com/support) to Report a Bug, and refer to the error help for potential solutions or workarounds. ErrorMessage: ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (http://esriurl.com/support) to Report a Bug, and refer to the error help for potential solutions or workarounds.
Thanks, Naty
Hi Naty, would you be able to share the script/toolbox?
I just want to run it on my Linux ArcGIS Server. What I have to do?
Thanks,
Naty
Please share the simple script with the print statement in it that fails (unless the script it just the one line you already shared), then others can look at the code and try publishing it on their machines to see if there are issues.
here you are 🙂
print("Hello World")
@JoshuaBixby wrote:Please share the simple script with the print statement in it that fails (unless the script it just the one line you already shared), then others can look at the code and try publishing it on their machines to see if there are issues.
If you can't successfully publish and execute your single-line script, then something is definitely configured wrong with ArcGIS Server. Unfortunately, ERROR 999999 is a catch-all error code when something more specific isn't available. I suggest contacting Esri Support at this point because it is hard for Esri Community members to troubleshoot issues with users' ArcGIS Enterprise deployments.