<?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: Not all scripts copy to server when publishing GP service in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/not-all-scripts-copy-to-server-when-publishing-gp/m-p/1152059#M52572</link>
    <description>&lt;P&gt;Why am I not surprised...&lt;/P&gt;&lt;P&gt;I'm assuming since you can &lt;FONT face="courier new,courier" color="#FF00FF"&gt;&lt;SPAN&gt;import utils.utils&lt;/SPAN&gt;&lt;/FONT&gt;&amp;nbsp;then it is a proper python package with a utils/__init__.py and then the other submodules like utils.py etc.&lt;/P&gt;&lt;P&gt;Possible dodgy workaround (I can't test publishing) - the &lt;A href="https://enterprise.arcgis.com/en/server/10.7/publish-services/windows/authoring-geoprocessing-tasks-with-python-scripts.htm#ESRI_SECTION1_87AFC11351574AD1A085A2528D946D3A" target="_self"&gt;docs only discuss importing modules&lt;/A&gt;&amp;nbsp;not packages (other docs discuss how to install external 3rd party packages, but that's not relevant). But there is a section in there that talks about &lt;FONT face="courier new,courier" color="#FF00FF"&gt;sys.path.append&lt;/FONT&gt;:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;Another technique for referencing modules to import is to use the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;sys.path.append&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;method. This allows you to set a path to a folder containing scripts that you need to import.&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;note that the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;sys.path.append&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;method requires a folder as an argument. Since&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;r'e:\Warehousing\Scripts'&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is a folder, &lt;EM&gt;&lt;STRONG&gt;the entire contents of the folder will be consolidated&lt;/STRONG&gt;&lt;/EM&gt;.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I paraphrased the quote slightly, but it makes me think you &lt;EM&gt;might&lt;/EM&gt; be able to throw in&amp;nbsp;&lt;FONT face="courier new,courier" color="#FF00FF"&gt;sys.path.append("utils") &lt;/FONT&gt;and the utils package and all its submodules would get consolidated and published.&lt;/P&gt;&lt;P&gt;I don't &lt;EM&gt;think&lt;/EM&gt; there would be any issue with the&amp;nbsp;&lt;FONT face="courier new,courier" color="#FF00FF"&gt;&lt;SPAN&gt;import utils.utils&lt;/SPAN&gt;&lt;/FONT&gt;&amp;nbsp;call after appending the utils dir to sys.path, I just tried in a simple python script on my local drive and it worked.&amp;nbsp; But if there is, you could always &lt;FONT face="courier new,courier" color="#FF00FF"&gt;sys.path.pop()&lt;/FONT&gt; or &lt;FONT face="courier new,courier" color="#FF00FF"&gt;del sys.path[-1]&lt;/FONT&gt; directly after the append.&lt;/P&gt;</description>
    <pubDate>Wed, 09 Mar 2022 09:47:21 GMT</pubDate>
    <dc:creator>Luke_Pinner</dc:creator>
    <dc:date>2022-03-09T09:47:21Z</dc:date>
    <item>
      <title>Not all scripts copy to server when publishing GP service</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/not-all-scripts-copy-to-server-when-publishing-gp/m-p/1151555#M52500</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;Here's what's happening&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;In ArcGIS Pro, make a toolbox script and run it successfully.&lt;/LI&gt;&lt;LI&gt;Publish as a web tool successfully&lt;/LI&gt;&lt;LI&gt;BUT, when I run the web tool, I get the following error&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="ModuleNotFound_afterpublishing.PNG" style="width: 286px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/35805i7069B1A93A8ECE65/image-dimensions/286x166?v=v2" width="286" height="166" role="button" title="ModuleNotFound_afterpublishing.PNG" alt="ModuleNotFound_afterpublishing.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I look in the server machine where published tools are hosted and I see that not all of the scripts used by the tool are uploaded to the server. Comparing the two photos below, the photo with more stuff in it is my dev folder, while the one with less stuff is the folder on the server machine. As you can see, when I publish, not all the scripts make it on to the server.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Scripts on dev/desktop" style="width: 291px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/35806iDBAFB07E6E14AEED/image-size/large?v=v2&amp;amp;px=999" role="button" title="on_dev_machine.PNG" alt="Scripts on dev/desktop" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Scripts on dev/desktop&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-right" image-alt="Scripts that actually get published to server" style="width: 241px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/35807i99B0065327181464/image-size/large?v=v2&amp;amp;px=999" role="button" title="published_in_svr.png" alt="Scripts that actually get published to server" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Scripts that actually get published to server&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As a workaround, if I manually copy over the scripts that didn't publish, then restart the web service, all works well, but this seems like an inconvenient workaround. Why aren't all scripts publishing? Do I need to tweak my code? Here is how I'm importing modules in the main script--highlighted lines are for modules that did not import*:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="imported_main_script.PNG" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/35808iC04F5629F3592005/image-size/medium?v=v2&amp;amp;px=400" role="button" title="imported_main_script.PNG" alt="imported_main_script.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* I have an untested theory that if I specify &lt;FONT face="courier new,courier" color="#0000FF"&gt;from &amp;lt;module&amp;gt; import &amp;lt;thing&amp;gt;&lt;/FONT&gt; that it will result in the module not uploading. Is this the case? Do I instead need to write &lt;FONT face="courier new,courier" color="#0000FF"&gt;import &amp;lt;module&amp;gt;&lt;/FONT&gt; then in my code specify &lt;FONT face="courier new,courier" color="#0000FF"&gt;&amp;lt;module&amp;gt;.&amp;lt;thing&amp;gt;&lt;/FONT&gt;?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 00:14:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/not-all-scripts-copy-to-server-when-publishing-gp/m-p/1151555#M52500</guid>
      <dc:creator>DarrenConly</dc:creator>
      <dc:date>2022-03-08T00:14:25Z</dc:date>
    </item>
    <item>
      <title>Re: Not all scripts copy to server when publishing GP service</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/not-all-scripts-copy-to-server-when-publishing-gp/m-p/1151570#M52501</link>
      <description>&lt;P&gt;Your theory is likely correct, this has been noticed previously (see 2nd comment below this &lt;A href="https://gis.stackexchange.com/a/43213/2856" target="_self"&gt;GIS-SE answer&lt;/A&gt;).&lt;/P&gt;&lt;P&gt;You can also use&amp;nbsp;&lt;FONT face="courier new,courier" color="#0000FF"&gt;import &lt;/FONT&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;&amp;lt;module&amp;gt;.&amp;lt;thing&amp;gt; as&amp;nbsp;&amp;lt;thing&amp;gt;.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 03:49:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/not-all-scripts-copy-to-server-when-publishing-gp/m-p/1151570#M52501</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2022-03-08T03:49:31Z</dc:date>
    </item>
    <item>
      <title>Re: Not all scripts copy to server when publishing GP service</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/not-all-scripts-copy-to-server-when-publishing-gp/m-p/1151784#M52535</link>
      <description>&lt;P&gt;Thanks Luke,&lt;/P&gt;&lt;P&gt;Progress but still no victory yet. Here's what happens:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Rejiggered code to the import &amp;lt;module&amp;gt;.&amp;lt;thing&amp;gt; format as discussed above.&lt;/LI&gt;&lt;LI&gt;Successfully ran in Pro&lt;/LI&gt;&lt;LI&gt;Successfully published (after mysteriously getting a few 00068 errors)&lt;/LI&gt;&lt;LI&gt;Checked in server. As you'll see below, all of the stuff in the main folder got published (yay! Progress!), but the utils folder still didn't publish, even though one of the main scripts (accessibility_calcs.py) calls a script from within the utils folder using the import command &lt;FONT face="courier new,courier" color="#0000FF"&gt;import utils.utils as ut.&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="published_in_svr_change_import_syntax.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/35861iB6F3A1FA242FDD84/image-size/medium?v=v2&amp;amp;px=400" role="button" title="published_in_svr_change_import_syntax.png" alt="published_in_svr_change_import_syntax.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 16:30:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/not-all-scripts-copy-to-server-when-publishing-gp/m-p/1151784#M52535</guid>
      <dc:creator>DarrenConly</dc:creator>
      <dc:date>2022-03-08T16:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: Not all scripts copy to server when publishing GP service</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/not-all-scripts-copy-to-server-when-publishing-gp/m-p/1152059#M52572</link>
      <description>&lt;P&gt;Why am I not surprised...&lt;/P&gt;&lt;P&gt;I'm assuming since you can &lt;FONT face="courier new,courier" color="#FF00FF"&gt;&lt;SPAN&gt;import utils.utils&lt;/SPAN&gt;&lt;/FONT&gt;&amp;nbsp;then it is a proper python package with a utils/__init__.py and then the other submodules like utils.py etc.&lt;/P&gt;&lt;P&gt;Possible dodgy workaround (I can't test publishing) - the &lt;A href="https://enterprise.arcgis.com/en/server/10.7/publish-services/windows/authoring-geoprocessing-tasks-with-python-scripts.htm#ESRI_SECTION1_87AFC11351574AD1A085A2528D946D3A" target="_self"&gt;docs only discuss importing modules&lt;/A&gt;&amp;nbsp;not packages (other docs discuss how to install external 3rd party packages, but that's not relevant). But there is a section in there that talks about &lt;FONT face="courier new,courier" color="#FF00FF"&gt;sys.path.append&lt;/FONT&gt;:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;Another technique for referencing modules to import is to use the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;sys.path.append&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;method. This allows you to set a path to a folder containing scripts that you need to import.&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;note that the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;sys.path.append&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;method requires a folder as an argument. Since&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;r'e:\Warehousing\Scripts'&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is a folder, &lt;EM&gt;&lt;STRONG&gt;the entire contents of the folder will be consolidated&lt;/STRONG&gt;&lt;/EM&gt;.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I paraphrased the quote slightly, but it makes me think you &lt;EM&gt;might&lt;/EM&gt; be able to throw in&amp;nbsp;&lt;FONT face="courier new,courier" color="#FF00FF"&gt;sys.path.append("utils") &lt;/FONT&gt;and the utils package and all its submodules would get consolidated and published.&lt;/P&gt;&lt;P&gt;I don't &lt;EM&gt;think&lt;/EM&gt; there would be any issue with the&amp;nbsp;&lt;FONT face="courier new,courier" color="#FF00FF"&gt;&lt;SPAN&gt;import utils.utils&lt;/SPAN&gt;&lt;/FONT&gt;&amp;nbsp;call after appending the utils dir to sys.path, I just tried in a simple python script on my local drive and it worked.&amp;nbsp; But if there is, you could always &lt;FONT face="courier new,courier" color="#FF00FF"&gt;sys.path.pop()&lt;/FONT&gt; or &lt;FONT face="courier new,courier" color="#FF00FF"&gt;del sys.path[-1]&lt;/FONT&gt; directly after the append.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2022 09:47:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/not-all-scripts-copy-to-server-when-publishing-gp/m-p/1152059#M52572</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2022-03-09T09:47:21Z</dc:date>
    </item>
    <item>
      <title>Re: Not all scripts copy to server when publishing GP service</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/not-all-scripts-copy-to-server-when-publishing-gp/m-p/1153031#M52703</link>
      <description>&lt;P&gt;Thanks for the tip Luke. I was trying the &lt;FONT face="courier new,courier" color="#FF00FF"&gt;sys.path.append("utils")&lt;/FONT&gt; approach and for some reason it was giving me a "module not found error". I then tried adding an __init__.py script to the utils folder, but that didn't fix it, but then commenting out the &lt;FONT face="courier new,courier" color="#FF00FF"&gt;sys.path.append("utils")&lt;/FONT&gt; did seem to fix it. At the same time my Arc Pro has been inconsistent this morning--I'll try the .append() approach perhaps on a different day after restarting my machine.&lt;/P&gt;&lt;P&gt;Just too bad that the utils folder doesn't just import!&lt;/P&gt;</description>
      <pubDate>Fri, 11 Mar 2022 19:17:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/not-all-scripts-copy-to-server-when-publishing-gp/m-p/1153031#M52703</guid>
      <dc:creator>DarrenConly</dc:creator>
      <dc:date>2022-03-11T19:17:27Z</dc:date>
    </item>
  </channel>
</rss>

