Select to view content in your preferred language

Quick Import (Data Interoperability) GP tool failed after publishing on server (10.81) as web tool

312
5
05-06-2024 04:49 AM
Hari
by
New Contributor
Developed a python  script to convert a KML file to feature class using arcpy.interop.QuickImport().
Script is working as expected while executing in ArcGIS Pro and Jupyter notebook but failing  after publishing on server (10.81) as a web tool with the following error message.
 
Please help me to identify and suggest any solutions.. Thanks in advance
 
Error Message:
 
Submitted.
Executing...
Start Time: maanantai 6. toukokuuta 2024 12.04.16
Start Time: maanantai 6. toukokuuta 2024 12.04.16
D:\arcgisserver\directories\arcgisjobs\qitest_gpserver\j8f5cd54b4eb34e0a8a556eb1653c6d9f\scratch\Klippan.kml
D:\arcgisserver\directories\arcgisjobs\qitest_gpserver\j8f5cd54b4eb34e0a8a556eb1653c6d9f\scratch\scratch.gdb
Failed script QiTest...
Traceback (most recent call last):
  File "D:\arcgisserver\directories\arcgissystem\arcgisinput\QiTest.GPServer\extracted\cd\glint\qi_test.tbx#QiTest_qitest.py", line 16, in <module>
  File "d:\arcgis\server\framework\runtime\arcgis\Resources\arcpy\arcpy\interop.py", line 103, in QuickImport
    raise e
  File "d:\arcgis\server\framework\runtime\arcgis\Resources\arcpy\arcpy\interop.py", line 100, in QuickImport
    retval = convertArcObjectToPythonObject(gp.QuickImport_interop(*gp_fixargs((Input, Output), True)))
  File "d:\arcgis\server\framework\runtime\arcgis\Resources\arcpy\arcpy\geoprocessing\_base.py", line 511, in <lambda>
    return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: 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.
Failed to execute (QuickImport).
 
Scrpt:
 
# Name: QuickImport_Ex_01.py
# Requirements: None
# Description: Imports KML file to a geodatabase
# Import system modules
import arcpy
arcpy.env.overwriteOutput = True
# Check out the Data Interoperability Extension
arcpy.CheckOutExtension("DataInteroperability")
# Set local variables
kmlPath = arcpy.GetParameterAsText(0)
#r"C:\Users\xchebrapp_\Documents\ArcGIS\Projects\Glint\Hult.kml"
output_gdb =  arcpy.env.scratchGDB
arcpy.AddMessage(str(kmlPath))
arcpy.AddMessage(str(output_gdb))
# Execute Quick Ixport
res= arcpy.interop.QuickImport(kmlPath, output_gdb)
print (res)
arcpy.AddMessage(str(res))
0 Kudos
5 Replies
BruceHarold
Esri Regular Contributor

Quick Import will always try to create a new file geodatabase and the scratch GDB already exists, try using another name and make sure it doesn't exist before running Quick Import.

Hari
by
New Contributor

Thanks  BruceHarold for suggestion.

I tried by giving a new gdb name but no luck.

added line os.path.join(arcpy.env.scratchFolder,"kml_1.gdb") which tried to create new GDB as
D:\arcgisserver\directories\arcgisjobs\qitest_gpserver\j9a143afdb97044e7a4d1b8fa4d727913\scratch\kml_1.gdb.
0 Kudos
BruceHarold
Esri Regular Contributor

My guess is Quick Import's input data type is not supported in the geoprocessing framework so you can try making an embedded Spatial ETL tool that accepts a file input.  However a workspace (geodatabase) output is not supported by server side geoprocessing, so you will need to write to a zipped file geodatabase and make its path an output.

TommiTerävä1
New Contributor

I looked into this and I've narrowed down the problem. I think the parameters somehow get mangled when inputted into the tool by gp_fixargs.

Here's a very basic python tool to test this issue:

# -*- coding: utf-8 -*-

import arcpy
import os
import traceback

from pathlib import Path


class Toolbox(object):
    def __init__(self):
        self.label = "Toolbox"
        self.alias = "toolbox"

        # List of tool classes associated with this toolbox
        self.tools = [Tool]


class Tool(object):
    def __init__(self):
        self.label = "Tool"
        self.description = ""
        self.canRunInBackground = False

    def getParameterInfo(self):
        params = [
            arcpy.Parameter(
                displayName="Input file",
                name="input_file",
                direction="Input",
                parameterType="Required",
                datatype="DEFile"     
            )
        ]
        return params

    def isLicensed(self):
        return True

    def updateParameters(self, parameters):
        return

    def updateMessages(self, parameters):
        return

    def execute(self, parameters, messages):
        arcpy.env.overwriteOutput = True

        ext_status = arcpy.CheckExtension("DataInteroperability")

        if ext_status != "Available":
            arcpy.AddError(f"Data Interoperability status: {ext_status}")
        else:
            arcpy.AddMessage("Data interoperability available")

        arcpy.CheckOutExtension("DataInteroperability")
        
        kmlPath = parameters[0].valueAsText
        arcpy.AddMessage(f"Input file: {kmlPath}")

        if not os.path.exists(kmlPath):
            arcpy.AddMessage("Source file doesn't exist")
            return
        
        arcpy.AddMessage("File contents:")
        with open(kmlPath, 'r') as file:
            for row in file.readlines():
                arcpy.AddMessage(row)

        arcpy.AddMessage("")

        output_dir = arcpy.env.scratchFolder

        if not os.path.exists(output_dir):
            arcpy.AddMessage("Creating destination folder")
            Path(output_dir).mkdir(parents=True, exist_ok=True)
            
        output_gdb = os.path.join(output_dir, "export.gdb")
        arcpy.AddMessage(f"Output gdb: {output_gdb}")

        try:
            res = arcpy.interop.QuickImport(
                Input=kmlPath,
                Output=output_gdb
            )
            arcpy.AddMessage(str(res))

        except Exception as e:
            arcpy.AddMessage(traceback.format_exc())

    def postExecute(self, parameters):
        return

 

And here's a very simple test file to reproduce the error with (test.geojson):

{
  "type": "Feature",
  "geometry": {
    "type": "Point",
    "coordinates": [125.6, 10.1]
  },
  "properties": {
    "name": "Dinagat Islands"
  }
}

 
Parameters used to publish webtool:

TommiTerv1_0-1715857671565.pngTommiTerv1_1-1715857700033.png


Messages when running locally:

Data interoperability available
Input file: C:\Users\_____\_____\Documents\ArcGIS\Projects\QuickImport\test.geojson
File contents:
{
  "type": "Feature",
  "geometry": {
    "type": "Point",
    "coordinates": [125.6, 10.1]
  },
  "properties": {
    "name": "Dinagat Islands"
  }
}
Output gdb: C:\Users\_____\_____\Documents\ArcGIS\Projects\QuickImport\scratch\export.gdb
C:\Users\_____\_____\Documents\ArcGIS\Projects\QuickImport\scratch\export.gdb

 

Messages when running published as Web Tool:

Data interoperability available
Input file: D:\arcgisserver\directories\arcgisjobs\quickimporttesttool_gpserver\ja6af2726b46a455296ce7e438a7d2492\scratch\test.geojson
File contents:
{
  "type": "Feature",
  "geometry": {
    "type": "Point",
    "coordinates": [125.6, 10.1]
  },
  "properties": {
    "name": "Dinagat Islands"
  }
}
Output gdb: D:\arcgisserver\directories\arcgisjobs\quickimporttesttool_gpserver\ja6af2726b46a455296ce7e438a7d2492\scratch\export.gdb
Traceback (most recent call last):
  File "<string>", line 84, in execute
  File "d:\arcgis\server\framework\runtime\arcgis\Resources\arcpy\arcpy\interop.py", line 103, in QuickImport
    raise e
  File "d:\arcgis\server\framework\runtime\arcgis\Resources\arcpy\arcpy\interop.py", line 100, in QuickImport
    retval = convertArcObjectToPythonObject(gp.QuickImport_interop(*gp_fixargs((Input, Output), True)))
  File "d:\arcgis\server\framework\runtime\arcgis\Resources\arcpy\arcpy\geoprocessing\_base.py", line 511, in <lambda>
    return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: 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.
Failed to execute (QuickImport).
TommiTerävä1
New Contributor

The root cause seems to be version incompatibility between ArcGIS Pro and the ArcGIS Enterprise environment where the tool is published. The code provided above works without issues in a more recent AE environment.