I'm working with the geoprocessing server tool (GenerateOriginDestinationCostMatrix) imported as a toolbox (OriginDestinationCostMatrix) in ArcMap 10.6. Being asynchronous I use the resultID with arcpy.Results() to retrieve the status and, once complete, the results from the server. Some of my results show up as complete (result.status == 4) but when I try to retrieve and save the output_origin_destination_lines (result[1]) from the results to a geodatabase I get the error "RuntimeError: RecordSetObject: No internal record set object for Save". Most of my results save fine this way. Has anyone experienced this? Any suggestions?

Sample Code (path is a local .gdb, resultID gets cleared after 24 hours):

tool = 'GenerateOriginDestinationCostMatrix_OriginDestinationCostMatrix'
result = arcpy.Result(tool, resultID)
if result.status == 4:
     outFC = os.path.join(path, resultID)

Everything seems like it executed fine and the result hasn't been cleared from the server yet. For example result.getMessages() returns warnings but not errors, and "solve_succeeded" (results[0]) comes back as true. All the other results outputs save successfully using the same method. For example, output_destinations saves fine:

  • So it's just the 1-index (2nd output) that's causing this problem: "results/Output_Origins" ? – KHibma Dec 7 '18 at 18:48
  • @KHibma yes the second output, output_origin_destination_lines, is causing the problem, other outputs such as the output_origins (index = 3) save fine using the same syntax. – jbosq Dec 7 '18 at 18:51
  • If I believe the JSON example the destination_lines is the 1st output, 0-index – KHibma Dec 7 '18 at 18:54
  • @KHibma I'm using the toolbox instead of sending a json request. The results are slightly different between the two methods, the closest documentation I can find is this network analyst example. Index 0 is a string 'True' I've assumed for solve_succeeded. – jbosq Dec 7 '18 at 19:18
  • Ok. I see. So after further reading, what do you have the Origin_Destination_Line_Shape parameter set to? None or Straight Line? I wonder if this is causing the output to come back in a strange way? Maybe try the other value than you have set right now. – KHibma Dec 7 '18 at 19:33

This will either be a problem specific to RecordSets (tables), or the code style you're using.

You can try using the Copy Rows tool to save your table.: arcpy.CopyRows_management(result[1], outFC) But I suspect you should try the next option -

The more common approach when working with a result object is to use getOutput(#) off the result. The example explicitly shows using .save off the getOutput for features. It may not work for tables/recordsets, if not thats probably a bug. And the above way of using CopyRows should serve as a workaround when using getOutput. Keep in mind with an async GP Service, that if the server has cleaned up your result, you won't be able to get the result table back, no matter what you do. In this case I'd suspect you'd get an error on your initial result = arcpy.Result(tool, resultID) call....but I've never actually tested that to know what would happen.

Help link / eg code:

# Run a server tool named BufferPoints with featureset created above
result = arcpy.BufferPoints_server(in_featureset, "500 feet")

# Check the status of the result object every 0.2 seconds
#    until it has a value of 4 (succeeded) or greater
while result.status < 4:

# Get the output FeatureSet back from the server and save to a local geodatabase
out_featureset = result.getOutput(0)
  • result.getOutput(1).save(outFC) returns the same error. The OD matrix result is a bit weird in that it doesn't have geometry (line features) but still comes back as a feature class. arcpy.CopyFeatures_management(result.getOutput(0), outFC) returns the error "ExecuteError: Failed to execute. Parameters are not valid. ERROR 000735: Input Features: Value is required Failed to execute (CopyFeatures)". CopyRows_management() returns the same error as CopyFeatures_management(). – jbosq Dec 7 '18 at 18:43
  • After the server cleans up a result (~24 hours in this case) result = arcpy.Result(tool, resultID) will work but result.status will not – jbosq Dec 7 '18 at 20:24
  • The solution that finally worked was just to close and re-open arcMap... I'm marking this answer correct as you suggested it may just be a bug – jbosq Dec 7 '18 at 21:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.