This is in ArcGIS Enterprise 10.9.1
So I have a geoprocessing service that creates an html file as a report. It creates this html file using the following environment/path. Here is the core of the code that I have an issue with:
workspace = arcpy.env.scratchFolder
output_folder = create_ouput_folder(workspace) # creates datetime subdirectory inside the workspace
html_report = create_html_report_file(output_folder) # creates file in output folder
# Format file with data ...
# ...
# ...
# Done formatting file
arcpy.AddMessage(html_report.name) # prints correct path: <path_to_scratch_folder_with_jobID>/scratch/<datetime>/html_report.html
# This next line is the issue. Once deployed as a geoprocessing service,
# the path to the file that is returned is: <path_to_scratch_folder_with_jobID>/scratch/html_report.html
arcpy.SetParameterAsText(1, html_report.name)
Here is an example of the output which is almost correct:
{
"paramName": "outputFile",
"dataType": "GPDataFile",
"value": {"url": "<url_to_scratch_folder_with_jobID>/scratch/html_report.html"}
}
The problem is that the SetParameterAsText function does not return the full path to the html report. For some reason it does not include the datetime subdirectory of the scratch directory. I have verified that on our servers, the file is being created in the correct location which is: <path_to_scratch_folder_with_jobID>/scratch/<datetime>/html_report.html. But instead of returning that directory, the output is: <path_to_scratch_folder_with_jobID>/scratch/html_report.html And I can verify that the script IS printing the correct path (WITH the datetime subdirectory) right before the SetParameterAsText() call. I have also verified that the options are setup correctly for the output parameter (data type is File, type is Derived, direction is Output). Why is SetParameterAsText not including the datetime subdirectory in the result path?