Select to view content in your preferred language

Problems sharing complex geoprocessing services to portal

47
0
8 hours ago
eiriksd
New Member

I have a case where I would like to use the BatchTrace tool from the UtilityDataManagementSupport (UDMS) toolbox through the ArcGIS Rest API on my ArcGIS Enterprise server. I therefore would like to create a service-definition that I share as a geoprocessing service. I am going to use arcgis rest api and arcpy in production, but have also tried with the "Share as web tool" function in ArcGIS Pro with the exact same problem.

My ideal solution would be to create a light wrapper .pyt file that imports the UDMS-toolbox and hardcodes some of the values that will be equal always for my case, making the usage simpler for the end users. It turns out that both this path and trying to share the BatchTrace tool directly encounters the same error, and I'm at my wits end trying to work out how to fix it:

I keep getting error "00068 Script Batch Trace contains broken project data source: String". This is after the tool has run successfully, both the light wrapper-tool AND the one from the .atbx-toolbox (where the whole toolbox was uploaded to the project in arcgis pro). I am pretty sure it is the dependencies that does not get packaged correctly but I have found no fixes or way to troubleshoot further.

 

I have also tried extracting all the logic and reimplementing the batch trace functionality but it is so complex and full of pitfalls I hope to not have to go that route...

Can anyone help me find out how to correctly package and share complex geoprocessing services and make it available in our portal? Either the BatchTrace tool inside udms or my lightweight wrapper (see code bellow)

 

For reference, the light wrapper tool code is (udms atbx-file is stored in the same folder): 

def execute(self, parameters, messages) -> None:
        in_utility_network = parameters[0].valueAsText
        trace_locations = parameters[1].valueAsText
        expression = parameters[2].valueAsText or ""
        calc_on_start = parameters[3].valueAsText

        arcpy.ImportToolbox(os.path.join(os.path.dirname(__file__), "UtilityDataManagementSupport.atbx"))

        arcpy.udms.BatchTrace(
           in_utility_network=in_utility_network,
           trace_locations=trace_locations,
           result_types="CALCULATE",
           trace_config="Trace Config:: BT LV Downstream Ex NS", # Hardcoded trace configuration for LV Downstream
           expression=expression,
           output_folder=None,
           key_field=None,
           summary_store_field=None,
           fields=self._FIELDS,
           calc_on_start=calc_on_start,
           history_field=None,
           default_terminal_id=None,
           code_block="",
        )

        parameters[4].value = str("SUCCESS")
        messages.addMessage("Batch Trace completed successfully.")

    def postExecute(self, parameters) -> None:
        return

 

0 Kudos
0 Replies