We have a python script that is being published to a GP service. One of the things it does is create a PDF file and save it. When run direct from ArcMap it saves correctly to the designated folder, but then when we publish the script to a GP service, it replaces the file path with a relative path.
We want the file path to remain absolute in this case - the target directory is permanent and accessed by other applications. In our tests we are just using a local directory, although in the production environment it is likely to be a mapped network drive.
We have tried a basic string such as r'd:\myfolder\myfile.pdf' and also os.path.join(r'd:\myfolder', 'myfile.pdf').
Our currently workaround is to edit the script file once published and replace the path again, but that seems rather hacky. It seems like there should be another, simpler way!
We have a static folder for our print server service, but I don't think the file name is static. Besides having a proxy, we have a parameter set for the path (we are still on AGS 10.2.2 ...in the process of updating) See if this will work for you
See the Parameter-> Directories for your GP print service.
edit...btw, not sure how to modify this with python...we do it manually.
GP services are expected to write to the jobs directory, as that's managed by the ArcGIS Server internally, (cleanup routines, etc), so that's why you see the service using the jobs directory defined by the site. You can create a new jobs directory and define it as the jobs directory for the GP service to use if you want to write any outputs to that location.
Thanks for the refresher....yes, that is what we did (i.e., the step before the graphic above)
If I remember correctly, we had to make sure we have the correct read/write permission on the folder, although creating above might have set it. We set a clean up mode, but my note said our web guys control that. I can't remember exactly.
This does seem to be working for us. This thread is nice, because we will have to test this all out again soon ourselves, as we hope to move to new servers and 10.5.1 in the next couple weeks. So, I'll know if we are missing a step at that time.
fwiw, if you want to see what happens from a user's perspective, choose one of the "custom map" options
and test the print.
edit: btw, if it isn't apparent above, our path is a UNC path. I just blanked the server name.
Yes, I guess our question is - what if we want to store something in a directory other than the jobs directory? We understand the security and cleanup concepts, but in this case we want to store results into various network directories that already exist. So yes, we could define the jobs directory as a workaround to get a single target output location, but I was hoping there was some python syntax to define an absolute path that retains that target throughout the publishing process.
Unfortunately, the publishing process and GP framework expect everything to be in a jobs directory. You'll need to update the published script or set up a new jobs directory as workarounds.