<?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: Error when consolidating Python Web Tool. Not all the reference code is consolidated in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/error-when-consolidating-python-web-tool-not-all/m-p/1512889#M86238</link>
    <description>&lt;P&gt;Hello people from the future, in my mirrored post in &lt;A href="https://gis.stackexchange.com/questions/484339/error-when-consolidating-python-web-tool-in-arcgis-pro-3-3-not-all-the-referenc" target="_blank" rel="noopener"&gt;gis.stackexchange&lt;/A&gt;&amp;nbsp;one of the users said:&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;EM&gt;&lt;SPAN&gt;"I chatted with the Esri Geoprocessing Services Team -- they confirmed this is a bug and have entered a ticket into their system. I can't make any promises on their behalf, but they've set a target to fix in ArcGIS Pro 3.4"&lt;/SPAN&gt;&lt;/EM&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if that is true, I can't afford such delay, therefore I had to figure a solution:&lt;/P&gt;&lt;P&gt;1. In root level, I created a file called &lt;STRONG&gt;modules_importer.py&lt;/STRONG&gt;:&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Updm2018
└── TestService.atbx
├  __init__.py
├  MyTestService.py
├  modules_importer.py
├  foo.py
└──bar
    ├ __init__.py
    ├ real_bar.py
    ├ file_required_by_baz.json
    └─ baz.py&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;2. Inside the file I put the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import sys
from os.path import exists


def set_path():
    bar_module = r".\bar"
        
    if exists(arcpy.env.packageWorkspace + '\\..\\cd\\'):
        sys.path.append(arcpy.env.packageWorkspace + '\\..\\cd\\')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. Modified the imports of the file&lt;STRONG&gt; MyTestService.py&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;...
import arcpy
import foo

arcpy.AddMessage("Loading own modules")
import modules_importer
modules_importer.set_path()
arcpy.AddMessage("AfterLoading own modules")

import bar.real_bar as real_bar
import bar.baz as baz
....&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4. When the stage definition is created, is very important&amp;nbsp; to select the &lt;STRONG&gt;Copy all data&lt;/STRONG&gt; option (in ArcGIS Pro):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cristian_Galindo_0-1722426844664.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/111181i851981435DF63BF1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cristian_Galindo_0-1722426844664.png" alt="Cristian_Galindo_0-1722426844664.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or its equivalent&amp;nbsp; in python: setting &lt;STRONG&gt;True&lt;/STRONG&gt; the property &lt;STRONG&gt;copyDataToServer&lt;/STRONG&gt; in the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/sharing/geoprocessingsharingdraft-class.htm" target="_blank" rel="noopener"&gt;GeoprocessingSharingDraft&lt;/A&gt; class.&lt;/P&gt;&lt;P&gt;when all this is set, the creation of the .sd file will consolidate, and the file structure will be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;│   manifest.xml
│   serviceconfiguration.json
│   tilingservice.xml
│
├───cd
│   ├───updm2018
│   │        foo.py
│   │       MyTestService.py
│   │       TestService.atbx
│   └───bar
│           real_bar.py
│           file_required_by_baz.json
│            baz.py
│
├───esriinfo
│   │   iteminfo.xml
│   │
│   └───metadata
│           metadata.xml
│
└───p30
        MyTestService.msd
        MyTestService.rltx
        MyTestService.tbx&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and the file &lt;STRONG&gt;modules_importer.py&lt;/STRONG&gt; will be consolidated as:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Esri start of added imports
import sys, os, arcpy
# Esri end of added imports

# Esri start of added variables
g_ESRI_variable_1 = os.path.join(arcpy.env.packageWorkspace,'..\\cd\\bar')
# Esri end of added variables

import arcpy
import sys
from os.path import exists

def set_path():    
    bar_module = g_ESRI_variable_1
    # pythonModules = r".\\" # this line make a recursive call to the current folder
    arcpy.AddMessage("Call set_path")
    arcpy.AddMessage(arcpy.env.packageWorkspace + '\\..\\cd\\')
    if exists(arcpy.env.packageWorkspace + '\\..\\cd\\'):
        sys.path.append(arcpy.env.packageWorkspace + '\\..\\cd\\')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 31 Jul 2024 12:04:59 GMT</pubDate>
    <dc:creator>Cristian_Galindo</dc:creator>
    <dc:date>2024-07-31T12:04:59Z</dc:date>
    <item>
      <title>Error when consolidating Python Web Tool. Not all the reference code is consolidated</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/error-when-consolidating-python-web-tool-not-all/m-p/1511526#M86114</link>
      <description>&lt;P&gt;In version ArcGIS Pro 2.9,3.0 and 3.1 the following structure of a web tool work as intended:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Updm2018
└── TestService.atbx
├  __init__.py
├  MyTestService.py
├  foo.py
└──bar
    ├ __init__.py
    ├ real_bar.py
    ├ file_required_by_baz.json
    └─ baz.py
&lt;/LI-CODE&gt;&lt;P&gt;The definition was staged&amp;nbsp; using the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/server/stage-service.htm" target="_blank"&gt;StageService&lt;/A&gt; function and the .sd file will include the required files.&lt;/P&gt;&lt;P&gt;Note: I also tried using the &lt;STRONG&gt;Save As Offline Service Definition&lt;/STRONG&gt; tool:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cristian_Galindo_0-1722256635293.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/110913i9F3989B77F43C32B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cristian_Galindo_0-1722256635293.png" alt="Cristian_Galindo_0-1722256635293.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;It is worth to mention that the file MyTestService.py include the imports:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;…
import foo
from bar import realbar
from bar import baz
…&lt;/LI-CODE&gt;&lt;P&gt;Execution of the tool StageService in ArcGIS Pro 3.3.1 generates an .sd file with the following structure (.sd file is just a zip file):&lt;/P&gt;&lt;LI-CODE lang="c"&gt;│   manifest.xml
│   serviceconfiguration.json
│   tilingservice.xml
│
├───cd
│   └───updm2018
│           foo.py
│           MyTestService.py
│           TestService.atbx
│
├───esriinfo
│   │   iteminfo.xml
│   │
│   └───metadata
│           metadata.xml
│
└───p30
        MyTestService.msd
        MyTestService.rltx
        MyTestService.tbx&lt;/LI-CODE&gt;&lt;P&gt;There are missing files required by the tool to properly run:&lt;/P&gt;&lt;P&gt;real_bar.py&lt;BR /&gt;file_required_by_baz.json&lt;BR /&gt;baz.py&lt;/P&gt;&lt;P&gt;The attached file contains the structure folder and Web Tool to reproduce the issue.&lt;/P&gt;&lt;P&gt;Following the indications of the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/analysis/geoprocessing/share-analysis/authoring-web-tools-with-python-scripts.htm#ESRI_SECTION1_87AFC11351574AD1A085A2528D946D3A" target="_blank"&gt;documentation&lt;/A&gt; , it should be possible to do it. As a matter of fact it has been working with out any issue, until this version.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2024 12:39:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/error-when-consolidating-python-web-tool-not-all/m-p/1511526#M86114</guid>
      <dc:creator>Cristian_Galindo</dc:creator>
      <dc:date>2024-07-29T12:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: Error when consolidating Python Web Tool. Not all the reference code is consolidated</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/error-when-consolidating-python-web-tool-not-all/m-p/1512889#M86238</link>
      <description>&lt;P&gt;Hello people from the future, in my mirrored post in &lt;A href="https://gis.stackexchange.com/questions/484339/error-when-consolidating-python-web-tool-in-arcgis-pro-3-3-not-all-the-referenc" target="_blank" rel="noopener"&gt;gis.stackexchange&lt;/A&gt;&amp;nbsp;one of the users said:&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;EM&gt;&lt;SPAN&gt;"I chatted with the Esri Geoprocessing Services Team -- they confirmed this is a bug and have entered a ticket into their system. I can't make any promises on their behalf, but they've set a target to fix in ArcGIS Pro 3.4"&lt;/SPAN&gt;&lt;/EM&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if that is true, I can't afford such delay, therefore I had to figure a solution:&lt;/P&gt;&lt;P&gt;1. In root level, I created a file called &lt;STRONG&gt;modules_importer.py&lt;/STRONG&gt;:&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Updm2018
└── TestService.atbx
├  __init__.py
├  MyTestService.py
├  modules_importer.py
├  foo.py
└──bar
    ├ __init__.py
    ├ real_bar.py
    ├ file_required_by_baz.json
    └─ baz.py&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;2. Inside the file I put the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import sys
from os.path import exists


def set_path():
    bar_module = r".\bar"
        
    if exists(arcpy.env.packageWorkspace + '\\..\\cd\\'):
        sys.path.append(arcpy.env.packageWorkspace + '\\..\\cd\\')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. Modified the imports of the file&lt;STRONG&gt; MyTestService.py&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;...
import arcpy
import foo

arcpy.AddMessage("Loading own modules")
import modules_importer
modules_importer.set_path()
arcpy.AddMessage("AfterLoading own modules")

import bar.real_bar as real_bar
import bar.baz as baz
....&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4. When the stage definition is created, is very important&amp;nbsp; to select the &lt;STRONG&gt;Copy all data&lt;/STRONG&gt; option (in ArcGIS Pro):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cristian_Galindo_0-1722426844664.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/111181i851981435DF63BF1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cristian_Galindo_0-1722426844664.png" alt="Cristian_Galindo_0-1722426844664.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or its equivalent&amp;nbsp; in python: setting &lt;STRONG&gt;True&lt;/STRONG&gt; the property &lt;STRONG&gt;copyDataToServer&lt;/STRONG&gt; in the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/sharing/geoprocessingsharingdraft-class.htm" target="_blank" rel="noopener"&gt;GeoprocessingSharingDraft&lt;/A&gt; class.&lt;/P&gt;&lt;P&gt;when all this is set, the creation of the .sd file will consolidate, and the file structure will be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;│   manifest.xml
│   serviceconfiguration.json
│   tilingservice.xml
│
├───cd
│   ├───updm2018
│   │        foo.py
│   │       MyTestService.py
│   │       TestService.atbx
│   └───bar
│           real_bar.py
│           file_required_by_baz.json
│            baz.py
│
├───esriinfo
│   │   iteminfo.xml
│   │
│   └───metadata
│           metadata.xml
│
└───p30
        MyTestService.msd
        MyTestService.rltx
        MyTestService.tbx&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and the file &lt;STRONG&gt;modules_importer.py&lt;/STRONG&gt; will be consolidated as:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Esri start of added imports
import sys, os, arcpy
# Esri end of added imports

# Esri start of added variables
g_ESRI_variable_1 = os.path.join(arcpy.env.packageWorkspace,'..\\cd\\bar')
# Esri end of added variables

import arcpy
import sys
from os.path import exists

def set_path():    
    bar_module = g_ESRI_variable_1
    # pythonModules = r".\\" # this line make a recursive call to the current folder
    arcpy.AddMessage("Call set_path")
    arcpy.AddMessage(arcpy.env.packageWorkspace + '\\..\\cd\\')
    if exists(arcpy.env.packageWorkspace + '\\..\\cd\\'):
        sys.path.append(arcpy.env.packageWorkspace + '\\..\\cd\\')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2024 12:04:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/error-when-consolidating-python-web-tool-not-all/m-p/1512889#M86238</guid>
      <dc:creator>Cristian_Galindo</dc:creator>
      <dc:date>2024-07-31T12:04:59Z</dc:date>
    </item>
  </channel>
</rss>

