<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: scratchworkspace for geoprocessing task in ArcGIS Enterprise Questions</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-questions/scratchworkspace-for-geoprocessing-task/m-p/601900#M23214</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are happy to leave the PDF in the Jobs scratch folder then you can use the following line to create the output path:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14056391130178007" jivemacro_uid="_14056391130178007"&gt;
&lt;P&gt;fn = r"{0}\well_map.pdf".format(arcpy.env.scratchFolder)&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, make sure not to change the scratch workspace in your script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_1405639405909127 jive_text_macro" jivemacro_uid="_1405639405909127"&gt;
&lt;P&gt;# You should be able to remove this line when running on the server:&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;arcpy.env.scratchWorkspace&amp;nbsp; = '%scratchworkspace%'&amp;nbsp;&amp;nbsp; (is this in quotes?)&lt;/SPAN&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let ArcGIS Server control the scratch directory and it will use a new Job directory each time the process runs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Owen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 17 Jul 2014 23:19:11 GMT</pubDate>
    <dc:creator>OwenEarley</dc:creator>
    <dc:date>2014-07-17T23:19:11Z</dc:date>
    <item>
      <title>scratchworkspace for geoprocessing task</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/scratchworkspace-for-geoprocessing-task/m-p/601896#M23210</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to create a geoprocessing task that will result in a pdf file.&amp;nbsp; The geoprocessing task kicks off a python script and does stuff, then generates this report as a pdf.&lt;/P&gt;&lt;P&gt;I'm having a little trouble knowing what to specifically do with the scratchworkspace.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is what I've tried: &lt;/P&gt;&lt;P&gt;attempt 1:&lt;/P&gt;&lt;P&gt;Put the scratchworkspace in the python scripts. Did this a couple of ways:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.env.scratchWorkspace = '%scratchworkspace%'&lt;/P&gt;&lt;P&gt;(result: doesn't seem to do anything)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and &lt;/P&gt;&lt;P&gt;myfile&amp;nbsp;&amp;nbsp; = "C:\\arcgisserver\\directories\\arcgisoutput\\SpecialProcess\\myfile.pdf"&lt;/P&gt;&lt;P&gt;( works when I run the python script by itself. Works when I run the script from a tool. Does not work as a geoprocessing service)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Attempt 2 :&lt;/P&gt;&lt;P&gt;Put a parameter called output_location in the tool.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tried as a data type of&amp;nbsp; folder, tried as a workspace.&lt;/P&gt;&lt;P&gt;Direction = output&lt;/P&gt;&lt;P&gt;Default = %scratchworkspace%&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When i run it, it says that the output_location already exists and won't run.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Attempt 3:&lt;/P&gt;&lt;P&gt;Don't do anything for the output_location&lt;/P&gt;&lt;P&gt;In the Environment Settings, under workspace, under Scratch Workspace - entered %scratchworkspace%&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know this is just picky and needs to be set just perfectly to work.&amp;nbsp; Can anyone spell it out for me please?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;Dorothy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Jul 2014 21:08:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/scratchworkspace-for-geoprocessing-task/m-p/601896#M23210</guid>
      <dc:creator>DorothyMortenson</dc:creator>
      <dc:date>2014-07-16T21:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: scratchworkspace for geoprocessing task</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/scratchworkspace-for-geoprocessing-task/m-p/601897#M23211</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dorothy,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have always used the &lt;SPAN class="usertext" style="background-color: rgba(255, 255, 255, 0);"&gt;in_memory&lt;/SPAN&gt; workspace. This automatically creates the files for output in the jobs folder on the server under a folder with the job id.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//01540000054q000000" title="http://resources.arcgis.com/en/help/main/10.1/index.html#//01540000054q000000"&gt;ArcGIS Help 10.1&lt;/A&gt;‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Jul 2014 21:43:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/scratchworkspace-for-geoprocessing-task/m-p/601897#M23211</guid>
      <dc:creator>AnthonyGiles</dc:creator>
      <dc:date>2014-07-16T21:43:31Z</dc:date>
    </item>
    <item>
      <title>Re: scratchworkspace for geoprocessing task</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/scratchworkspace-for-geoprocessing-task/m-p/601898#M23212</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dorothy,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When running a GP service on the server, the scratch workspace is created under a job directory. For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14055877636129650" jivemacro_uid="_14055877636129650"&gt;
&lt;P&gt;&lt;A _jive_internal="true" href="https://community.esri.com/[server]/arcgis/rest/directories/arcgisjobs/lotexport_gpserver" rel="nofollow" target="_blank"&gt;http://[server]/arcgis/rest/directories/arcgisjobs/lotexport_gpserver/&lt;/A&gt;&lt;STRONG&gt;j52e4e3ec1ff741e9aad19b8263615232&lt;/STRONG&gt;/scratch/WebMap_12345.pdf&amp;nbsp; &lt;/P&gt;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You will notice that in the path a directory with a Global ID (j52e4e3ec1ff741e9aad19b8263615232) is created to ensure the output is unique.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to control where the file is created then you can export the PDF into this job directory then copy it into your target directory using python, for example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14055877765257561" jivemacro_uid="_14055877765257561" modifiedtitle="true"&gt;
&lt;P&gt;arcpy.mapping.ExportToPDF(mxd,fn,resolution=self.dpi,image_compression="JPEG",jpeg_compression_quality=90)&lt;/P&gt;
&lt;P&gt;shutil.copyfile(fn, r"{0}\{1}.pdf".format(outdir, key))&lt;/P&gt;
&lt;P&gt;return r"{0}/{1}.pdf".format(baseurl,key)&lt;/P&gt;
&lt;P&gt;# Notes:&lt;/P&gt;
&lt;P&gt;# mxd = map document&lt;/P&gt;
&lt;P&gt;# fn = output filename (include the &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;arcpy.env.scratchWorkspace path&lt;/SPAN&gt;) &lt;/P&gt;
&lt;P&gt;# outdir = a path on the server for the output PDFs&lt;/P&gt;
&lt;P&gt;# baseurl = the virtual path to the outdir&lt;/P&gt;
&lt;P&gt;# key = unique file name&lt;/P&gt;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just make sure that your output PDF name is also unique. You can then return the URL to the PDF as the geoprocessing result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may also need to implement some kind of regular spring cleaning for this directory. Scheduled tasks work great for this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Owen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jul 2014 09:05:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/scratchworkspace-for-geoprocessing-task/m-p/601898#M23212</guid>
      <dc:creator>OwenEarley</dc:creator>
      <dc:date>2014-07-17T09:05:16Z</dc:date>
    </item>
    <item>
      <title>Re: scratchworkspace for geoprocessing task</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/scratchworkspace-for-geoprocessing-task/m-p/601899#M23213</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm afraid I'm still a little thick. I get what both of you are saying, I'm just not quite sure how to specify the workspace and file. I'm fine with the pdf staying in the scratchworkspace. I'd also be ok if it was in memory.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me with the following:&lt;/P&gt;&lt;P&gt;arcpy.env.scratchWorkspace&amp;nbsp; = '%scratchworkspace%'&amp;nbsp;&amp;nbsp; (is this in quotes?)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mxd&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = "C:\\mystuff\\ArcMap\\well_map_template.mxd"&lt;/P&gt;&lt;P&gt;&lt;SPAN class="comment"&gt;fn&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = arcpy.env.scratchWorkspace&amp;nbsp; +&amp;nbsp;&amp;nbsp; "well_map.pdf"&amp;nbsp; (this is the line I'm most confused on how to write)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;arcpy.mapping.ExportToPDF(mxd, fn, resolution=&lt;SPAN class="special"&gt;self&lt;/SPAN&gt;.dpi,image_compression=&lt;SPAN class="string"&gt;"JPEG"&lt;/SPAN&gt;,jpeg_compression_quality=&lt;SPAN class="number"&gt;90&lt;/SPAN&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="comment"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jul 2014 18:09:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/scratchworkspace-for-geoprocessing-task/m-p/601899#M23213</guid>
      <dc:creator>DorothyMortenson</dc:creator>
      <dc:date>2014-07-17T18:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: scratchworkspace for geoprocessing task</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/scratchworkspace-for-geoprocessing-task/m-p/601900#M23214</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are happy to leave the PDF in the Jobs scratch folder then you can use the following line to create the output path:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14056391130178007" jivemacro_uid="_14056391130178007"&gt;
&lt;P&gt;fn = r"{0}\well_map.pdf".format(arcpy.env.scratchFolder)&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, make sure not to change the scratch workspace in your script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_1405639405909127 jive_text_macro" jivemacro_uid="_1405639405909127"&gt;
&lt;P&gt;# You should be able to remove this line when running on the server:&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;arcpy.env.scratchWorkspace&amp;nbsp; = '%scratchworkspace%'&amp;nbsp;&amp;nbsp; (is this in quotes?)&lt;/SPAN&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let ArcGIS Server control the scratch directory and it will use a new Job directory each time the process runs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Owen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jul 2014 23:19:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/scratchworkspace-for-geoprocessing-task/m-p/601900#M23214</guid>
      <dc:creator>OwenEarley</dc:creator>
      <dc:date>2014-07-17T23:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: scratchworkspace for geoprocessing task</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/scratchworkspace-for-geoprocessing-task/m-p/601901#M23215</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah! Nice one, and a nice way to top of the end of the week.&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jul 2014 18:18:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/scratchworkspace-for-geoprocessing-task/m-p/601901#M23215</guid>
      <dc:creator>DorothyMortenson</dc:creator>
      <dc:date>2014-07-18T18:18:08Z</dc:date>
    </item>
    <item>
      <title>Re: scratchworkspace for geoprocessing task</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/scratchworkspace-for-geoprocessing-task/m-p/601902#M23216</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Owen,&lt;/P&gt;&lt;P&gt;This still isn't working as intended (despite having set it up successfully previously)&lt;/P&gt;&lt;P&gt;The output PDF is created in the correct output scratch folder fine using&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; border: 0px; font-size: 12px;"&gt;fn&amp;nbsp;=&amp;nbsp;r&lt;/SPAN&gt;&lt;SPAN class="" style="color: blue; background-color: #ffffff; border: 0px; font-size: 12px;"&gt;"{0}\well_map.pdf"&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff; border: 0px; font-size: 12px;"&gt;.format(arcpy.env.scratchFolder)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But setting output parameter to fn results in an error through the geoprocessing widget:&lt;/P&gt;&lt;P&gt;A test message I put in the code says the output path to fn is C:\Users\arcgis\Appdata\Local\Temp\geoprocessors\*name*\*ID*\scratch\well_map.pdf&lt;/P&gt;&lt;P&gt;...I don't think that's a problem itself as a similar message resolves in a same way for output featureclasses which draw fine as a map service (note: I've checked the directories of the server, none are set to a local path)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looking at the network calls/response through IE developer tools or similar, the link to the file is OK and I can click on that&amp;nbsp;and successfully open it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's just that whatever I try I cannot get the output parameter in the geoprocessing widget to successfully set to the link- It errors out with no messages (i.e. not a script problem).&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Oct 2018 19:19:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/scratchworkspace-for-geoprocessing-task/m-p/601902#M23216</guid>
      <dc:creator>GeoNZ</dc:creator>
      <dc:date>2018-10-15T19:19:15Z</dc:date>
    </item>
  </channel>
</rss>

