I feel like I'm missing a very basic concept when it comes to publishing python toolbox scripts to a geoprocessing server. I've scoured the ArcGIS online help (not saying I've read everything, and it's possible I missed the important part of information in all that I've read), but I think my issue is understanding path specifications, especially when it comes to the server. I'll try to explain as best I can:
I have a python toolbox script that takes a .tif file representing elevation, and a .cfg file that supplies configuration input to a custom command line interface (CLI) executable.
The "getParameterInfo()" block of code is as follows:
paramElevation = arcpy.Parameter(displayName="Elevation File (.tif, .asc, .img)", name="elevationFile", datatype="DEFile", parameterType="Required", direction="Input") paramConfig = arcpy.Parameter(displayName="WindNinja Configuration File", name="configFile", datatype="DEFile", parameterType="Optional", direction="Input") paramOutFile = arcpy.Parameter(displayName="Output File", name="outFile", datatype="DEFile", parameterType="Derived", direction = "Output")
In the "execute()" block of code we have:
ninjaPath = "C:/WindNinja/WindNinja-2.3.0/bin/WindNinja_cli.exe" #Location of windninja CLI on server imgFile = parameters.valueAsText #User specified elevation file confFile = parameters.valueAsText #User specified configuration file args = (ninjaPath, "--elevation_file", imgFile, "--config_file", confFile) runfile = subprocess.Popen(args,stdout= subprocess.PIPE, bufsize = -1) #Run windninja cli runfile.wait() output = runfile.stdout.read() if output is None: messages.AddMessage("Results: None returned\n") else: messages.AddMessage("Results:\n" + output)
The CLI takes the elevation .tif and the configuration file, does its magic, and creates an output ASCII file as a result. However, the output ASCII file is always written to the same location as the input elevation file. A query of the location of the specified elevation file on the server returns:
which is the unique jobs id folder for the task. The script runs successfully on a local machine and takes ~20 seconds to complete. It takes about ~2 seconds to complete on the server, and a query of the unique jobs id folder afterwards shows no resulting ASCII. So here comes my list of questions:
Does a copy of the user specified elevation file actually exist in the unique jobs id folder?
Are there any arcpy tools that would allow me to copy the elevation and configuration files to a known location on the server (say the scratch workspace for example), and then run the CLI on those copies?
How can I return the resulting ASCII (once I can get the script to create it on the server, and locate where it's created) from the geoprocessing service to my local machine?